/* ─── Premium Design System ────────────────────────────────── */
:root {
    --bg-dark: #080b14;
    --bg-panel: #111827;
    --bg-glass: rgba(31, 41, 55, 0.7);
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.4);
    --secondary: #818cf8;
    --text-high: #f9fafb;
    --text-mid: #9ca3af;
    --text-low: #6b7280;
    --border: rgba(255, 255, 255, 0.06);
    --radius-lg: 16px;
    --radius-md: 12px;
    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --font-display: 'Plus Jakarta Sans', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-dark);
    color: var(--text-high);
    font-family: var(--font);
    height: 100vh;
    overflow: hidden;
}

/* ─── Layout ───────────────────────────────────────────────── */
.layout-container {
    display: flex;
    height: 100vh;
    transition: filter 0.3s ease;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at 50% 0%, #1e293b 0%, var(--bg-dark) 80%);
    position: relative;
    z-index: 10;
}

.split-view .chat-container {
    flex: 0 0 500px;
    border-right: 1px solid var(--border);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.3);
}

/* ─── Header ───────────────────────────────────────────────── */
.app-header {
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(8, 11, 20, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.logo-section h1 {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.logo-section h1 span {
    color: var(--primary);
}

.logo-section p {
    font-size: 0.65rem;
    color: var(--text-low);
    text-transform: uppercase;
    margin-top: 2px;
}

/* ─── Hero ─────────────────────────────────────────────────── */
.welcome-hero {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3rem;
    animation: fadeIn 0.8s ease;
}

.welcome-banner {
    width: 320px;
    height: 320px;
    object-fit: cover;
    border-radius: 50%;
    margin-bottom: 2rem;
    box-shadow: 0 0 60px rgba(99, 102, 241, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.05);
    animation: float 4s ease-in-out infinite, pulseGlow 8s infinite alternate;
}

@keyframes pulseGlow {
    0% {
        box-shadow: 0 0 40px rgba(99, 102, 241, 0.2);
    }

    100% {
        box-shadow: 0 0 80px rgba(99, 102, 241, 0.5);
    }
}

@keyframes float {
    0% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0);
    }
}

.welcome-hero h2 {
    font-family: var(--font-display);
    font-size: 2.25rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    text-align: center;
}

.welcome-hero p {
    color: var(--text-mid);
    max-width: 420px;
    line-height: 1.6;
    margin-bottom: 2.5rem;
    font-size: 1rem;
    text-align: center;
}

.upload-handle {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    padding: 1rem 2.5rem;
    border-radius: 100px;
    font-weight: 700;
    font-family: var(--font-display);
    box-shadow: 0 8px 30px var(--primary-glow);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.upload-handle:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 12px 40px var(--primary-glow);
}

/* ─── Messages ────────────────────────────────────────────── */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.messages-area::-webkit-scrollbar {
    width: 6px;
}

.messages-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.msg-wrapper {
    display: flex;
    animation: slideUp 0.4s ease-out;
    flex-direction: column;
}

.user-wrapper {
    align-items: flex-end;
}

.bot-wrapper {
    align-items: flex-start;
}

.msg-bubble {
    max-width: 85%;
    padding: 1.1rem 1.4rem;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.6;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.user-bubble {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-bubble {
    background: var(--bg-glass);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.msg-bubble p {
    margin-bottom: 0.75rem;
}

.msg-bubble p:last-child {
    margin-bottom: 0;
}

/* ─── Actions & TTS ───────────────────────────────────────── */
.msg-actions {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

.tts-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-mid);
    border: none;
    padding: 6px 12px;
    border-radius: 100px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: 0.2s;
    font-weight: 600;
}

.tts-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.tts-btn.pulsing {
    background: var(--primary);
    color: white;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 var(--primary-glow);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(99, 102, 241, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
    }
}

/* ─── Sources ─────────────────────────────────────────────── */
.reference-row {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.page-ref-chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 3px 10px;
    border-radius: 100px;
    color: var(--secondary);
    font-size: 0.72rem;
    font-weight: 600;
    transition: all 0.2s;
    cursor: pointer;
}

.page-ref-chip:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
    border-color: var(--primary);
}

/* ─── Input ────────────────────────────────────────────────── */
.input-area {
    padding: 1.5rem 2rem;
    background: rgba(8, 11, 20, 0.9);
    backdrop-filter: blur(15px);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
}

.input-area input {
    flex: 1;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 1.1rem 1.75rem;
    color: white;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.input-area input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.input-area input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-btn {
    background: var(--primary);
    color: white;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
}

.send-btn svg {
    width: 22px;
    height: 22px;
    margin-left: 2px;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 20px var(--primary-glow);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(100%);
}

/* ─── PDF Panel ────────────────────────────────────────────── */
.pdf-viewer-panel {
    flex: 1;
    background: #000;
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.pdf-viewer-header {
    background: #111;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #222;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-btn,
.zoom-btn {
    background: #222;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 1.1rem;
    border: none;
    cursor: pointer;
}

.nav-btn:hover,
.zoom-btn:hover {
    background: #333;
}

.page-info {
    font-size: 0.8rem;
    color: #888;
    text-align: center;
    min-width: 60px;
    font-weight: 600;
}

.close-pdf-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.close-pdf-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

.pdf-content {
    flex: 1;
    overflow: auto;
    padding: 3rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #080b14;
    position: relative;
}

.canvas-container {
    position: relative;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.8), 0 0 20px rgba(99, 102, 241, 0.1);
    transition: transform 0.3s ease;
    border-radius: 4px;
    overflow: hidden;
}

.snippet-top-bar {
    padding: 1.5rem 2.5rem;
    background: rgba(17, 24, 39, 0.98);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(99, 102, 241, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 50;
    max-height: 200px;
    overflow-y: auto;
    animation: fadeIn 0.5s ease;
}

.snippet-top-content {
    max-width: 900px;
    margin: 0 auto;
    border-left: 4px solid var(--primary);
    padding-left: 1.5rem;
}

.snippet-top-bar strong {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.08em;
    color: var(--primary);
    opacity: 0.9;
}

.snippet-top-bar p {
    font-size: 1rem;
    line-height: 1.7;
    margin: 0;
    font-style: italic;
    color: #f1f5f9;
    letter-spacing: 0.01em;
}

/* ─── Typing ───────────────────────────────────────────────── */
.typing-bubble {
    display: flex;
    gap: 6px;
    padding: 1.2rem;
    background: var(--bg-glass);
    border-radius: 20px;
    width: fit-content;
    border: 1px solid var(--border);
}

.typing-bubble span {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: bounce 1s infinite alternate cubic-bezier(0.5, 0.05, 1, 0.5);
}

.typing-bubble span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-bubble span:nth-child(3) {
    animation-delay: 0.4s;
}

/* ─── Animations ───────────────────────────────────────────── */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translate(-50%, -20px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

@keyframes bounce {
    from {
        transform: translateY(0);
        opacity: 0.3;
    }

    to {
        transform: translateY(-5px);
        opacity: 1;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner {
    width: 22px;
    height: 22px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s ease-in-out infinite;
}

/* ─── Modern Upload Loader ────────────────────────────────── */
.modern-loader {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: #fff;
    border-bottom-color: #fff;
    animation: rotateScale 1s cubic-bezier(0.5, 0.1, 0.4, 0.9) infinite;
}

@keyframes rotateScale {
    0% {
        transform: rotate(0deg) scale(0.8);
    }

    50% {
        transform: rotate(180deg) scale(1.2);
    }

    100% {
        transform: rotate(360deg) scale(0.8);
    }
}

/* ─── Footer ──────────────────────────────────────────────── */
.app-footer {
    padding: 1rem;
    text-align: center;
    background: var(--bg-dark);
    font-size: 0.75rem;
    color: var(--text-low);
    border-top: 1px solid var(--border);
    font-family: var(--font-display);
    letter-spacing: 0.05em;
    z-index: 20;
}