/* ── Yasmin Chat Interface ─────────────────────────────────────────── */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a28;
    --bg-hover: #222235;
    --bg-input: #161622;
    --surface: #1e1e2e;
    --surface-hover: #2a2a3e;
    --border: #2a2a3d;
    --border-light: #3a3a50;
    --text-primary: #e8e8f0;
    --text-secondary: #9898b0;
    --text-muted: #6868808;
    --accent: #f0c040;
    --accent-dim: rgba(240, 192, 64, 0.12);
    --accent-glow: rgba(240, 192, 64, 0.25);
    --danger: #e05050;
    --danger-dim: rgba(224, 80, 80, 0.12);
    --user-bubble: #1a2a4a;
    --assistant-bubble: var(--bg-tertiary);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition: 200ms ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
}

/* ── Login Screen ─────────────────────────────────────────────────── */

.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(240, 192, 64, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(100, 100, 240, 0.03) 0%, transparent 50%);
}

.login-card {
    text-align: center;
    padding: 48px 40px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    width: 380px;
    animation: fadeIn 0.5s ease;
}

.login-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #e0a020);
    color: var(--bg-primary);
    font-size: 32px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 0 30px var(--accent-glow);
}

.login-card h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.login-card p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 28px;
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-card input {
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}

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

.login-card button {
    padding: 12px;
    background: linear-gradient(135deg, var(--accent), #e0a020);
    color: var(--bg-primary);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: opacity var(--transition), transform var(--transition);
}

.login-card button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.login-error {
    color: var(--danger);
    font-size: 13px;
    margin-top: 8px;
    min-height: 20px;
}

/* ── Chat App Layout ──────────────────────────────────────────────── */

.chat-app {
    display: flex;
    height: 100%;
}

.hidden {
    display: none !important;
}

/* ── Sidebar ──────────────────────────────────────────────────────── */

.sidebar {
    width: 260px;
    min-width: 260px;
    height: 100%;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #e0a020);
    color: var(--bg-primary);
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand h2 {
    font-size: 18px;
    font-weight: 700;
}

.brand-sub {
    font-size: 12px;
    color: var(--text-secondary);
}

.sidebar-nav {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition);
    width: 100%;
    text-align: left;
}

.nav-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-btn.active {
    background: var(--accent-dim);
    color: var(--accent);
}

.nav-btn.danger:hover {
    background: var(--danger-dim);
    color: var(--danger);
}

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

/* ── Main Content ─────────────────────────────────────────────────── */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

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

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #40c060;
    animation: pulse 2s infinite;
}

.status-text {
    font-size: 12px;
    color: var(--text-secondary);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

/* ── Views ────────────────────────────────────────────────────────── */

.view {
    display: none;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.view.active {
    display: flex;
}

/* ── Messages ─────────────────────────────────────────────────────── */

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
    scroll-behavior: smooth;
}

.messages::-webkit-scrollbar {
    width: 6px;
}

.messages::-webkit-scrollbar-track {
    background: transparent;
}

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

.welcome-message {
    text-align: center;
    padding: 60px 20px;
    animation: fadeIn 0.6s ease;
}

.welcome-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #e0a020);
    color: var(--bg-primary);
    font-size: 28px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    box-shadow: 0 0 40px var(--accent-glow);
}

.welcome-message h2 {
    font-size: 24px;
    margin-bottom: 8px;
}

.welcome-message p {
    color: var(--text-secondary);
    font-size: 15px;
    max-width: 440px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ── Message Bubble ───────────────────────────────────────────────── */

.message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: slideUp 0.3s ease;
    max-width: 85%;
}

.message.user {
    margin-left: auto;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
    margin-top: 2px;
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, var(--accent), #e0a020);
    color: var(--bg-primary);
}

.message.user .message-avatar {
    background: var(--user-bubble);
    color: var(--accent);
}

.message-content {
    padding: 12px 16px;
    border-radius: var(--radius);
    line-height: 1.6;
    font-size: 14px;
}

.message.assistant .message-content {
    background: var(--assistant-bubble);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.message.user .message-content {
    background: var(--user-bubble);
    border: 1px solid rgba(100, 140, 220, 0.2);
    border-bottom-right-radius: 4px;
}

/* Markdown inside messages */
.message-content p { margin-bottom: 8px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content ul, .message-content ol { padding-left: 20px; margin-bottom: 8px; }
.message-content li { margin-bottom: 4px; }
.message-content h1, .message-content h2, .message-content h3 {
    margin: 12px 0 6px;
    font-weight: 600;
}
.message-content h1 { font-size: 18px; }
.message-content h2 { font-size: 16px; }
.message-content h3 { font-size: 15px; }

.message-content code {
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.message-content pre {
    background: var(--bg-primary) !important;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    overflow-x: auto;
    margin: 8px 0;
    position: relative;
}

.message-content pre code {
    background: none;
    padding: 0;
    font-size: 13px;
    line-height: 1.5;
}

.message-content a {
    color: var(--accent);
    text-decoration: none;
}

.message-content a:hover {
    text-decoration: underline;
}

.message-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 12px;
    color: var(--text-secondary);
    margin: 8px 0;
}

.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
    font-size: 13px;
}

.message-content th, .message-content td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
}

.message-content th {
    background: var(--bg-hover);
    font-weight: 600;
}

/* ── Typing Indicator ─────────────────────────────────────────────── */

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

/* ── Input Area ───────────────────────────────────────────────────── */

.input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    transition: border-color var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.input-wrapper textarea {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    max-height: 150px;
    padding: 4px 0;
}

.input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.file-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition);
    flex-shrink: 0;
}

.file-upload-btn:hover {
    color: var(--accent);
    background: var(--accent-dim);
}

.send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent), #e0a020);
    border: none;
    cursor: pointer;
    color: var(--bg-primary);
    flex-shrink: 0;
    transition: all var(--transition);
}

.send-btn:hover {
    opacity: 0.85;
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.file-preview {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 8px;
}

.file-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--accent-dim);
    border-radius: 20px;
    font-size: 12px;
    color: var(--accent);
}

.file-tag .remove {
    cursor: pointer;
    opacity: 0.7;
}

.file-tag .remove:hover {
    opacity: 1;
}

/* ── Files View ───────────────────────────────────────────────────── */

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

.files-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.files-path {
    font-size: 13px;
    color: var(--text-secondary);
    font-family: 'SF Mono', monospace;
}

.files-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.files-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 60px 20px;
    font-size: 14px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.file-item:hover {
    background: var(--bg-hover);
}

.file-item svg {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.file-item .file-name {
    flex: 1;
    font-size: 14px;
}

.file-item .file-size {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ── Animations ───────────────────────────────────────────────────── */

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

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

@keyframes typing {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ── Responsive ───────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 100;
        transform: translateX(-100%);
        box-shadow: var(--shadow);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: block;
    }

    .message {
        max-width: 95%;
    }
}
