/* ============================================================
   Iravakan Legal AI — style.css v6.0.0
   Тёмная тема по умолчанию, юридический премиум стиль
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Source+Sans+3:wght@300;400;500;600&display=swap');

/* ---- CSS ПЕРЕМЕННЫЕ ---- */
:root {
    --bg-primary:    #09090e;
    --bg-secondary:  #0f0f16;
    --bg-tertiary:   #17171f;
    --bg-elevated:   #1d1d28;
    --text-primary:  #ededf4;
    --text-secondary:#9696b0;
    --text-tertiary: #55556a;
    --border-light:  #252535;
    --border-medium: #30304a;
    --accent:        #7c6fff;
    --accent-hover:  #5c50dd;
    --accent-glow:   rgba(124, 111, 255, 0.25);
    --danger:        #ff5a5a;
    --success:       #4dffa0;
    --gold:          #ffd055;
    --gold-dark:     #c8a000;
    --shadow:        0 4px 24px rgba(0,0,0,0.45);
    --shadow-soft:   0 2px 10px rgba(0,0,0,0.25);
    --transition:    0.18s ease;
    --radius:        14px;
    --radius-sm:     8px;
}

[data-theme="light"] {
    --bg-primary:    #f3f3f8;
    --bg-secondary:  #ffffff;
    --bg-tertiary:   #eaeaf2;
    --bg-elevated:   #f0f0f8;
    --text-primary:  #111120;
    --text-secondary:#44445a;
    --text-tertiary: #88889a;
    --border-light:  #dddde8;
    --border-medium: #c8c8d8;
    --accent-glow:   rgba(124, 111, 255, 0.12);
    --shadow:        0 4px 20px rgba(0,0,0,0.10);
    --shadow-soft:   0 2px 8px rgba(0,0,0,0.07);
}

/* ---- RESET ---- */
*, *::before, *::after {
    margin: 0; padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Source Sans 3', 'Segoe UI', 'Noto Sans', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    transition: background var(--transition), color var(--transition);
    line-height: 1.6;
}

/* ---- СКРОЛЛБАР ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-medium); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ---- АНИМАЦИИ ---- */
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50%       { opacity: 1; }
}
@keyframes typingDot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%           { transform: scale(1);   opacity: 1;   }
}

/* ---- LAYOUT ---- */
.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
}

/* ==============================
   САЙДБАР
   ============================== */
.sidebar {
    width: 270px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    gap: 14px;
    flex-shrink: 0;
    transition: transform var(--transition);
    z-index: 100;
}

.sidebar-header { padding: 0 4px; }
.sidebar-header h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--text-primary);
    line-height: 1.3;
}
.sub-logo {
    font-size: 0.67rem;
    color: var(--text-tertiary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-top: 2px;
    display: block;
}

.new-chat-btn {
    background: var(--accent);
    border: none;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
    color: white;
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition);
    text-align: left;
}
.new-chat-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 14px var(--accent-glow);
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-item {
    background: none;
    border: none;
    text-align: left;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.82rem;
    font-family: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nav-item.active, .nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.nav-item.active {
    border-left: 2px solid var(--accent);
    padding-left: 8px;
}

.sidebar-footer {
    border-top: 1px solid var(--border-light);
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sync-status {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    line-height: 1.4;
}

.tariff-box {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 10px;
    font-size: 0.78rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#lbl-current-tariff {
    font-weight: 500;
    color: var(--text-secondary);
}

.tariff-selector-container select {
    width: 100%;
    padding: 6px 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    border-radius: 6px;
    font-size: 0.78rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
}

.upgrade-btn {
    background: var(--gold);
    color: #000;
    border: none;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    transition: opacity var(--transition);
    width: 100%;
}
.upgrade-btn:hover { opacity: 0.88; }

.logout-btn {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.73rem;
    font-family: inherit;
    transition: all var(--transition);
}
.logout-btn:hover {
    background: var(--danger);
    color: white;
}

/* ==============================
   ОСНОВНАЯ ОБЛАСТЬ
   ============================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    min-width: 0;
}

/* ---- TOP BAR ---- */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
    gap: 10px;
    flex-shrink: 0;
}

.chat-title-area h2 {
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}
.chat-title-area p {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.top-bar-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* LIVE Toggle */
.live-toggle-container {
    display: flex;
    align-items: center;
    gap: 7px;
}
.live-label {
    font-size: 0.73rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.03em;
}
.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 22px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border-medium);
    transition: 0.2s;
    border-radius: 22px;
}
.slider::before {
    content: '';
    position: absolute;
    height: 16px; width: 16px;
    left: 3px; bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
}
input:checked + .slider { background: var(--accent); }
input:checked + .slider::before { transform: translateX(20px); }

#lang-selector {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    outline: none;
    font-family: inherit;
}

.icon-btn {
    background: var(--bg-tertiary) !important;
    border: 1px solid var(--border-light) !important;
    border-radius: 50% !important;
    width: 34px !important;
    height: 34px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer;
    font-size: 15px;
    transition: background var(--transition);
}
.icon-btn:hover { background: var(--bg-elevated) !important; }

