/* AISPIRE Reflection Analyst */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --navy: #13132b;
    --navy-mid: #1e1e42;
    --purple: #8b7ec8;
    --purple-soft: rgba(139, 126, 200, 0.12);
    --purple-border: rgba(139, 126, 200, 0.2);
    --magenta: #c44dff;
    --cyan: #4dc8ff;
    --gradient: linear-gradient(135deg, #c44dff 0%, #8b7ec8 40%, #4dc8ff 80%, #33e6ff 100%);
    --gradient-soft: linear-gradient(135deg, rgba(196,77,255,0.08), rgba(77,200,255,0.06));

    --bg: #0f0f23;
    --surface: #181833;
    --surface-2: #1e1e42;
    --text: #e4e4ef;
    --text-2: #a0a0b8;
    --text-3: #6a6a82;
    --border: rgba(255, 255, 255, 0.06);
    --border-strong: rgba(255, 255, 255, 0.1);

    --error: #e04060;
    --r: 10px;
    --r-lg: 16px;
    --r-xl: 20px;
}

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

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

/* ─── Nav ─── */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    height: 72px;
    background: transparent;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-decoration: none;
}
.nav-brand img { height: 28px; }
.nav-brand span {
    color: rgba(255,255,255,0.5);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 0.125rem;
}
.nav-links a {
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    transition: all 0.15s;
}
.nav-links a:hover { color: #fff; background: rgba(255,255,255,0.07); }
.nav-links a.active { color: #fff; background: rgba(255,255,255,0.1); }
.nav-user {
    color: rgba(255,255,255,0.35);
    font-size: 0.75rem;
    padding: 0 0.4rem;
}
.nav-divider {
    width: 1px;
    height: 16px;
    background: rgba(255,255,255,0.1);
    margin: 0 0.25rem;
}
.btn-logout {
    color: rgba(255,255,255,0.35) !important;
    font-size: 0.75rem !important;
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.15s;
}
.btn:hover { border-color: var(--purple-border); background: var(--purple-soft); }
.btn-send {
    background: var(--gradient);
    color: white;
    border: none;
    padding: 0 1.1rem;
    border-radius: var(--r);
    font-weight: 600;
    font-size: 0.8rem;
    height: 44px;
    min-width: 56px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(196, 77, 255, 0.2);
}
.btn-send:hover {
    box-shadow: 0 4px 16px rgba(196, 77, 255, 0.35);
    transform: translateY(-1px);
}
.btn-send svg { width: 18px; height: 18px; }
.btn-gradient {
    display: inline-block;
    background: var(--gradient);
    color: white;
    border: none;
    font-weight: 600;
    padding: 0.65rem 2rem;
    border-radius: var(--r);
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    transition: all 0.2s;
}
.btn-gradient:hover {
    box-shadow: 0 6px 24px rgba(196,77,255,0.35);
    transform: translateY(-1px);
    filter: brightness(1.1);
}

/* ─── Login ─── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 72px);
    background: var(--bg);
    background-image: radial-gradient(ellipse at 30% 0%, rgba(196,77,255,0.06) 0%, transparent 60%),
                      radial-gradient(ellipse at 70% 100%, rgba(77,200,255,0.04) 0%, transparent 60%);
}
.login-card {
    max-width: 380px;
    width: 100%;
    margin: 0 1rem;
    padding: 3rem 2.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
}
.login-card img { height: 36px; margin-bottom: 1.5rem; }
.login-card h1 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.4rem;
}
.login-card p {
    color: var(--text-3);
    font-size: 0.85rem;
    margin-bottom: 2rem;
}

/* ─── Denied ─── */
.denied-card {
    max-width: 380px;
    margin: 5rem auto;
    padding: 2.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    text-align: center;
}
.denied-card h1 { font-size: 1.1rem; color: var(--error); margin-bottom: 0.5rem; }
.denied-card p { color: var(--text-3); font-size: 0.85rem; margin-bottom: 1.5rem; }

/* ─── Chat Layout ─── */
.chat-page {
    display: flex;
    height: calc(100vh - 72px);
    overflow: hidden;

}

.sidebar {
    width: 140px;
    flex-shrink: 0;
    background: transparent;
    padding: 1.25rem 0.75rem;
    overflow-y: auto;
}
.sidebar-title {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-3);
    margin-bottom: 0.6rem;
    padding: 0 0.5rem;
}
.tab-option {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.4rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s;
    color: var(--text-3);
}
.tab-option:hover {
    background: var(--purple-soft);
    color: var(--text-2);
}
.tab-option input[type="checkbox"] {
    accent-color: var(--text-3);
    width: 14px;
    height: 14px;
    opacity: 0.6;
}
.tab-option input[type="checkbox"]:checked {
    accent-color: var(--purple);
    opacity: 1;
}

/* Chat center */
.chat-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 0;
}
.chat-scroll-inner {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.welcome-msg {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 4rem 2rem;
}
.welcome-msg img { height: 36px; margin-bottom: 1rem; opacity: 0.6; }
.welcome-subtitle {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-2);
    margin-bottom: 0.25rem;
}
.welcome-msg p {
    color: var(--text-3);
    font-size: 0.85rem;
    max-width: 380px;
    line-height: 1.65;
}

