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

:root {
    --primary: #004e98;
    --primary-light: #3a6ea5;
    --pulse: #00a896;
    --pulse-soft: rgba(0, 168, 150, 0.1);
    --bg-main: #f0f4f8;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --text-main: #1a202c;
    --text-muted: #4a5568;
    --shadow-premium: 0 12px 24px -6px rgba(0, 0, 0, 0.08), 0 4px 12px -4px rgba(0, 0, 0, 0.04);
    
    /* Fluid Layout Variables */
    --pad-container: 2rem;
    --pad-bubble: 1rem 1.25rem;
    --fs-base: 1rem;
    --fs-h1: 1.5rem;
    --fs-small: 0.85rem;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background: radial-gradient(circle at top left, #fdfdfd, #e2e8f0);
    color: var(--text-main);
    height: 100dvh; /* Dynamic viewport height for mobile */
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#app {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    max-width: 1000px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: var(--shadow-premium);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (min-width: 768px) {
    #app {
        height: 85vh;
        border-radius: 24px;
    }
}

/* Header Branding */
header {
    padding: calc(var(--pad-container) * 0.6) var(--pad-container);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

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

.logo-text {
    font-size: var(--fs-h1);
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--pulse));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Chat Area */
#chat-box {
    flex: 1;
    overflow-y: auto;
    padding: var(--pad-container);
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Custom Scrollbar */
#chat-box::-webkit-scrollbar {
    width: 6px;
}

#chat-box::-webkit-scrollbar-track {
    background: transparent;
}

#chat-box::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 10px;
}

/* Message Bubbles */
.msg-bubble {
    padding: var(--pad-bubble);
    border-radius: 20px;
    max-width: 85%;
    font-size: 0.95rem;
    line-height: 1.6;
    animation: slideUp 0.3s ease-out;
    position: relative;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

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

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

.user-msg {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-msg {
    align-self: flex-start;
    background: white;
    color: var(--text-main);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.bot-msg pre {
    font-family: inherit;
}

/* Input Zone */
.input-area {
    padding: calc(var(--pad-container) * 0.75) var(--pad-container);
    background: white;
    display: flex;
    align-items: center;
    gap: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

input {
    flex: 1;
    min-width: 0; /* Prevents input from overflowing flex container */
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: calc(var(--pad-container) * 0.4) calc(var(--pad-container) * 0.6);
    border-radius: 16px;
    font-size: var(--fs-base);
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
}

input:focus {
    border-color: var(--pulse);
    background: white;
    box-shadow: 0 0 0 calc(var(--pad-container) * 0.1) var(--pulse-soft);
}

.action-btn {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-size: 1.1rem;
}

.camera-btn {
    background: #f1f5f9;
    color: #64748b;
}

.camera-btn:hover {
    background: #e2e8f0;
    color: var(--primary);
    transform: scale(1.05);
}

.send-btn {
    background: var(--primary);
    color: white;
}

.send-btn:hover {
    background: var(--primary-light);
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Preview */
.img-preview-banner {
    background: white;
    padding: 12px 2rem;
    border-top: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 12px;
}

.preview-thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid var(--pulse);
}

/* Login Card Upgrade */
.login-page {
    height: 100vh;
    width: 100vw;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--pulse) 100%);
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 3rem;
    border-radius: 32px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    text-align: center;
}

.login-card h1 {
    margin-bottom: 0.5rem;
    font-weight: 800;
    color: var(--primary);
}

.login-card p {
    margin-bottom: 2rem;
    color: var(--text-muted);
}

.form-group {
    text-align: left;
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.9rem;
}

.login-btn {
    width: 100%;
    margin-top: 1rem;
    padding: 14px;
    font-size: 1rem;
}

/* Markdown Rendering & Premium UI Refinements */
.markdown-body {
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    font-size: 0.95rem;
}

/* Premium Route Card Styles */
.markdown-body h3 {
    margin: 1.5rem 0 1rem;
    font-size: 1rem;
    font-weight: 800;
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    padding: 12px 16px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 78, 152, 0.2);
    display: flex;
    align-items: center;
    gap: 10px;
}

.markdown-body h3::before {
    content: "📍";
    font-size: 1.2rem;
}

/* Vertical Timeline Engine */
.markdown-body ul {
    list-style: none;
    padding-left: 1.8rem;
    position: relative;
    border-left: 2px solid #e2e8f0;
    margin: 1rem 0 1.5rem 0.8rem;
}

.markdown-body li {
    margin-bottom: 1.25rem;
    position: relative;
    line-height: 1.5;
}

.markdown-body li::before {
    content: '';
    position: absolute;
    left: -1.8rem;
    top: 0.4rem;
    width: 12px;
    height: 12px;
    background: white;
    border: 3px solid var(--pulse);
    border-radius: 50%;
    transform: translateX(-50%);
    z-index: 2;
    transition: all 0.3s ease;
}

.markdown-body li:hover::before {
    background: var(--pulse);
    transform: translateX(-50%) scale(1.2);
}

/* Highlighted Times & Actions */
.markdown-body strong {
    color: var(--primary);
    font-weight: 600;
}

/* Professional Comparison Table */
.markdown-body table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 1.5rem 0;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    font-size: 0.85rem;
}

