/* === Chat Widget — Modern Dark Theme === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #0f0f1a;
    --bg2: #161625;
    --bg3: #1e1e32;
    --surface: #252540;
    --surface2: #2d2d4a;
    --border: rgba(255,255,255,.06);
    --border2: rgba(255,255,255,.1);
    --primary: #7c5cfc;
    --primary2: #6a4ce0;
    --primary-glow: rgba(124,92,252,.15);
    --accent: #00d4aa;
    --accent-glow: rgba(0,212,170,.12);
    --danger: #ff5c5c;
    --text: #f0f0f8;
    --text2: #a0a0c0;
    --text3: #6a6a90;
    --user-bg: linear-gradient(135deg, #7c5cfc, #5a3fd4);
    --ai-bg: #1e1e32;
    --radius: 16px;
    --shadow: 0 8px 32px rgba(0,0,0,.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* === AUTH PAGE === */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg);
    background-image: radial-gradient(ellipse at 50% 0%, rgba(124,92,252,.08) 0%, transparent 60%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 40px 36px;
    box-shadow: var(--shadow);
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), #9d7dff);
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 16px;
    box-shadow: 0 8px 24px rgba(124,92,252,.3);
}

.auth-logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff, #c0b0ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-logo p {
    font-size: .85rem;
    color: var(--text3);
    margin-top: 4px;
}

.auth-tabs {
    display: flex;
    background: var(--bg);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 28px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    border-radius: 10px;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text3);
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    transition: .2s;
}

.auth-tab.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(124,92,252,.3);
}

.auth-form { display: none; }
.auth-form.active { display: block; }

.field {
    margin-bottom: 18px;
}

.field label {
    display: block;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.field input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border2);
    border-radius: 12px;
    color: var(--text);
    font-size: .9rem;
    font-family: inherit;
    outline: none;
    transition: border-color .2s;
}

.field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.field input::placeholder { color: var(--text3); }

.auth-btn {
    width: 100%;
    padding: 14px;
    background: var(--user-bg);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: .95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: transform .1s, box-shadow .2s;
    margin-top: 8px;
}

.auth-btn:hover {
    box-shadow: 0 6px 20px rgba(124,92,252,.35);
}

.auth-btn:active { transform: scale(.98); }

.auth-error {
    color: var(--danger);
    font-size: .82rem;
    text-align: center;
    margin-top: 12px;
    min-height: 20px;
}

/* === CHAT PAGE === */
.chat-layout {
    display: flex;
    height: 100vh;
}

/* Сайдбар */
.sidebar {
    width: 280px;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), #9d7dff);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.sidebar-header h2 {
    font-size: .95rem;
    font-weight: 700;
}

.new-chat-btn {
    margin: 16px 16px 8px;
    padding: 12px;
    background: var(--primary-glow);
    border: 1px dashed rgba(124,92,252,.3);
    border-radius: 12px;
    color: var(--primary);
    font-size: .85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: .2s;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.new-chat-btn:hover {
    background: rgba(124,92,252,.2);
    border-color: var(--primary);
}

/* Список чатов */
.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-list::-webkit-scrollbar { width: 4px; }
.chat-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

.chat-item {
    padding: 12px 14px;
    border-radius: 12px;
    cursor: pointer;
    transition: .15s;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-item:hover { background: var(--surface); }
.chat-item.active { background: var(--primary-glow); border: 1px solid rgba(124,92,252,.2); }

.chat-item-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.chat-item-text {
    flex: 1;
    min-width: 0;
}

.chat-item-title {
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-date {
    font-size: .7rem;
    color: var(--text3);
    margin-top: 2px;
}

.chat-item-del {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text3);
    font-size: 14px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: .15s;
}

.chat-item:hover .chat-item-del { opacity: 1; }
.chat-item-del:hover { color: var(--danger); }

/* Профиль внизу сайдбара */
.sidebar-profile {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.profile-avatar {
    width: 36px;
    height: 36px;
    background: var(--surface);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.profile-info {
    flex: 1;
    min-width: 0;
}

.profile-name {
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-email {
    font-size: .7rem;
    color: var(--text3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-logout {
    background: none;
    border: none;
    color: var(--text3);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: .15s;
}

.profile-logout:hover { color: var(--danger); background: rgba(255,92,92,.1); }

/* Основная область чата */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg);
    background-image: radial-gradient(ellipse at 50% 0%, rgba(124,92,252,.04) 0%, transparent 50%);
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    backdrop-filter: blur(8px);
    background: rgba(15,15,26,.8);
}

.chat-header-title {
    font-size: .95rem;
    font-weight: 700;
    flex: 1;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text2);
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
}

/* Сообщения */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.messages::-webkit-scrollbar { width: 5px; }
.messages::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 5px; }

/* Приветствие */
.welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary), #9d7dff);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    margin-bottom: 20px;
    box-shadow: 0 12px 32px rgba(124,92,252,.25);
}

.welcome h2 {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.welcome p {
    color: var(--text2);
    font-size: .9rem;
    max-width: 400px;
    line-height: 1.6;
}

.welcome-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
    justify-content: center;
    max-width: 500px;
}

.welcome-chip {
    padding: 10px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text2);
    font-size: .82rem;
    font-family: inherit;
    cursor: pointer;
    transition: .2s;
}

