/* ─── Fonts ─────────────────────────────────────────── */
/* Imported in index.html */

/* ─── Variables (Premium Midnight & Gold) ────────── */
:root {
    --navy: #0a1128;            /* Deep Midnight */
    --navy-mid: #1c2541;        /* Navy Slate */
    --navy-light: #3a506b;      /* Slate Blue */
    --accent: #ffbc0a;          /* Chrome Gold */
    --accent-hover: #e0a300;
    --accent-pale: rgba(255, 188, 10, .12);
    --white: #ffffff;
    --off-white: #f0f2f5;
    --border: rgba(255, 255, 255, .1); /* Glass border */
    --border-light: #e1e4e8;
    --text: #0b132b;
    --text-muted: #5c677d;
    --bubble-user: linear-gradient(135deg, #0a1128, #1c2541);
    --bubble-bot: rgba(255, 255, 255, .8);
    --success: #00af54;
    --radius: 16px;
    --glass: rgba(255, 255, 255, .03);
    --shadow: 0 8px 32px rgba(0, 0, 0, .08);
    --shadow-lg: 0 12px 48px rgba(0, 0, 0, .15);
}

/* ─── Reset ─────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    background: var(--off-white);
    color: var(--text);
    overscroll-behavior: none;
    zoom: 1;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* ─── Layout ─────────────────────────────────────────── */
.app {
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: 100vh;
    height: 100vh;
    overflow: hidden;
}

/* ─── Sidebar (Glassmorphic) ─────────────────────────── */
.sidebar {
    background: var(--navy);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    position: relative;
    border-right: 1px solid var(--border);
    backdrop-filter: blur(10px);
}

.sidebar::before {
    content: '';
    position: absolute;
    top: -80px;
    right: -80px;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(232, 160, 32, .18) 0%, transparent 70%);
    pointer-events: none;
}

.sidebar-logo {
    padding: 28px 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-logo .brand {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 20px;
    color: var(--white);
    line-height: 1.1;
    letter-spacing: -.5px;
}

.sidebar-logo .brand span {
    color: var(--accent);
}

.sidebar-logo .tagline {
    font-size: 11px;
    color: rgba(255, 255, 255, .45);
    margin-top: 4px;
    letter-spacing: .5px;
    text-transform: uppercase;
}

/* Progress tracker */
.progress-section {
    padding: 24px 20px 0;
    flex: 1;
    overflow-y: auto;
}

.progress-section::-webkit-scrollbar {
    width: 4px;
}

.progress-section::-webkit-scrollbar-track {
    background: transparent;
}

.progress-section::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .15);
    border-radius: 2px;
}

.progress-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .35);
    margin-bottom: 16px;
}

.part-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.part-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 8px;
    cursor: default;
    transition: background .15s;
}

.part-item.active {
    background: rgba(255, 255, 255, .1);
}

.part-item.done {
    opacity: .7;
}

.part-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 600;
    color: rgba(255, 255, 255, .4);
    transition: all .2s;
}

.part-item.active .part-dot {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--navy);
}

.part-item.done .part-dot {
    border-color: var(--success);
    background: var(--success);
    color: white;
}

.part-item.done .part-dot::before {
    content: '✓';
    font-size: 11px;
}

.part-label {
    font-size: 12.5px;
    font-weight: 500;
    color: rgba(255, 255, 255, .55);
    line-height: 1.3;
}

.part-item.active .part-label {
    color: var(--white);
    font-weight: 600;
}

.part-item.done .part-label {
    color: rgba(255, 255, 255, .4);
}

/* Claim ref badge (Pulsing Claim Card) */
.claim-ref-box {
    margin: 20px;
    padding: 16px;
    background: rgba(255, 188, 10, .1);
    border: 1px solid rgba(255, 188, 10, .2);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    animation: glowPulse 3s infinite ease-in-out;
}

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 188, 10, .2); }
    50% { box-shadow: 0 0 20px rgba(255, 188, 10, .4); }
}

.claim-ref-box .label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .5);
    margin-bottom: 6px;
}

.claim-ref-box .ref {
    font-family: 'Outfit', sans-serif;
    font-size: 19px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: .8px;
}

.claim-ref-box.hidden {
    display: none;
}

/* ─── Main chat area ─────────────────────────────────── */
.chat-area {
    display: flex;
    flex-direction: column;
    background: var(--off-white);
    position: relative;
    overflow: hidden;
}

/* Top bar */
.chat-topbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.topbar-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 20px;
    color: var(--navy);
}

.topbar-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
}

.topbar-status {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 500;
    color: var(--success);
}

.topbar-status .dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: .5;
        transform: scale(1.3);
    }
}

/* Messages */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 32px 36px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

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

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

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

/* Message bubbles */
.msg {
    display: flex;
    gap: 16px;
    max-width: 80%;
    animation: fadeUp .25s ease both;
    min-width: 0;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg.bot {
    align-self: flex-start;
    margin-left: 0;
}

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

.msg-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--navy);
    border: 2px solid rgba(255,255,255,.15);
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 4px;
}

