/* =========================================
   1. GLOBAL VARIABLES & RESET
   ========================================= */
:root {
    --primary-blue: #4169e1; /* Royal Blue */
    --glass-bg: rgba(255, 255, 255, 0.15);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-dark: #333;
    --text-light: #fff;
    --blur: 15px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Poppins', sans-serif; /* Kept Poppins */
    background: linear-gradient(135deg, #f0f4ff 0%, #dbeafe 100%);
    color: var(--text-dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Glassmorphism Card Style */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    border-radius: 16px;
}

/* Standard Inputs & Buttons */
input, textarea, select {
    font-family: inherit;
    outline: none;
}

.btn-primary {
    background: var(--primary-blue);
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary:hover { transform: scale(1.05); }

.btn-secondary {
    background: transparent;
    border: 2px solid var(--primary-blue);
    color: var(--primary-blue);
    padding: 10px 23px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    display: inline-block;
}

/* =========================================
   2. HEADER & NAVIGATION
   ========================================= */
header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(65, 105, 225, 0.95);
    padding: 1rem 2rem;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.logo { font-weight: 700; font-size: 1.5rem; letter-spacing: 1px; }

/* Desktop Navigation */
nav ul {
    display: flex;
    gap: 20px; /* Increased gap */
    list-style: none;
    padding: 0;
    margin: 0;
}

nav a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem; /* Restored size */
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.3s;
}

nav a:hover, nav a.active {
    background: rgba(255,255,255,0.2);
}

/* Header Right Alignment */
.header-right { display: flex; align-items: center; gap: 15px; }

/* User Profile - FIXED CIRCULAR */
.user-profile { display: flex; align-items: center; gap: 10px; }

.user-profile img { 
    width: 40px !important; 
    height: 40px !important; 
    border-radius: 50% !important; 
    border: 2px solid white; 
    object-fit: cover; 
}

.user-name { font-size: 0.95rem; font-weight: 500; color: white; }
.logout-link { font-size: 0.8rem; color: rgba(255,255,255,0.8); text-decoration: none; }

/* Solid Login Button */
.login-btn {
    background-color: white !important;
    color: var(--primary-blue) !important;
    border: none !important;
    padding: 8px 20px !important;
    font-size: 0.9rem !important;
    font-weight: 600;
    border-radius: 20px !important;
    text-decoration: none;
}
.login-btn:hover { background-color: #f0f4ff !important; }

/* HAMBURGER ICON - HIDDEN ON DESKTOP */
.mobile-menu-toggle {
    display: none !important; 
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

/* =========================================
   3. FOOTER
   ========================================= */
footer {
    background: #0f172a;
    color: white;
    text-align: center;
    padding: 20px;
    margin-top: auto;
}

.social-icons a {
    color: white;
    margin: 0 10px;
    font-size: 1.2rem;
    text-decoration: none;
}

/* =========================================
   4. HOME PAGE SPECIFICS
   ========================================= */
.home-container {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.hero-card {
    padding: 3rem;
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.hero-card h1 {
    font-size: 2.5rem;
    color: var(--primary-blue);
    margin-bottom: 1rem;
}

.highlight {
    color: var(--primary-blue);
    font-weight: bold;
    text-decoration: underline;
}

.cta-group {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    width: 100%;
    max-width: 1000px;
}

.feature-card {
    padding: 1.5rem;
    text-align: center;
}

.feature-card i {
    font-size: 2rem;
    color: var(--primary-blue);
    margin-bottom: 1rem;
}

/* =========================================
   5. SUBJECT PAGE (GRIDS & MODALS)
   ========================================= */
.page-container {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.page-header {
    text-align: center;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.section-title {
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: #444;
    border-left: 5px solid var(--primary-blue);
    padding-left: 10px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.stream-card {
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    position: relative;
    overflow: hidden;
}

.stream-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.25);
}

.icon-box {
    font-size: 2rem;
    color: var(--primary-blue);
    margin-bottom: 0.5rem;
}

/* Modal Overlay */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 3000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.modal-content {
    width: 90%;
    max-width: 600px;
    padding: 2rem;
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 16px;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
}

.resource-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 2rem 0;
}

.resource-card {
    background: #f0f4ff;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    border: 1px solid transparent;
}

.resource-card:hover { border-color: var(--primary-blue); }
.resource-card i { display: block; font-size: 1.5rem; color: var(--primary-blue); margin-bottom: 5px; }


/* =========================================
   6. BEHAVIOURAL PAGE (FLIP CARDS)
   ========================================= */
.flip-card {
    background-color: transparent;
    height: 250px;
    perspective: 1000px;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    cursor: pointer;
}

.flip-card:hover .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    padding: 1.5rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 16px;
}

.flip-card-front {
    background: rgba(255, 255, 255, 0.4);
    border-left: 4px solid var(--primary-blue);
    border: 1px solid var(--glass-border);
}

.flip-card-back {
    background: var(--primary-blue);
    color: white;
    transform: rotateY(180deg);
}

.category-tag {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0,0,0,0.1);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: bold;
}

/* =========================================
   7. CURRENT AFFAIRS & NEWS GRID
   ========================================= */
.search-bar-container {
    margin: 1.5rem 0;
    display: flex;
    justify-content: center;
    gap: 10px;
}

#news-search {
    padding: 10px 15px;
    border-radius: 25px;
    border: 1px solid #ccc;
    width: 100%;
    max-width: 400px;
    background: rgba(255,255,255,0.8);
}

.btn-search {
    background: var(--primary-blue);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
}

.filter-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 1rem;
}

.tag {
    background: rgba(255,255,255,0.5);
    padding: 5px 15px;
    border-radius: 15px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: 0.3s;
}

.tag.active, .tag:hover {
    background: var(--primary-blue);
    color: white;
}

.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.news-card {
    padding: 1.5rem;
    position: relative;
    display: flex;
    flex-direction: column;
}

.news-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #e0e7ff;
    color: var(--primary-blue);
    padding: 3px 10px;
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: bold;
}

.news-card h3 { margin-top: 1.5rem; margin-bottom: 0.5rem; }
.news-date { font-size: 0.8rem; color: #666; margin-bottom: 10px; }
.news-desc { flex-grow: 1; margin-bottom: 1.5rem; line-height: 1.5; }

.btn-small-outline {
    background: transparent;
    border: 1px solid var(--primary-blue);
    color: var(--primary-blue);
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    width: 100%;
    transition: 0.3s;
    text-align: center;
    text-decoration: none;
    display: inline-block;
}
.btn-small-outline:hover { background: var(--primary-blue); color: white; }

/* =========================================
   8. ADMIN & PDF RESOURCES STYLES
   ========================================= */
.admin-container { 
    max-width: 1000px; 
    margin: 2rem auto; 
    padding: 2rem; 
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
}

.tab-nav { 
    display:flex; 
    gap:10px; 
    margin-bottom:20px; 
    border-bottom:2px solid #eee; 
}

.tab-btn { 
    padding:10px 20px; 
    cursor:pointer; 
    background:rgba(255,255,255,0.5); 
    border:none; 
    border-radius: 8px 8px 0 0; 
    font-weight: 500;
    transition: 0.3s;
}

.tab-btn.active { 
    background:var(--primary-blue); 
    color:white; 
    font-weight:bold; 
}

.tab-content { 
    display:none; 
    animation: fadeIn 0.5s; 
}

.tab-content.active { 
    display:block; 
}

@keyframes fadeIn { 
    from { opacity:0; } 
    to { opacity:1; } 
}

.note { 
    font-size: 0.85rem; 
    color: #666; 
    margin-bottom: 15px; 
    display: block; 
}

input, textarea, select { 
    width:100%; 
    padding:10px; 
    margin-bottom:15px; 
    border:1px solid #ccc; 
    border-radius:5px; 
}

/* =========================================
   9. CHATBOT INTERFACE
   ========================================= */
#chat-trigger {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: var(--primary-blue);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(65, 105, 225, 0.4);
    z-index: 2000;
    transition: transform 0.2s;
}
#chat-trigger:hover { transform: scale(1.1); }

/* Desktop Chat Window */
#avinash-chat-interface {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    height: 550px;
    display: none; 
    flex-direction: column;
    z-index: 9999;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.chat-header {
    background: var(--primary-blue);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    z-index: 2010;
    position: relative;
}
.chat-header button { background: none; border: none; color: white; cursor: pointer; font-size: 1.2rem; }

#chat-messages {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message { max-width: 80%; padding: 10px 14px; border-radius: 12px; font-size: 0.9rem; line-height: 1.4; word-wrap: break-word; }
.bot-msg { align-self: flex-start; background: white; border: 1px solid #e0e7ff; color: #333; border-bottom-left-radius: 2px; }
.user-msg { align-self: flex-end; background: var(--primary-blue); color: white; border-bottom-right-radius: 2px; }
.error { background: #fee2e2; color: #991b1b; border: 1px solid #f87171; }

.chat-input-area {
    padding: 10px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 60px;
    z-index: 2010;
    flex-shrink: 0;
}

.chat-input-area textarea {
    flex-grow: 1;
    height: 40px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 20px;
    resize: none;
    outline: none;
}

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

.attach-btn { color: #64748b; cursor: pointer; font-size: 1.2rem; padding: 5px; }
.attach-btn:hover { color: var(--primary-blue); }

.pulse-animation {
    animation: pulse-red 1.5s infinite;
}
@keyframes pulse-red {
    0% { transform: scale(1); text-shadow: 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

#mic-btn { margin-right: 5px; cursor: pointer; transition: color 0.3s; z-index: 2020; pointer-events: auto; }

/* Button Fixes */
#voice-toggle-btn, #mic-btn, #close-chat {
    pointer-events: auto;
    cursor: pointer;
    position: relative;
    z-index: 2020;
}

/* =========================================
   10. MOBILE FIXES (ONLY APPLIES TO SCREENS < 480px)
   ========================================= */
@media (max-width: 480px) {
    /* 1. Show Hamburger Icon (ONLY HERE) */
    .mobile-menu-toggle { display: block !important; }

    /* 2. Hide Default Nav Links */
    nav ul { display: none !important; }

    /* 3. Mobile Dropdown */
    nav ul.active {
        display: flex !important;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: rgba(65, 105, 225, 0.98);
        backdrop-filter: blur(10px);
        padding: 20px 0;
        text-align: center;
        box-shadow: 0 4px 10px rgba(0,0,0,0.2);
        border-top: 1px solid rgba(255,255,255,0.1);
        z-index: 1001;
    }

    nav ul.active li { margin: 10px 0; }
    nav ul.active a { display: block; padding: 10px; font-size: 1.1rem; }
    
    /* 4. Hide User Name on Mobile */
    .user-name, .logout-link { display: none; }

    /* 5. Force Chat Window Full Screen Overlay */
    #avinash-chat-interface {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        bottom: 0 !important;
        right: 0 !important;
        border-radius: 0 !important;
        z-index: 2147483647 !important;
        display: none;
        flex-direction: column !important;
        margin: 0 !important;
    }

    /* 6. Adjust Header for Phone Status Bar/Notch */
    .chat-header {
        padding-top: 40px !important;
        padding-bottom: 15px !important;
        flex-shrink: 0 !important;
    }

    /* 7. Messages Area */
    #chat-messages {
        flex-grow: 1 !important;
        height: auto !important;
        max-height: none !important;
        padding-bottom: 10px !important;
    }

    /* 8. Fix Input Area Squashing */
    .chat-input-area {
        padding: 10px 5px !important;
        gap: 5px !important;
        background: white !important;
        border-top: 1px solid #eee !important;
        flex-shrink: 0 !important;
        position: relative !important; 
        bottom: 0 !important;
    }

    /* Prevent Zoom on Focus */
    .chat-input-area textarea {
        font-size: 16px !important; 
        padding: 8px 10px !important;
        height: 45px !important;
    }

    #chat-trigger {
        z-index: 1000 !important;
    }
}