.welcome-chip:hover {
    background: var(--primary-glow);
    border-color: rgba(124,92,252,.3);
    color: var(--primary);
}

/* Сообщение */
.msg {
    display: flex;
    gap: 12px;
    max-width: 780px;
    width: 100%;
    margin: 0 auto;
    animation: msgIn .25s ease;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg-user { flex-direction: row-reverse; }

.msg-avatar {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    margin-top: 2px;
}

.msg-ai .msg-avatar { background: linear-gradient(135deg, var(--primary), #9d7dff); }
.msg-user .msg-avatar { background: var(--surface); }

.msg-body { flex: 1; min-width: 0; }

.msg-name {
    font-size: .72rem;
    font-weight: 600;
    color: var(--text3);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.msg-user .msg-name { text-align: right; }

.msg-bubble {
    padding: 14px 18px;
    border-radius: 16px;
    font-size: .88rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.msg-ai .msg-bubble {
    background: var(--ai-bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-top-left-radius: 4px;
}

.msg-user .msg-bubble {
    background: var(--user-bg);
    color: #fff;
    border-top-right-radius: 4px;
    border: none;
}

/* Typing dots */
.typing-dots {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text3);
    animation: dotBounce .6s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: .1s; }
.typing-dots span:nth-child(3) { animation-delay: .2s; }

@keyframes dotBounce {
    0%, 100% { transform: translateY(0); opacity: .4; }
    50% { transform: translateY(-5px); opacity: 1; }
}

/* Input area */
.input-area {
    padding: 16px 20px 20px;
    border-top: 1px solid var(--border);
    background: rgba(15,15,26,.6);
    backdrop-filter: blur(8px);
}

.input-wrap {
    max-width: 780px;
    margin: 0 auto;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.input-box {
    flex: 1;
    position: relative;
}

.input-box textarea {
    width: 100%;
    padding: 14px 18px;
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 14px;
    color: var(--text);
    font-size: .9rem;
    font-family: inherit;
    outline: none;
    resize: none;
    max-height: 120px;
    line-height: 1.5;
    transition: border-color .2s;
}

.input-box textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.input-box textarea::placeholder { color: var(--text3); }

.send-btn {
    width: 48px;
    height: 48px;
    background: var(--user-bg);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform .1s, box-shadow .2s;
}

.send-btn:hover { box-shadow: 0 4px 16px rgba(124,92,252,.35); }
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { opacity: .4; cursor: not-allowed; }

.send-btn svg { width: 20px; height: 20px; fill: #fff; }

.input-hint {
    font-size: .7rem;
    color: var(--text3);
    text-align: center;
    margin-top: 8px;
}

/* === MOBILE === */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -300px;
        top: 0;
        bottom: 0;
        z-index: 200;
        transition: left .25s ease;
        box-shadow: 4px 0 20px rgba(0,0,0,.5);
    }

    .sidebar.open { left: 0; }

    .menu-toggle { display: block; }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.5);
        z-index: 199;
    }

    .sidebar-overlay.show { display: block; }

    .msg { max-width: 100%; }
    .input-wrap { max-width: 100%; }
}

.provider-badge{font-size:.7rem;color:var(--text2);border:1px solid var(--border);border-radius:999px;padding:5px 9px;white-space:nowrap}.provider-badge[data-state="ready"]{color:#9be6b2;border-color:#31533f}.provider-badge[data-state="error"]{color:#ffb6b6;border-color:#654044}
@media(max-width:600px){.provider-badge{font-size:.62rem;padding:4px 7px;max-width:130px;overflow:hidden;text-overflow:ellipsis}}
