/* ==========================================================================
   Yuri — base stylesheet
   --------------------------------------------------------------------------
   This file is plain, open CSS. Nothing here is compiled or obfuscated.
   Edit it directly, or leave it alone and put your own overrides in
   css/custom.css (loaded after this file, so anything you write there wins).

   Everything visual is driven by the CSS variables in :root below. Changing
   a variable is almost always enough — you shouldn't need to touch the
   selectors beneath it unless you want structural changes.
   ========================================================================== */

:root {
    /* --- palette --- */
    --bg-void: #0b0b10;
    --bg-base: #121218;
    --bg-raised: #191922;
    --bg-hover: #22222e;
    --bg-input: #1b1b26;

    --border-soft: #26262f;
    --border-strong: #35353f;

    --text-primary: #ece9f5;
    --text-secondary: #a6a3b8;
    --text-faint: #6f6c80;

    --accent: #8b6bff;
    --accent-hover: #9d80ff;
    --accent-dim: #5a4b99;
    --accent-text: #ffffff;

    --danger: #ff6b6b;
    --success: #6bffb3;

    --user-bubble: #8b6bff;
    --user-bubble-text: #ffffff;
    --bot-bubble: #191922;
    --bot-bubble-text: #ece9f5;

    /* --- type --- */
    --font-ui: "Inter", "Segoe UI", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", "Fira Code", monospace;

    /* --- layout --- */
    --sidebar-width: 280px;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* Light mode overrides toggled via body.theme-light */
body.theme-light {
    --bg-void: #eceef4;
    --bg-base: #f5f6fa;
    --bg-raised: #ffffff;
    --bg-hover: #e8e9f2;
    --bg-input: #ffffff;

    --border-soft: #dcdde6;
    --border-strong: #c7c8d6;

    --text-primary: #17171f;
    --text-secondary: #52505f;
    --text-faint: #8a879a;

    --bot-bubble: #ffffff;
    --bot-bubble-text: #17171f;
    --user-bubble: #6f4bff;
    --user-bubble-text: #ffffff;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg-void);
    color: var(--text-primary);
    font-family: var(--font-ui);
    -webkit-font-smoothing: antialiased;
}

button {
    font-family: inherit;
    cursor: pointer;
}

img.icon {
    width: 20px;
    height: 20px;
    display: block;
}

.hidden { display: none !important; }

/* ==========================================================================
   Auth screens (signup / login / verify)
   ========================================================================== */

.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 20% 20%, rgba(139, 107, 255, 0.12), transparent 45%),
        radial-gradient(circle at 80% 80%, rgba(139, 107, 255, 0.08), transparent 40%),
        var(--bg-void);
}

.auth-card {
    width: 380px;
    max-width: 92vw;
    background: var(--bg-raised);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    box-shadow: var(--shadow-soft);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.auth-brand img { width: 32px; height: 32px; }

.auth-brand h1 {
    font-size: 22px;
    margin: 0;
    letter-spacing: 0.3px;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 13.5px;
    margin: 0 0 24px 0;
}

.field {
    margin-bottom: 14px;
}

.field label {
    display: block;
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.field input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease;
}

.field input:focus {
    border-color: var(--accent);
}

.field-password-wrap {
    position: relative;
}

.field-password-wrap img {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.6;
}
.field-password-wrap img:hover { opacity: 1; }

.btn-primary {
    width: 100%;
    padding: 11px;
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14.5px;
    font-weight: 600;
    margin-top: 6px;
    transition: background 0.15s ease;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

.auth-switch {
    text-align: center;
    margin-top: 18px;
    font-size: 13px;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--accent);
    cursor: pointer;
    text-decoration: none;
}
.auth-switch a:hover { text-decoration: underline; }

.form-error {
    background: rgba(255, 107, 107, 0.12);
    border: 1px solid rgba(255, 107, 107, 0.3);
    color: var(--danger);
    font-size: 13px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
}

.form-notice {
    background: rgba(107, 255, 179, 0.1);
    border: 1px solid rgba(107, 255, 179, 0.28);
    color: var(--success);
    font-size: 13px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
}

.code-input {
    letter-spacing: 8px;
    text-align: center;
    font-size: 22px !important;
    font-family: var(--font-mono);
}

/* ==========================================================================
   Main app shell
   ========================================================================== */

.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* --- sidebar --- */

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--bg-base);
    border-right: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    transition: margin-left 0.2s ease;
}

.sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-soft);
}

.brand-mini {
    display: flex;
    align-items: center;
    gap: 8px;
}
.brand-mini img { width: 24px; height: 24px; }
.brand-mini span { font-weight: 600; font-size: 15px; }

.icon-btn {
    background: transparent;
    border: none;
    padding: 7px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-btn:hover { background: var(--bg-hover); }

.new-chat-btn {
    margin: 14px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    background: var(--bg-raised);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13.5px;
    font-weight: 500;
}
.new-chat-btn:hover { border-color: var(--accent); }

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 10px;
}

.chat-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: var(--text-secondary);
    cursor: pointer;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-list-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.chat-list-item.active { background: var(--bg-hover); color: var(--text-primary); }

.chat-list-item .title { overflow: hidden; text-overflow: ellipsis; }