/* ==============================
   ИСТОРИЯ ЧАТА
   ============================== */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.message-wrapper {
    display: flex;
    animation: fadeSlideUp 0.22s ease-out;
}
.message-wrapper.user { justify-content: flex-end; }
.message-wrapper.ai   { justify-content: flex-start; }

.message {
    max-width: 78%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.88rem;
    line-height: 1.55;
    word-break: break-word;
    box-shadow: var(--shadow-soft);
}
.message-wrapper.user .message {
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}
.message-wrapper.ai .message {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-light);
}
.message strong { font-weight: 600; }
.message em { font-style: italic; opacity: 0.85; }
.message code {
    background: var(--bg-tertiary);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.83em;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

/* Точки набора текста */
.typing-dots {
    display: inline-flex;
    gap: 4px;
    font-size: 1.1rem;
    letter-spacing: 2px;
    animation: pulse 1.2s infinite;
}

/* ---- LIVE индикатор ---- */
.live-indicator {
    background: var(--bg-tertiary);
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.73rem;
    color: var(--gold);
    border-top: 1px solid var(--border-light);
    flex-shrink: 0;
}
.spinner {
    width: 14px; height: 14px;
    border: 2px solid var(--gold);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.65s linear infinite;
    flex-shrink: 0;
}

/* ==============================
   ЗОНА ВВОДА
   ============================== */
.input-area {
    padding: 14px 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-light);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 8px 14px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.attach-btn {
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    color: var(--text-tertiary);
    transition: color var(--transition);
    padding: 4px;
    flex-shrink: 0;
}
.attach-btn:hover { color: var(--accent); }

textarea {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    resize: none;
    font-size: 0.88rem;
    font-family: inherit;
    outline: none;
    padding: 4px 0;
    max-height: 160px;
    line-height: 1.5;
}
textarea::placeholder { color: var(--text-tertiary); }

.send-btn {
    background: var(--accent);
    border: none;
    color: white;
    padding: 7px 16px;
    border-radius: 40px;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: opacity var(--transition), background var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.file-badge {
    display: inline-block;
    background: var(--success);
    color: #000;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    margin-top: 8px;
}

.input-hint {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    margin-top: 6px;
    text-align: center;
    letter-spacing: 0.02em;
}

/* ==============================
   МОДАЛКИ
   ============================== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeSlideUp 0.18s ease;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 22px;
    padding: 28px;
    max-width: 480px;
    width: 92%;
    border: 1px solid var(--border-light);
    position: relative;
    box-shadow: var(--shadow);
}

.close-modal {
    position: absolute;
    top: 14px; right: 18px;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-tertiary);
    line-height: 1;
    transition: color var(--transition);
}
.close-modal:hover { color: var(--text-primary); }

/* About modal */
.modal-content h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    margin-bottom: 14px;
}
.modal-content p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.6;
}

/* Payment modal */
.payment-card .price-tag {
    font-family: 'Playfair Display', serif;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--gold);
    text-align: center;
    margin: 18px 0;
}

.checkout-btn {
    background: var(--accent);
    color: white;
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 40px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background var(--transition);
}
.checkout-btn:hover { background: var(--accent-hover); }
.checkout-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ==============================
   SURVEY OVERLAY
   ============================== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(8px);
}

.survey-card {
    background: var(--bg-secondary);
    border-radius: 28px;
    padding: 36px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow);
    animation: fadeSlideUp 0.28s ease;
}

.survey-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.35rem;
    margin-bottom: 6px;
}
.survey-header p {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    margin-bottom: 20px;
}

.form-group {
    text-align: left;
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    font-size: 0.78rem;
    margin-bottom: 6px;
    color: var(--text-secondary);
}
.form-group select,
.form-group input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--transition);
}
.form-group select:focus,
.form-group input:focus {
    border-color: var(--accent);
}

.primary-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 11px 16px;
    border-radius: 40px;
    cursor: pointer;
    width: 100%;
    font-weight: 700;
    font-size: 0.88rem;
    font-family: inherit;
    transition: background var(--transition);
}
.primary-btn:hover { background: var(--accent-hover); }

/* Google login button контейнер */
#google-login-btn-container {
    display: flex;
    justify-content: center;
    margin-top: 4px;
}

/* ==============================
   TOAST
   ============================== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-elevated);
    border-left: 3px solid var(--accent);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.85rem;
    box-shadow: var(--shadow);
    animation: fadeSlideUp 0.22s ease;
    z-index: 3000;
    max-width: 320px;
    line-height: 1.4;
}

/* ==============================
   БУРГЕР / МОБИЛКА
   ============================== */
.burger-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
}

.hidden { display: none !important; }

@media (max-width: 768px) {
    .burger-menu-btn { display: block; }
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        transform: translateX(-100%);
        z-index: 200;
        width: 260px;
    }
    .sidebar.mobile-open { transform: translateX(0); }
    .message { max-width: 92%; }
    .top-bar { padding: 10px 14px; }
    .chat-history { padding: 16px; }
    .chat-title-area h2 { max-width: 180px; font-size: 0.88rem; }
    .top-bar-controls { gap: 8px; }
    .live-label { display: none; }
}