.msg.user .msg-avatar {
    background: linear-gradient(135deg, var(--accent), #e0a300);
    border: none;
}

.msg-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.msg-bubble {
    padding: 16px 20px;
    border-radius: var(--radius);
    font-size: 14.5px;
    line-height: 1.65;
    box-shadow: 0 2px 12px rgba(0,0,0,.07);
    transition: box-shadow .2s ease, transform .2s ease;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.msg-bubble:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,.11);
    transform: translateY(-1px);
}

.msg.bot .msg-bubble {
    background: #ffffff;
    border: 1px solid #e5e9f0;
    border-top-left-radius: 4px;
    color: var(--text);
}

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

/* Markdown-like formatting inside bubbles */
.msg-bubble strong {
    font-weight: 600;
}

.msg-bubble em {
    font-style: italic;
}

.msg-bubble p {
    margin-bottom: 8px;
}

.msg-bubble p:last-child {
    margin-bottom: 0;
}

.msg-bubble ul,
.msg-bubble ol {
    padding-left: 22px;
    margin: 8px 0 4px;
}

.msg-bubble li {
    margin-bottom: 6px;
    line-height: 1.55;
}

.msg-bubble code {
    background: rgba(0, 0, 0, .07);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
}

/* Bot name + time */
.msg-meta {
    font-size: 11px;
    color: var(--text-muted);
    padding: 0 4px;
}

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

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 12px;
    align-self: flex-start;
    animation: fadeUp .2s ease both;
}

.typing-indicator .msg-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--navy-mid);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.typing-dots {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    border-top-left-radius: 4px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: var(--shadow);
}

.typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: bounce 1.2s infinite;
}

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

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

@keyframes bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: .4;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Claim reference toast */
.ref-toast {
    align-self: center;
    background: linear-gradient(135deg, #e8f5ee, #f0faf5);
    border: 1px solid #a8dfc0;
    border-radius: 10px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--success);
    font-weight: 500;
    animation: fadeUp .3s ease both;
}

.ref-toast .icon {
    font-size: 18px;
}

/* Part complete badge */
.part-badge {
    align-self: center;
    background: var(--accent-pale);
    border: 1px solid rgba(232, 160, 32, .3);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 11.5px;
    font-weight: 600;
    color: #a06010;
    letter-spacing: .3px;
    animation: fadeUp .3s ease both;
}

/* ─── Input area ─────────────────────────────────────── */
.input-area {
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 16px 28px;
    flex-shrink: 0;
}

.input-wrap {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: var(--off-white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    transition: border-color .2s, box-shadow .2s;
}

.input-wrap:focus-within {
    border-color: var(--navy-light);
    box-shadow: 0 0 0 3px rgba(36, 84, 154, .12);
}

#message-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    color: var(--text);
    resize: none;
    max-height: 120px;
    outline: none;
    line-height: 1.5;
}

#message-input::placeholder {
    color: var(--text-muted);
}

#send-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: var(--navy);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s, transform .1s;
    font-size: 16px;
}

#send-btn:hover {
    background: var(--navy-light);
}

#send-btn:active {
    transform: scale(.93);
}

#send-btn:disabled {
    background: var(--border);
    cursor: not-allowed;
}

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

/* ─── Completion screen ──────────────────────────────── */
.complete-screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 40px;
    text-align: center;
    gap: 16px;
    animation: fadeUp .4s ease both;
}

.complete-screen.show {
    display: flex;
}

.complete-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e9e6b, #13784f);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    box-shadow: 0 8px 32px rgba(30, 158, 107, .3);
}

.complete-screen h2 {
    font-family: 'DM Serif Display', serif;
    font-size: 28px;
    color: var(--navy);
}

.complete-screen p {
    font-size: 15px;
    color: var(--text-muted);
    max-width: 380px;
    line-height: 1.6;
}

.complete-ref {
    font-family: 'DM Serif Display', serif;
    font-size: 22px;
    color: var(--accent);
    background: var(--accent-pale);
    padding: 10px 24px;
    border-radius: 10px;
    border: 1px solid rgba(232, 160, 32, .3);
}

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 768px) {
    .app {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .sidebar {
        display: none;
    }
}

/* ─── Error card ─────────────────────────────────────────── */
.error-card {
    align-self: center;
    background: #fff5f5;
    border: 1px solid #f5a5a5;
    border-radius: 10px;
    padding: 16px 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 480px;
    animation: fadeUp .3s ease both;
}

.error-icon {
    font-size: 22px;
    flex-shrink: 0;
}

.error-title {
    font-weight: 600;
    color: #b91c1c;
    font-size: 14px;
    margin-bottom: 4px;
}

.error-msg {
    font-size: 13px;
    color: #7f1d1d;
}

.error-hint {
    font-size: 12px;
    color: #9a3412;
    margin-top: 4px;
}