/* Composer */
.composer {
    padding: 0.75rem 1.5rem 1.25rem;
    display: flex;
    justify-content: center;
}
.composer-inner {
    max-width: 720px;
    width: 100%;
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}
.composer-input {
    flex: 1;
    padding: 0.7rem 1rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--r);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text);
    background: var(--surface-2);
    height: 44px;
    transition: border-color 0.15s, box-shadow 0.2s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.composer-input:focus {
    outline: none;
    border-color: var(--purple);
    box-shadow: 0 0 0 3px var(--purple-soft), 0 1px 4px rgba(0,0,0,0.2);
}
.composer-input::placeholder { color: var(--text-3); }

/* Loading */
.htmx-indicator {
    display: none;
    padding: 0 1.5rem 0.75rem;
}
.htmx-indicator-inner {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--purple);
    font-size: 0.82rem;
    font-weight: 500;
}
.htmx-indicator-inner::before {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid var(--purple-border);
    border-top-color: var(--purple);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: block; }

/* ─── Messages ─── */
.chat-block {
    margin-bottom: 2rem;
}
.chat-block + .chat-block {
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.chat-question {
    margin-bottom: 1rem;
}
.question-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: #fff;
    line-height: 1.55;
}

.chat-answer {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}
.answer-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    background: var(--gradient);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}
.answer-icon svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: white;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.answer-body {
    flex: 1;
    min-width: 0;
}
.answer-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.25rem 1.5rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}
.answer-text {
    font-size: 0.9rem;
    line-height: 1.75;
    color: var(--text);
}
.answer-text p { margin: 0.5em 0; }
.answer-text p:first-child { margin-top: 0; }
.answer-text p:last-child { margin-bottom: 0; }
.answer-text ul, .answer-text ol { margin: 0.5em 0; padding-left: 1.4em; }
.answer-text li { margin: 0.25em 0; }
.answer-text li::marker { color: var(--text-3); }
.answer-text h2 {
    font-size: 0.92rem;
    font-weight: 600;
    color: #fff;
    margin: 1.2em 0 0.4em;
}
.answer-text h3 {
    font-size: 0.88rem;
    font-weight: 600;
    color: #fff;
    margin: 1em 0 0.3em;
}
.answer-text strong { font-weight: 600; color: #fff; }
.answer-text code {
    background: var(--purple-soft);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-size: 0.82em;
    font-family: 'SF Mono', Monaco, monospace;
}

.answer-evidence {
    margin-top: 1rem;
    padding: 0.55rem 0.75rem;
    background: var(--gradient-soft);
    border-radius: 8px;
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    font-size: 0.75rem;
    color: var(--text-3);
}
.evidence-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.evidence-label { font-weight: 500; color: var(--text-2); }

/* Error */
.chat-error { margin-bottom: 1.5rem; }
.error-text {
    background: rgba(224,64,96,0.1);
    border: 1px solid rgba(224,64,96,0.2);
    color: var(--error);
    padding: 0.7rem 1rem;
    border-radius: var(--r);
    font-size: 0.85rem;
}

/* ─── Admin ─── */
.admin-layout {
    max-width: 1100px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
}
.admin-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    overflow: hidden;
}
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.admin-header h1 { font-size: 1rem; font-weight: 600; }
.admin-controls {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.admin-controls input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--r);
    font-family: inherit;
    font-size: 0.82rem;
    min-width: 200px;
    background: var(--surface-2);
    color: var(--text);
    transition: border-color 0.15s;
}
.admin-controls input:focus { outline: none; border-color: var(--purple); }

.log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.log-table th {
    text-align: left;
    padding: 0.65rem 1rem;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-3);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.log-table td {
    text-align: left;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    color: var(--text-2);
    line-height: 1.5;
}
.log-table tr:last-child td { border-bottom: none; }
.log-table tr:hover td { background: rgba(139,126,200,0.06); }

.muted { color: var(--text-3); }

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .chat-page { flex-direction: column; }
    .sidebar {
        width: 100%;
        max-height: 100px;
        padding: 0.75rem 1rem;
        display: flex;
        gap: 0.5rem;
        align-items: center;
    }
    .sidebar-title { margin-bottom: 0; margin-right: 0.5rem; }
    .chat-scroll-inner { padding: 0 1rem; }
    .composer { padding: 0.75rem 1rem 1rem; }
    .navbar { padding: 0 0.75rem; }
}
