/* ============================================================
   1. CORE VARIABLES & RESET
   ============================================================ */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --border: #e2e8f0;
    --bot-msg-bg: #ffffff;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* ============================================================
   2. NAVIGATION & LAYOUT
   ============================================================ */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 6%;
    background-color: #ffffff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    transition: transform 0.2s ease;
}

.logo-container:hover { transform: scale(1.01); }

.logo-img {
    height: 42px;
    width: auto;
    object-fit: contain;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 800;
    color: #0b3d66;
    letter-spacing: -0.03em;
}

.container {
    max-width: 800px;
    margin: 2rem auto;
    padding: 2rem;
    background: var(--card);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.hidden { display: none !important; }

/* ============================================================
   3. FORMS & INPUTS
   ============================================================ */
h1, h2, h3 { color: var(--primary); margin-bottom: 1rem; }

.row { display: flex; gap: 20px; margin-bottom: 1.2rem; }
.col { flex: 1; display: flex; flex-direction: column; }

label { font-weight: 600; font-size: 0.9rem; color: #64748b; margin-bottom: 4px; }

input, select {
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
    width: 100%;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
}

.subject-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    background: #f1f5f9;
    padding: 12px;
    border-radius: 8px;
    align-items: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
    width: 100%;
}

.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }

.btn-secondary {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
}

/* ============================================================
   4. CHAT SYSTEM
   ============================================================ */
#chat-box {
    height: 450px;
    overflow-y: auto;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f9fafb;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.user-msg, .bot-msg {
    margin-bottom: 1.2rem;
    padding: 12px 18px;
    border-radius: 15px;
    max-width: 85%;
    word-wrap: break-word;
    position: relative;
}

.user-msg { 
    background: var(--primary); 
    color: white; 
    margin-left: auto; 
    border-bottom-right-radius: 2px;
}

.bot-msg { 
    background: var(--bot-msg-bg); 
    color: var(--text); 
    border: 1px solid var(--border);
    border-bottom-left-radius: 2px;
}

/* Input Bar Styling */
.chat-input-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 5px 5px 5px 20px;
}

#user-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 10px 0;
}

#send-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#send-btn:disabled { background: #cbd5e1; cursor: not-allowed; }

/* ============================================================
   5. STREAMING CONTENT FIXES (Markdown)
   ============================================================ */
.stream-content { display: block; }
.stream-content p { margin-bottom: 8px !important; }
.stream-content ul, .stream-content ol { padding-left: 25px; margin-bottom: 10px; }
.stream-content li { margin-bottom: 4px; }
.stream-content h3 { font-size: 1.1rem; margin-top: 10px; color: var(--primary); }

/* ============================================================
   6. MODAL & PRICING
   ============================================================ */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: white; padding: 30px; border-radius: 20px; width: 90%; max-width: 450px;
    text-align: center;
}

.pricing-grid { display: flex; flex-direction: column; gap: 12px; margin: 20px 0; }

.price-card {
    border: 2px solid #f1f5f9; padding: 15px; border-radius: 12px; cursor: pointer;
    text-align: left; transition: 0.2s;
}

.price-card:hover { border-color: var(--primary); background: #f8faff; }
.price-card.popular { border-color: var(--success); background: #f0fff4; }

.price { font-size: 1.4rem; font-weight: 800; color: var(--primary); }
.badge { background: var(--success); color: white; padding: 2px 8px; border-radius: 4px; font-size: 0.7rem; }

/* ============================================================
   7. UTILITIES
   ============================================================ */
#credit-badge {
    position: fixed; top: 80px; right: 20px;
    background: var(--success); color: white;
    padding: 8px 16px; border-radius: 20px; font-weight: bold;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.gemini-loader {
    width: 20px; height: 20px;
    border: 3px solid #f3f3f3; border-top: 3px solid var(--primary);
    border-radius: 50%; animation: spin 1s linear infinite;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ============================================================
   8. MOBILE RESPONSIVENESS
   ============================================================ */
@media (max-width: 768px) {
    .container { width: 95%; padding: 15px; margin: 10px auto; }
    .row { flex-direction: column; gap: 10px; }
    .subject-row { flex-direction: column; align-items: flex-start; }
    
    #chat-box { height: 400px; padding: 10px; }
    .user-msg, .bot-msg { max-width: 95%; }
    
    .navbar { padding: 10px 15px; }
    .logo-text { font-size: 1.2rem; }
}

/* ============================================================
   9. PDF EXPORT OVERRIDES (Used by html2pdf)
   ============================================================ */
@media print {
    .bot-msg { background: #f0f4f8 !important; border-left: 5px solid #0b3d66 !important; color: black !important; }
    .user-msg { color: #555 !important; border-bottom: 1px solid #ddd !important; background: transparent !important; }
}
/* --- Landing Page Spacing Fix --- */

#landing-page {
    text-align: center;
    padding: 4rem 2rem; /* Increases internal breathing room of the card */
}

#landing-page h1 {
    font-size: 2.2rem;
    margin-bottom: 1.5rem; /* Space below the main title */
    line-height: 1.2;
}

#landing-page p {
    font-size: 1.1rem;
    color: #475569;
    margin-bottom: 2.5rem; /* This creates the wide gap before the button */
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

#landing-page .btn-primary {
    max-width: 250px; /* Prevents the button from being giant on desktop */
   
}
/* Animated Dots for "Thinking" state */
.dot-pulse::after {
    content: '...';
    display: inline-block;
    width: 20px;
    text-align: left;
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* Optional: Make the thinking message slightly transparent to look "in progress" */
.bot-msg[id^="load-"] {
    color: #555;
    font-style: italic;
}
#top-up-chat-btn {
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

#top-up-chat-btn:hover {
    background-color: #e67e22; /* Slightly darker orange on hover */
}