﻿@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* ── CSS Variables ── */
:root {
    --bg-primary: #212121;
    --bg-secondary: #2f2f2f;
    --bg-input: #2f2f2f;
    --bg-sidebar: #171717;
    --text-primary: #ececec;
    --text-secondary: #a0a0a0;
    --accent: #ff6b35;
    --accent-hover: #e55a24;
    --user-bubble: #2f6feb;
    --border-color: #3a3a3a;
    --shadow: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
    --bg-primary: #f9f9f9;
    --bg-secondary: #ffffff;
    --bg-input: #ffffff;
    --bg-sidebar: #efefef;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --accent: #ff6b35;
    --accent-hover: #e55a24;
    --user-bubble: #2f6feb;
    --border-color: #e0e0e0;
    --shadow: rgba(0, 0, 0, 0.08);
}

/* ── Reset & Base ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ── Sidebar ── */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar-logo {
    font-size: 1.4rem;
    font-weight: 600;
    padding: 10px 12px 24px;
    background: linear-gradient(to right, #405de6, #833ab4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar nav ul li a {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.sidebar nav ul li a:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

/* ── Main Chat Area ── */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* ── Header ── */
.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ── Message Container ── */
#message-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

#message-container::-webkit-scrollbar { width: 6px; }
#message-container::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 3px;
}

/* ── Messages ── */
.message {
    display: flex;
    max-width: 720px;
    width: 100%;
    line-height: 1.6;
    font-size: 0.95rem;
}

.user-message {
    align-self: flex-end;
    background-color: var(--user-bubble);
    color: #ffffff;
    padding: 12px 16px;
    border-radius: 18px 18px 4px 18px;
    max-width: 60%;
}

.assistant-message {
    align-self: flex-start;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 18px 18px 18px 4px;
    max-width: 80%;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 4px var(--shadow);
}

/* ── Input Area ── */
.input-container {
    padding: 16px 24px 24px;
    background-color: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 10px 16px;
    gap: 10px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    max-width: 720px;
    margin: 0 auto;
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.15);
}

.input-wrapper input[type="text"] {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
}

.input-wrapper input[type="text"]::placeholder { color: var(--text-secondary); }

.input-wrapper input[type="submit"] {
    background-color: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.2s ease, transform 0.1s ease;
    white-space: nowrap;
}

.input-wrapper input[type="submit"]:hover {
    background-color: var(--accent-hover);
    transform: scale(1.03);
}

/* ── Terms ── */
.terms-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 12px auto 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    max-width: 720px;
}

#terms-button {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: border-color 0.2s ease, color 0.2s ease;
}

#terms-button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Modal ── */
.modal {
    position: fixed;
    z-index: 9999;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--bg-secondary);
    width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 28px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px var(--shadow);
    color: var(--text-primary);
}

.close-button {
    float: right;
    cursor: pointer;
    font-size: 22px;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.close-button:hover { color: var(--accent); }

p {
    margin-bottom: 10px;
    line-height: 1.6;
    color: var(--text-primary);
}

/* ── Theme Toggle ── */
#theme-toggle {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 1000;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: border-color 0.2s ease, color 0.2s ease;
}

#theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Hamburger (mobile) ── */
.hamburger {
    display: none;
    cursor: pointer;
    z-index: 9999;
    flex-direction: column;
    gap: 5px;
    flex-shrink: 0;
}

.hamburger-line {
    width: 22px;
    height: 2px;
    background-color: var(--text-secondary);
    border-radius: 2px;
    transition: background-color 0.2s ease;
}

/* ── Mobile Menu ── */
.mobile-menu {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    backdrop-filter: blur(4px);
}

.mobile-menu.active { display: flex; }

.mobile-menu-content {
    background-color: var(--bg-secondary);
    width: 220px;
    padding: 24px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.mobile-menu-content ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mobile-menu-content ul li a {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s ease;
}

.mobile-menu-content ul li a:hover { color: var(--accent); }

/* ── About Page ── */
.about-container {
    max-width: 720px;
    margin: 40px auto;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.about-container h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.about-container p {
    color: var(--text-secondary);
    line-height: 1.7;
}

/* ── Thinking Animation ── */
.thinking-message {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 18px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-secondary);
    animation: thinking 1.2s infinite ease-in-out;
}

.dot:nth-child(1) { animation-delay: 0s; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinking {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Responsive / Mobile ── */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .hamburger { display: flex; }
    .user-message { max-width: 85%; }
    .assistant-message { max-width: 95%; }

    .terms-container {
        flex-direction: column;
        align-items: center;
        gap: 8px;
        padding: 0 16px;
        font-size: 0.75rem;
    }

    .terms-container label { text-align: center; }

    #terms-button {
        width: 100%;
        max-width: 280px;
    }

    .input-container { padding: 12px 16px 16px; }

    .input-wrapper input[type="text"] { font-size: 0.85rem; }
}