.markdown-body th {
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    padding: 10px;
    border-bottom: 1px solid #e2e8f0;
}

.markdown-body td {
    padding: 10px;
    border-bottom: 1px solid #f1f5f9;
}

.markdown-body tr:last-child td {
    border-bottom: none;
}

/* Expert Tip Box */
.markdown-body blockquote {
    padding: 1rem 1.25rem;
    background: var(--pulse-soft);
    border-left: 4px solid var(--pulse);
    border-radius: 12px;
    margin: 1.25rem 0;
    color: var(--text-main);
}

.markdown-body blockquote p::before {
    content: "💡 ";
}

/* Voice Mode UI */
.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.voice-toggle-btn {
    background: #f1f5f9;
    color: var(--text-muted);
    border: 1px solid #e2e8f0;
    padding: 8px 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.voice-toggle-btn.active {
    background: var(--pulse-soft);
    color: var(--pulse);
    border-color: var(--pulse);
    box-shadow: 0 0 15px var(--pulse-soft);
}

.voice-toggle-btn i {
    font-size: 1rem;
}

.voice-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    margin-bottom: 2rem;
}

.pulse-center {
    width: 64px;
    height: 64px;
    background: var(--pulse);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    z-index: 2;
    box-shadow: 0 4px 15px rgba(0, 168, 150, 0.4);
}

.pulse-ring {
    position: absolute;
    width: 64px;
    height: 64px;
    background: var(--pulse);
    border-radius: 50%;
    opacity: 0.3;
    z-index: 1;
    transition: transform 0.1s ease-out;
}

.voice-status {
    margin-top: 1.5rem;
    font-weight: 600;
    color: var(--pulse);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-size: 0.75rem;
}

.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 0.5rem 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Responsive Fixes for Small Screens */
@media (max-width: 600px) {
    :root {
        --pad-container: 1rem;
        --pad-bubble: 0.8rem 1rem;
        --fs-h1: 1.25rem;
    }

    #chat-box {
        padding: var(--pad-container);
    }

    .msg-bubble {
        max-width: 95%;
        padding: var(--pad-bubble);
    }

    .markdown-body table {
        display: block;
        overflow-x: auto;
    }

    .logo-text {
        font-size: var(--fs-h1);
    }

    .subtitle {
        display: none;
    }
}

/* Micro-Terminal Adjustments (e.g., iPhone SE) */
@media (max-width: 400px) {
    :root {
        --pad-container: 0.75rem;
    }
    
    .action-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .voice-toggle-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
    
    .logo-container {
        gap: 8px;
    }
}
.voice-active-input {
    justify-content: center;
    background: var(--pulse-soft) !important;
}

.stop-voice-btn {
    background: #ff4d4d !important;
    color: white !important;
    width: auto !important;
    padding: 0 24px !important;
    gap: 10px;
    font-weight: 800;
}

.stop-voice-btn:hover {
    background: #ff3333 !important;
    transform: scale(1.02);
}
