/* ==========================================================================
   AskMe AI - Master Stylesheet
   ========================================================================== */

/* --- 1. Base & Reset --- */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;800&display=swap');

body { 
    font-family: 'Nunito', sans-serif; 
    background: url('https://images.unsplash.com/photo-1557683316-973673baf926?auto=format&fit=crop&w=1920&q=80') center/cover no-repeat fixed;
    min-height: 100vh;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center; 
    color: #2d3748;
    padding-top: 100px; 
    box-sizing: border-box;
}

body.dashboard-layout {
    align-items: flex-start;
    padding: 120px 20px 40px 20px; 
}

/* --- 2. Main Containers --- */
.app-container {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 40px;
    border-radius: 28px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    border: 1px solid rgba(255, 255, 255, 0.6);
    width: 90%;
    max-width: 480px;
    text-align: center;
    transition: all 0.3s ease;
}

.app-container.dashboard-container {
    max-width: 800px;
    text-align: left;
}

/* --- 3. Typography --- */
h1 { color: #4338ca; margin-top: 0; margin-bottom: 25px; font-size: 28px; font-weight: 800; }
h2 { color: #1e293b; font-size: 20px; font-weight: 800; margin-bottom: 15px; }
.subtitle { color: #64748b; font-size: 16px; margin-bottom: 30px; }

/* --- 4. Inputs & Forms --- */
.input-group { position: relative; margin-bottom: 20px; }
.input-group i.left-icon, .input-group i.fa-comment-dots { 
    position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: #94a3b8; font-size: 18px; 
}
.toggle-password { 
    position: absolute; right: 18px; top: 50%; transform: translateY(-50%); color: #94a3b8; font-size: 18px; cursor: pointer; transition: color 0.2s; 
}
.toggle-password:hover { color: #4338ca; }

input[type="text"], input[type="email"], input[type="password"] { 
    width: 100%; padding: 14px 14px 14px 45px; font-size: 16px; font-family: 'Nunito', sans-serif; 
    border: 2px solid #e2e8f0; border-radius: 16px; outline: none; box-sizing: border-box; 
    background-color: rgba(255, 255, 255, 0.9); transition: 0.3s; 
}
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus { 
    border-color: #4338ca; box-shadow: 0 0 0 4px rgba(67, 56, 202, 0.1);
}
input[type="password"], input.pw-visible { padding-right: 45px; }

/* --- 5. Buttons --- */
button, .btn { 
    background: linear-gradient(135deg, #6366f1 0%, #4338ca 100%); color: white; 
    padding: 14px 30px; font-size: 16px; font-family: 'Nunito', sans-serif; font-weight: 700; 
    cursor: pointer; margin: 5px; border: none; border-radius: 30px; transition: all 0.2s; 
    box-shadow: 0 4px 15px rgba(67, 56, 202, 0.3); display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
button:hover, .btn:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(67, 56, 202, 0.4); color: white; }

.btn-yes { background: linear-gradient(135deg, #10b981 0%, #059669 100%); box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3); }
.btn-yes:hover { box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4); }

.btn-no { background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%); box-shadow: 0 4px 15px rgba(244, 63, 94, 0.3); }
.btn-no:hover { box-shadow: 0 8px 25px rgba(244, 63, 94, 0.4); }

.btn-outline { background: transparent; color: #64748b; box-shadow: none; border: 2px solid #cbd5e1; }
.btn-outline:hover { background: #f8fafc; color: #475569; transform: translateY(-1px); box-shadow: none; }

form button { width: 100%; margin: 5px 0 0 0; border-radius: 16px; font-size: 18px; }

/* --- 6. The Navigation Bar --- */
.glass-nav {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%); width: 95%; max-width: 950px;
    background: rgba(255, 255, 255, 0.75); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.6); border-radius: 50px; padding: 10px 20px;
    display: flex; justify-content: space-between; align-items: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08); z-index: 1000; box-sizing: border-box;
}

.nav-brand { 
    font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 20px; color: #4338ca; 
    text-decoration: none; display: flex; align-items: center; gap: 8px; 
    white-space: nowrap; flex-shrink: 0; 
}

.nav-links { 
    display: flex; gap: 6px; align-items: center; 
    overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
}
.nav-links::-webkit-scrollbar { display: none; }

.nav-link { 
    font-family: 'Nunito', sans-serif; text-decoration: none; color: #64748b; font-weight: 700; 
    font-size: 15px; transition: 0.2s; padding: 8px 14px; border-radius: 20px; 
    display: flex; align-items: center; gap: 6px; 
    white-space: nowrap; flex-shrink: 0;
}
.nav-link:hover { color: #4338ca; background: rgba(255,255,255,0.5); }

.nav-btn { 
    background: linear-gradient(135deg, #6366f1 0%, #4338ca 100%); color: white; 
    padding: 8px 20px; border-radius: 20px; text-decoration: none; font-weight: 700; 
    font-size: 15px; transition: 0.2s; box-shadow: 0 4px 10px rgba(67, 56, 202, 0.3); 
    white-space: nowrap; flex-shrink: 0;
}
.nav-btn:hover { transform: translateY(-2px); color: white; box-shadow: 0 6px 15px rgba(67, 56, 202, 0.4); }

/* --- 7. Analyzer Specific --- */
#result { font-size: 18px; font-weight: 600; margin-top: 25px; color: #1e293b; line-height: 1.5; padding: 15px; background: rgba(255,255,255,0.5); border-radius: 12px; text-align: left;}
.hidden { display: none !important; }
.spinner { font-size: 40px; color: #4338ca; margin: 30px auto; animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { transform: scale(0.95); opacity: 0.5; } 50% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(0.95); opacity: 0.5; } }

/* --- 8. Messages & Alerts --- */
.msg { padding: 15px; border-radius: 12px; margin-bottom: 20px; font-weight: 600; }
.msg.error { background: #fee2e2; color: #b91c1c; }
.msg.success { background: #d1fae5; color: #047857; }
.footer-link { margin-top: 20px; display: block; color: #64748b; text-decoration: none; font-weight: 600; }
.footer-link:hover { color: #4338ca; }
.guest-banner { background: #fffbeb; border-left: 4px solid #f59e0b; padding: 15px 20px; border-radius: 8px; margin-bottom: 30px; display: flex; justify-content: space-between; align-items: center; }
.guest-banner p { margin: 0; color: #b45309; font-weight: 600; }
.guest-banner a { color: #b45309; font-weight: 800; text-decoration: underline; }

/* --- 9. Dashboard Specific --- */
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; border-bottom: 2px solid rgba(0,0,0,0.05); padding-bottom: 20px; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 40px; }
.stat-card { background: white; padding: 25px; border-radius: 20px; text-align: center; box-shadow: 0 4px 15px rgba(0,0,0,0.05); }
.stat-card h3 { margin: 0 0 10px 0; color: #64748b; font-size: 16px; text-transform: uppercase; letter-spacing: 1px; }
.stat-card .number { font-size: 48px; font-weight: 800; line-height: 1; }
.yes-stat .number { color: #10b981; }
.no-stat .number { color: #f43f5e; }

.history-list { display: flex; flex-direction: column; gap: 15px; }
.history-item { background: rgba(255,255,255,0.6); padding: 20px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.8); display: flex; justify-content: space-between; align-items: center; }
.history-question { font-size: 16px; font-weight: 600; margin-bottom: 5px; }
.history-date { font-size: 12px; color: #94a3b8; }
.badge { padding: 6px 14px; border-radius: 20px; font-size: 14px; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; }
.badge-yes { background: #d1fae5; color: #047857; }
.badge-no { background: #ffe4e6; color: #e11d48; }
.badge-followup { background: #f1f5f9; color: #64748b; }

/* --- 10. AI Markdown Formatting Styles --- */
#result p { margin-bottom: 15px; line-height: 1.6; }
#result pre { background-color: #1e293b; color: #f8fafc; padding: 15px; border-radius: 8px; overflow-x: auto; font-family: 'Courier New', Courier, monospace; font-size: 14px; margin-bottom: 15px; border: 1px solid #334155; position: relative; }
#result code { background-color: #e2e8f0; color: #b91c1c; padding: 2px 6px; border-radius: 4px; font-family: 'Courier New', Courier, monospace; font-size: 13px; }
#result pre code { background-color: transparent; color: inherit; padding: 0; }
#result ul, #result ol { margin-left: 20px; margin-bottom: 15px; }

/* --- 11. AI Summary View Styles --- */
.ai-summary-card {
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: #ffffff;
    margin-top: 15px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    text-align: left;
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 15px;
}

.summary-label {
    font-size: 12px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 800;
}

.verdict-pill {
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.verdict-yes { background: #d1fae5; color: #059669; }
.verdict-no { background: #ffe4e6; color: #e11d48; }

.summary-body {
    color: #334155;
    font-size: 15px;
    line-height: 1.6;
}

.summary-body p:last-child { margin-bottom: 0; }

/* ==========================================================================
   12. MOBILE OPTIMIZATION (THE FIX)
   ========================================================================== */
@media (max-width: 768px) {
    /* Give the body more top padding so the navbar doesn't cover content */
    body { padding-top: 140px; }
    body.dashboard-layout { padding-top: 150px; }

    /* Reclaim screen space: Reduce massive padding and make container wider */
    .app-container { 
        padding: 25px 20px; 
        width: 95%; 
        border-radius: 20px;
    }

    /* The Navbar Fix: Turn it into a sleek swipeable row */
    .glass-nav { 
        flex-direction: column; 
        border-radius: 20px; 
        gap: 10px; 
        padding: 15px 15px 10px 15px; 
    }
    
    .nav-links { 
        width: 100%; 
        justify-content: flex-start; /* Align left so swipe is obvious */
        flex-wrap: nowrap; /* NEVER wrap to a second line */
        overflow-x: auto; /* Allow horizontal swiping */
        -webkit-overflow-scrolling: touch; /* Smooth swipe on iPhones */
        padding-bottom: 5px; 
        gap: 8px;
    }

    /* Hide the ugly scrollbar on mobile so it looks like a native app */
    .nav-links::-webkit-scrollbar { display: none; }

    /* Stack the Dashboard Grid so numbers don't squish */
    .stats-grid { 
        grid-template-columns: 1fr; 
        gap: 15px; 
        margin-bottom: 25px;
    }

    /* Stack History logs so questions don't crash into badges */
    .history-item { 
        flex-direction: column; 
        align-items: flex-start; 
        gap: 12px; 
    }

    /* Fix Guest Banner overlapping text */
    .guest-banner { 
        flex-direction: column; 
        text-align: center; 
        gap: 12px; 
    }

    /* Fix Analyzer Buttons: Stack Yes/No so they don't push off screen */
    #buttonArea {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    #buttonArea button {
        width: 100%;
        margin: 0;
    }

    /* Font adjustments for small screens */
    h1 { font-size: 24px; }
    #result { font-size: 16px; }
}