.chat-list-item .delete-btn {
    opacity: 0;
    flex-shrink: 0;
}
.chat-list-item:hover .delete-btn { opacity: 0.7; }
.chat-list-item .delete-btn:hover { opacity: 1; }
.chat-list-item .delete-btn img { width: 15px; height: 15px; }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
}
.user-chip img { width: 22px; height: 22px; flex-shrink: 0; }
.user-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.footer-actions { display: flex; gap: 4px; }

/* --- main chat column --- */

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-base);
}

.chat-topbar {
    height: 56px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    border-bottom: 1px solid var(--border-soft);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.model-badge {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}
.model-badge .name {
    font-size: 14.5px;
    font-weight: 600;
}
.model-badge .full-name {
    font-size: 11px;
    color: var(--text-faint);
    font-family: var(--font-mono);
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0 12px 0;
}

.messages-inner {
    max-width: 780px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-faint);
    text-align: center;
    gap: 10px;
}
.empty-state img { width: 56px; height: 56px; opacity: 0.6; }

.msg-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.msg-row.user { flex-direction: row-reverse; }

.msg-avatar { width: 28px; height: 28px; flex-shrink: 0; margin-top: 4px; }

.msg-bubble {
    max-width: 78%;
    padding: 11px 14px;
    border-radius: var(--radius-md);
    font-size: 14.5px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.msg-row.user .msg-bubble {
    background: var(--user-bubble);
    color: var(--user-bubble-text);
    border-bottom-right-radius: 4px;
}

.msg-row.bot .msg-bubble {
    background: var(--bot-bubble);
    color: var(--bot-bubble-text);
    border: 1px solid var(--border-soft);
    border-bottom-left-radius: 4px;
}

.msg-bubble pre {
    background: rgba(0,0,0,0.3);
    padding: 10px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 13px;
}

.msg-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.attachment-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-soft);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    text-decoration: none;
    color: inherit;
}
.attachment-chip img { width: 14px; height: 14px; }

.attachment-chip.editfile {
    background: rgba(107, 255, 179, 0.1);
    border-color: rgba(107, 255, 179, 0.3);
}

.msg-image-preview, .msg-video-preview {
    max-width: 260px;
    border-radius: var(--radius-sm);
    margin-top: 8px;
    display: block;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}
.typing-indicator span {
    width: 6px; height: 6px;
    background: var(--text-faint);
    border-radius: 50%;
    animation: bounce 1.2s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-4px); opacity: 1; }
}

/* --- composer --- */

.composer-wrap {
    padding: 14px 24px 20px 24px;
    flex-shrink: 0;
}

.composer {
    max-width: 780px;
    margin: 0 auto;
    background: var(--bg-input);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 8px 8px 8px 14px;
    display: flex;
    flex-direction: column;
    transition: border-color 0.15s ease;
}
.composer:focus-within { border-color: var(--accent); }

.composer-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 0;
}

.composer-attachments .attachment-chip button {
    background: none; border: none; color: inherit; opacity: 0.7; padding: 0 0 0 4px;
}

.composer-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.composer textarea {
    flex: 1;
    resize: none;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 14.5px;
    line-height: 1.5;
    max-height: 180px;
    padding: 8px 0;
}
.composer textarea::placeholder { color: var(--text-faint); }

.composer-send-btn {
    background: var(--accent);
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.composer-send-btn img { width: 16px; height: 16px; }
.composer-send-btn:hover { background: var(--accent-hover); }
.composer-send-btn:disabled { opacity: 0.4; cursor: default; }

.composer-hint {
    text-align: center;
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 8px;
}

/* ==========================================================================
   Settings modal
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    width: 460px;
    max-width: 92vw;
    max-height: 84vh;
    overflow-y: auto;
    background: var(--bg-raised);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-soft);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}
.modal-header h2 { margin: 0; font-size: 17px; }

.settings-section {
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border-soft);
}
.settings-section:last-child { border-bottom: none; }

.settings-section h3 {
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-faint);
    margin: 0 0 12px 0;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 14px;
}

.settings-row-desc {
    font-size: 12px;
    color: var(--text-faint);
    margin-top: 2px;
}

.toggle {
    position: relative;
    width: 40px;
    height: 22px;
    background: var(--border-strong);
    border-radius: 11px;
    border: none;
    flex-shrink: 0;
}
.toggle.on { background: var(--accent); }
.toggle::after {
    content: "";
    position: absolute;
    top: 2px; left: 2px;
    width: 18px; height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform 0.15s ease;
}
.toggle.on::after { transform: translateX(18px); }

.theme-choice-row {
    display: flex;
    gap: 8px;
}
.theme-choice {
    flex: 1;
    padding: 10px;
    text-align: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-soft);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 13px;
}
.theme-choice.active {
    border-color: var(--accent);
    color: var(--text-primary);
}

.file-upload-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.small-btn {
    padding: 7px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 12.5px;
}
.small-btn:hover { border-color: var(--accent); }

.small-btn.danger { color: var(--danger); border-color: rgba(255,107,107,0.3); }
.small-btn.danger:hover { background: rgba(255,107,107,0.1); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 720px) {
    .sidebar { position: fixed; z-index: 50; height: 100%; }
    .sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-width)); }
}
