/* ================================================================= */
/* CSS Variables - UPDATED COLOR SCHEME */
/* ================================================================= */
:root {
    /* Primary Colors - Original Blue & Vibrant Teal */
    --primary-color: #2563eb;
    --accent-color: #059669;
    --success-color: #059669;
    --danger-color: #ef4444;

    /* Background Colors */
    --bg-color: #f8fafc;
    --header-bg: #ffffff;
    --card-bg: #eee9e9;
    --footer-bg: #1f2937;

    /* Badge Colors */
    --ol-badge-color: #10b981;
    --al-badge-color: #007bff;

    /* Text Colors */
    --main-text-color: #1e293b;
    --secondary-text-color: #64748b;

    /* Border & Shadow */
    --border-color: #e2e8f0;
    --shadow-color: rgba(0, 0, 0, 0.08);
    --year-separator-color: #14b8a6;

    /* Fonts */
    --font-heading: 'Poppins', sans-serif;
    --font-body: 'Poppins', sans-serif;
}

.menu-open {
    overflow: hidden !important;
}

.dark-mode {
    /* Dark Mode Colors - Rich Dark Theme */
    --primary-color: #2563eb;
    --accent-color: #01c486;
    --success-color: #059669;
    --danger-color: #f87171;

    /* Dark Backgrounds */
    --bg-color: #0f172a;
    --header-bg: #1e293b;
    --card-bg: #1e293b;
    --footer-bg: #0f172a;

    /* Dark Text */
    --main-text-color: #f1f5f9;
    --secondary-text-color: #94a3b8;

    /* Dark Borders & Shadow */
    --border-color: #334155;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --year-separator-color: #2dd4bf;
}

/* ================================================================= */
/* Modal Buttons 2x2 Grid Layout */
/* ================================================================= */
.details-buttons {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: auto auto !important;
    gap: 10px !important;
    margin-top: 20px;
}

.action-btn {
    padding: 12px 8px;
    border-radius: 12px;
    text-align: center;
    font-weight: 600;
    font-size: 0.9em;
    transition: all 0.3s ease;
    display: block;
    text-decoration: none;
}

.btn-paper {
    background-color: var(--primary-color);
    color: white;
    border: 2px solid var(--primary-color);
}

.btn-paper:hover {
    background-color: transparent;
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-scheme {
    background-color: var(--success-color);
    color: white;
    border: 2px solid var(--success-color);
}

.btn-scheme:hover {
    background-color: transparent;
    color: var(--success-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-preview {
    background-color: var(--accent-color);
    color: white;
    border: 2px solid var(--accent-color);
}

.btn-preview:hover {
    background-color: transparent;
    color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
}

/* ================================================================= */
/* Base Styles */
/* ================================================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
    overflow-y: scroll;
    scrollbar-gutter: stable both-edges;
}

body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    background-color: var(--bg-color);
    color: var(--main-text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

body.theme-transition {
    transition: background-color 0.3s, color 0.3s;
}

main {
    flex-grow: 1;
    padding-bottom: 50px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    color: var(--main-text-color);
    line-height: 1.2;
}

h1 {
    font-size: 2.5em;
}

h2 {
    font-size: 2em;
}

h3 {
    font-size: 1.5em;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s;
}

a:hover {
    color: var(--accent-color);
}

.page-title {
    color: var(--primary-color);
    border-bottom: 3px solid var(--accent-color);
    padding-bottom: 15px;
    margin-top: 5px;
    margin-bottom: 20px;
    /* Reduced from 40px to bring filters up */
    font-size: 2.2em;
    font-weight: 700;
}

/* Filter Section - Pull Up */
.filter-section {
    margin-top: -2px !important;
    padding-top: 0 !important;
}

.main-header {
    background-color: var(--primary-color) !important;
    /* Ensure spacing */
}

.logo {
    font-size: 1.8em;
    /* Increased size */
    font-weight: 800;
    /* Bolder */
    color: white;
    margin-right: 20px;
    margin-top: -8px;
    /* Pull logo extremely up */
    transition: color 0.3s;
    flex-shrink: 0;
    line-height: 1;
    /* Reduce line-height to remove vertical space */
}

.logo a {
    color: white !important;
    transition: color 0.3s;
    text-decoration: none;
}

/* Hide hamburger button on desktop */
.hamburger-btn {
    display: none;
}

/* Hide mobile menu overlay on desktop */
.menu-overlay {
    display: none;
}

.main-nav {
    display: flex;
    gap: 20px;
    flex-grow: 1;
    justify-content: center;
    padding: 0 10px;
    min-width: 250px;
    margin-top: -5px !important;
    /* Force pull nav buttons up aggressively */
}

.main-nav a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    padding: 8px 0;
    position: relative;
    transition: color 0.3s;
    white-space: nowrap;
}

.main-nav a:hover {
    color: var(--accent-color);
}

.main-nav a.active-link {
    color: #fff;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.main-nav a.active-link::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -5px;
    width: 100%;
    height: 3px;
    background-color: #06b6d4;
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(6, 182, 212, 0.6);
}

#year-filter,
#search-bar {
    padding: 10px 15px;
    border: 1.5px solid #007bff;
    border-radius: 20px;
    font-size: 1em;
    background-color: rgba(255, 255, 255, 0.95);
    color: var(--main-text-color);
    transition: all 0.3s;
    flex-shrink: 0;
    margin: 0;
    margin-top: -8px !important;
    /* Force pull search bar up aggressively */
}

#year-filter {
    width: 120px;
    margin-right: 25px;
}

#search-bar {
    width: 250px;
    flex-grow: 1;
    max-width: 300px;
}

#year-filter:focus,
#search-bar:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 8px rgba(20, 184, 166, 0.5);
    outline: none;
}

#theme-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    color: white;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 20px;
    font-weight: 600;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
    margin-left: auto;
    display: flex;
    align-items: center;
    white-space: nowrap;
    flex-shrink: 0;
}

#theme-toggle:hover {
    background-color: white;
    color: var(--primary-color);
    border-color: white;
}

body.dark-mode .main-header {
    background: linear-gradient(135deg, #1e293b, #334155);
    border-bottom-color: #334155;
}

body.dark-mode .logo,
body.dark-mode .logo a {
    color: white;
}

body.dark-mode .main-nav a {
    color: #f0f0f0;
}

body.dark-mode #year-filter,
body.dark-mode #search-bar {
    background-color: #334155;
    border-color: #475569;
    color: var(--main-text-color);
}

body.dark-mode #theme-toggle {
    border-color: white;
    background: rgba(255, 255, 255, 0.15);
}

body.dark-mode #theme-toggle:hover {
    background: white;
    color: #0f172a;
}

/* ================================================================= */
/* Mobile & Tablet Navigation */
/* ================================================================= */
@media (max-width: 1100px) {
    body {
        overflow-x: hidden !important;
    }

    .header-content {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 5px;
        padding: 10px 15px;
        position: relative;
        flex-wrap: wrap;
    }

    .logo {
        font-size: 1.25em;
        order: 1;
        width: auto;
        margin-right: auto;
        padding-right: 0;
        flex-shrink: 0;
    }

    .logo a {
        display: inline-block;
    }

    /* Tablet Specific: Force Logo & Theme to take full Row 1 */
    @media (min-width: 768px) {
        .header-content {
            justify-content: flex-start;
            /* Reset justify to allow flex-basis to work */
        }

        .logo {
            flex-grow: 1;
            /* Take all available space */
            width: auto;
        }

        #theme-toggle {
            margin-left: 10px;
            /* Small gap from logo */
            flex-grow: 0;
            flex-shrink: 0;
        }

        /* This combination (Logo growing) + Space-between on container 
           might not force wrap if nav is Order 3. 
           We need a "break" or max-width constraint. 
           ACTUALLY: Giving Logo flex-grow: 1 makes it eat space.
           But Nav (Order 3) will only wrap if there is NO space.
           So we must ensure Logo + Theme > 100%? No, close to 100%. */
    }

    /* Better Strategy for Tablet Wrap: Force a "Break" element logic via width */
    @media (min-width: 768px) and (max-width: 1100px) {
        .logo {
            width: 70%;
            flex: 1 0 70%;
        }

        #theme-toggle {
            width: auto;
            flex: 0 0 auto;
            justify-content: flex-end;
        }

        /* Now Logo (70%) + Theme (20%+) ~ 90-100%. 
           Nav (Order 3) will have no room and MUST wrap. */
    }

    #theme-toggle {
        order: 2;
        padding: 6px 12px;
        font-size: 0.8em;
        margin-left: auto;
        position: static;
        top: auto;
        right: auto;
        white-space: nowrap;
        flex-shrink: 0;
        display: block;
    }

    .main-nav {
        order: 3;
        width: auto;
        flex: 1;
        /* Allow sharing row with hamburger */
        display: flex;
        flex-direction: row;
        gap: 8px;
        justify-content: flex-end;
        /* Align to right next to hamburger */
        padding: 0;
        min-width: unset;
        margin: 10px 0 0 0;
    }

    .main-nav a {
        display: none;
        /* Hide all by default in header */
        font-size: 0.75em;
        padding: 6px 8px;
        background: rgba(255, 255, 255, 0.15);
        border-radius: 8px;
        flex: 1;
        text-align: center;
        white-space: nowrap;
    }

    /* TIERED VISIBILITY: Header Buttons (Tablet & Mobile) */
    /* Large Tablets (835px - 1100px) - Default Visibility */
    .main-nav a:nth-child(1),
    .main-nav a:nth-child(2),
    .main-nav a:nth-child(3),
    .main-nav a:nth-child(4),
    .main-nav a:nth-child(5) {
        display: block;
    }

    /* Range: 769px - 834px (iPad/Tablet) */
    @media (max-width: 834px) {

        /* Non-Home Pages: Hide Home(1), Show Papers(2), Favs(3), History(4), Ads(5) */
        body:not(.home-page) .main-nav a:nth-child(1) {
            display: none !important;
        }

        body:not(.home-page) .main-nav a:nth-child(4) {
            display: block !important;
        }

        /* Home Page: 1, 2, 3, 5 are shown (at <950 History-4 is hidden by the rule below) */
    }

    /* Default Tiering for 769px - 950px Range (Mostly for Home Page) */
    @media (max-width: 950px) {
        body.home-page .main-nav a:nth-child(4) {
            display: none !important;
        }
    }

    /* Mobile (max-width: 768px) */
    @media (max-width: 768px) {

        /* Default: Hide 3 & 4 (shown in menu) */
        .main-nav a:nth-child(3),
        .main-nav a:nth-child(4) {
            display: none !important;
        }

        /* Non-Home Pages: Hide Home(1), Show Papers(2), Favs(3), Ads(5) */
        body:not(.home-page) .main-nav a:nth-child(1) {
            display: none !important;
        }

        body:not(.home-page) .main-nav a:nth-child(3) {
            display: block !important;
        }

        /* STRICT FIX: Ensure History(4) stays hidden even on non-home pages for mobile */
        body:not(.home-page) .main-nav a:nth-child(4) {
            display: none !important;
        }
    }

    /* Hide 6,7,8 from header ALWAYS on tablets/mobile */
    .main-nav a:nth-child(6),
    .main-nav a:nth-child(7),
    .main-nav a:nth-child(8) {
        display: none !important;
    }

    .hamburger-btn {
        display: none !important;
        /* Hidden by default */
        order: 4;
        position: static;
        flex-direction: column;
        gap: 5px;
        background: rgba(255, 255, 255, 0.2);
        border: 2px solid white;
        border-radius: 5px;
        cursor: pointer;
        padding: 8px;
        z-index: 1001;
        width: 35px;
        height: 35px;
        justify-content: center;
        align-items: center;
        margin: 0;
        flex-shrink: 0;
    }

    /* Show hamburger on tablets and mobile */
    .hamburger-btn {
        display: flex !important;
    }

    .hamburger-btn span {
        display: block !important;
        width: 22px;
        height: 3px;
        background: white !important;
        border-radius: 3px;
        transition: all 0.3s ease;
    }

    .hamburger-btn.active {
        background: rgb(245, 65, 65);
    }

    .hamburger-btn.active span:nth-child(1) {
        transform: rotate(45deg) translate(6px, 4px);
    }

    .hamburger-btn.active span:nth-child(2) {
        opacity: 0;
    }

    .hamburger-btn.active span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }

    #search-bar {
        order: 5;
        width: 100% !important;
        max-width: 100% !important;
        margin: 10px 0 0 0;
    }

    .main-nav.mobile-active {
        position: absolute;
        top: 65px;
        right: 15px;
        width: 200px;
        height: auto;
        background: var(--card-bg);
        flex-direction: column;
        padding: 10px 0;
        border-radius: 8px;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
        z-index: 1002;
        display: flex;
        justify-content: flex-start;
        align-items: stretch;
        border: 1px solid var(--border-color);
    }

    .main-nav.mobile-active a {
        display: block;
        padding: 1.5rem 1.2rem !important;
        /* Force override padding */
        border-bottom: 1px solid var(--border-color);
        color: var(--main-text-color);
        font-size: 0.9em;
        background: none;
        text-align: left;
        flex: none;
    }

    .main-nav.mobile-active a:last-child {
        border-bottom: none;
    }

    /* Mobile Menu visibility logic */
    .main-nav.mobile-active a {
        display: none !important;
        /* Hide all by default */
    }

    /* Always show Home (1) in menu IF we are on an internal page */
    body:not(.home-page) .main-nav.mobile-active a:nth-child(1) {
        display: block !important;
    }

    /* Base items always in menu: 6, 7, 8 */
    .main-nav.mobile-active a:nth-child(6),
    .main-nav.mobile-active a:nth-child(7),
    .main-nav.mobile-active a:nth-child(8) {
        display: block !important;
    }

    /* History (4) goes to menu IF it's hidden from header (Home Page < 950) */
    @media (max-width: 950px) {
        body.home-page .main-nav.mobile-active a:nth-child(4) {
            display: block !important;
        }
    }

    /* Mobile Range (<768px) */
    @media (max-width: 768px) {

        /* Home Page: Add Favs(3) and History(4) to menu */
        body.home-page .main-nav.mobile-active a:nth-child(3) {
            display: block !important;
        }

        body.home-page .main-nav.mobile-active a:nth-child(4) {
            display: block !important;
        }

        /* Other Pages: Add History(4) to menu (since 2,3,5 are in header) */
        body:not(.home-page) .main-nav.mobile-active a:nth-child(4) {
            display: block !important;
        }
    }

    .main-nav.mobile-active a:hover,
    .main-nav.mobile-active a.active-link {
        background: var(--primary-color) !important;
        color: white !important;
        border-right-color: var(--accent-color);
    }

    .main-nav.mobile-active a.active-link::after {
        display: none;
    }

    .menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(0, 0, 0, 0.6);
        z-index: 998;
    }

    .menu-overlay.active {
        display: block;
    }

    body.dark-mode .main-nav.mobile-active {
        background: #1e293b;
        box-shadow: -2px 0 15px rgba(255, 255, 255, 0.1);
    }

    body.dark-mode .main-nav.mobile-active a {
        color: #f0f0f0;
    }

    body.dark-mode .hamburger-btn span {
        background: white;
    }

    #year-filter {
        width: 100%;
        max-width: 100%;
        margin-bottom: 10px;
        margin-right: 0 !important;
    }

    .container {
        padding: 0 20px;
        max-width: 100%;
    }

    .page-title {
        display: none !important;
    }


    .filter-section {
        padding: 10px 0 !important;
        margin-bottom: 10px !important;
    }

    .main-nav {
        margin: 0 !important;
    }

    #search-bar {
        margin-top: 8px !important;
    }

    /* MOBILE HEADER FIX: Ensure 2 rows on all small screens (prevent menu wrap) */
    @media (max-width: 767px) {
        .header-content {
            display: flex !important;
            flex-wrap: wrap !important;
            justify-content: space-between !important;
            align-items: center !important;
            gap: 0 !important;
        }

        .logo {
            flex: 1 1 60% !important;
            order: 1 !important;
            margin-bottom: 0 !important;
            text-align: left;
        }

        #theme-toggle {
            flex: 0 0 auto !important;
            order: 2 !important;
            margin-left: auto !important;
            display: block !important;
        }

        .main-nav {
            flex: 1 1 auto !important;
            order: 3 !important;
            display: flex !important;
            justify-content: flex-start !important;
            margin-top: 15px !important;
            width: auto !important;
            gap: 5px !important;
        }

        .hamburger-btn {
            flex: 0 0 auto !important;
            order: 4 !important;
            margin-top: 15px !important;
            margin-left: 8px !important;
            display: flex !important;
        }

        /* Mobile Screen Compression (Starting at 550px) */
        @media (max-width: 550px) {
            .main-nav {
                gap: 3px !important;
            }

            .main-nav a {
                padding: 6px 4px !important;
                font-size: 0.72em !important;
                letter-spacing: -0.2px;
            }

            .header-content {
                padding: 10px 8px !important;
            }

            .hamburger-btn {
                margin-left: 5px !important;
                width: 32px !important;
                height: 32px !important;
            }
        }

        /* Micro-Screen Optimization (< 420px) - Extreme Compression */
        @media (max-width: 420px) {
            .logo {
                font-size: 1.05em !important;
            }

            .main-nav {
                gap: 2px !important;
            }

            .main-nav a {
                padding: 5px 2px !important;
                font-size: 0.68em !important;
                flex: 1 1 auto !important;
                min-width: 0 !important;
            }

            .header-content {
                padding: 10px 5px !important;
            }

            .hamburger-btn {
                padding: 6px !important;
                width: 30px !important;
                height: 30px !important;
            }
        }
    }

    #search-bar {
        order: 5;
        width: 100% !important;
        max-width: 100% !important;
        margin: 10px 0 0 0;
    }

    .action-btn {
        font-size: 0.75em;
        padding: 10px 6px;
    }

    .details-buttons {
        gap: 8px !important;
    }

    #papers-container {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 20px;
        padding: 10px 10px 40px 10px;
    }

    .secondary-filters {
        width: 100%;
        flex-direction: row;
        align-items: center;
        gap: 10px;
        margin-bottom: 0;
    }

    .secondary-filters label {
        font-size: 0.85em;
        margin-bottom: 0;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .filter-input {
        flex-grow: 1;
        margin-bottom: 0;
    }

    .year-separator {
        font-size: 1.1em !important;
        margin-top: 0.5rem !important;
        margin-bottom: 0.5rem !important;
        padding-bottom: 3px !important;
        color: var(--year-separator-color) !important;
    }

    .filter-btn {
        flex: 0 0 calc(33.333% - 7px);
        max-width: calc(33.333% - 7px);
        min-height: 34px;
        font-size: 0.7rem;
        padding: 4px 4px;
        text-align: center;
        white-space: normal;
        word-break: break-all;
        /* More aggressive for very tight spaces */
        overflow-wrap: break-word;
        line-height: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Tablet Filter Buttons Fix: 834px - 1024px */
@media (min-width: 834px) and (max-width: 1100px) {
    .filter-buttons {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 10px !important;
        justify-content: center !important;
    }

    .filter-btn {
        flex: 0 0 calc(25% - 8px) !important;
        max-width: calc(25% - 8px) !important;
        padding: 8px 4px !important;
        font-size: 0.82em !important;
        min-height: 40px !important;
    }

    /* Order for Row 1 */
    .filter-btn[data-filter="all"] {
        order: 1 !important;
    }

    .filter-btn[data-filter="O/L"] {
        order: 2 !important;
    }

    .filter-btn[data-filter="A/L"] {
        order: 3 !important;
    }

    .filter-btn[data-filter="Arts"] {
        order: 4 !important;
    }

    /* Order for Row 2 */
    .filter-btn[data-filter="Mathematics"] {
        order: 5 !important;
    }

    .filter-btn[data-filter="Science"] {
        order: 6 !important;
    }

    .filter-btn[data-filter="Technology"] {
        order: 7 !important;
    }

    .filter-btn[data-filter="Commerce"] {
        order: 8 !important;
    }
}

/* Year Filter Width Fix: 768px - 1024px */
@media (min-width: 500px) and (max-width: 1100px) {
    #year-filter {
        width: auto !important;
        max-width: 250px !important;
        /* Limit width to prevent overflow */
        margin-bottom: 0 !important;
        /* Align with label better if in row */
    }

    .secondary-filters {
        width: auto !important;
        flex-wrap: nowrap !important;
    }
}

/* Extra small devices (iPhone SE, etc.) */
@media (max-width: 360px) {
    .filter-btn {
        flex: 0 0 calc(50% - 6px);
        max-width: calc(50% - 6px);
        font-size: 0.75em;
        padding: 8px 6px;
    }
}

.tamil-slogan {
    font-size: 0.78rem;
    text-align: left;
    padding-left: 0;
}

.tamil-slogan br.desktop-break {
    display: none;
}

.hero-section {
    padding: 40px 15px;
}

.hero-section .page-title {
    font-size: 2.2em;
}

.hero-section .tagline {
    font-size: 1em;
}

/* ================================================================= */
/* Tablets 834px - 1024px: Menu Button in Row 2 with Nav */
/* ================================================================= */
@media (min-width: 834px) and (max-width: 1100px) {
    .header-content {
        justify-content: flex-start !important;
        gap: 0px !important;
        /* Remove gaps to avoid rounding errors */
    }

    #theme-toggle {
        margin-left: auto !important;
    }

    .main-nav {
        order: 3 !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
        width: auto !important;
        max-width: calc(100% - 65px) !important;
        /* Safety room for 42px button + 15px margin + buffer */
        margin-top: 8px !important;
        display: flex !important;
        flex-wrap: nowrap !important;
        margin-left: 0 !important;
    }

    .main-nav a {
        font-size: 1em !important;
        padding: 10px 15px !important;
        flex-shrink: 0;
    }

    .hamburger-btn {
        order: 3 !important;
        margin-top: 8px !important;
        margin-left: 15px !important;
        flex: 0 0 42px !important;
        /* Strictly lock the width */
        width: 42px !important;
        height: 42px !important;
        padding: 10px !important;
    }

    .main-nav a:nth-child(4) {
        display: block !important;
    }

    .main-nav.mobile-active a:nth-child(4) {
        display: none !important;
    }

    #search-bar {
        order: 5 !important;
        flex: 0 0 100% !important;
        /* Force to take full row and push to Row 3 */
        margin-top: 15px !important;
        width: 100% !important;
        max-width: 100% !important;
    }
}

@media (max-width: 480px) {
    body {
        overflow-x: hidden !important;
    }

    .logo {
        font-size: 2em;
    }

    #theme-toggle {
        padding: 6px 6px;
        font-size: 0.85em;
    }

    #year-filter,
    #search-bar {
        padding: 8px 12px;
        font-size: 0.9em;
        width: 100%;
        max-width: 52%;
    }

    .container {
        padding: 0 10px;
    }

    .header-content {
        gap: 4px;
    }

    #papers-container {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 10px 5px 30px 5px;
    }
}

@media (max-width: 400px) {
    .action-btn {
        font-size: 0.7em;
        padding: 8px 4px;
        line-height: 1.3;
    }
}

@media (max-width: 360px) {
    .header-content {
        gap: 3px !important;
        padding: 8px 8px !important;
    }

    .logo {
        font-size: 1.3em !important;
        margin-right: 5px !important;
    }

    .main-nav a {
        font-size: 0.65em !important;
        padding: 4px 5px !important;
    }

    #theme-toggle {
        padding: 4px 6px !important;
        font-size: 0.7em !important;
    }

    .hamburger-btn {
        width: 28px !important;
        height: 28px !important;
        padding: 5px !important;
    }

    .hamburger-btn span {
        width: 16px !important;
        height: 2px !important;
    }
}

/* ================================================================= */
/* Paper List & Filters */
/* ================================================================= */
.filter-section {
    padding: 20px 0;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
}

.secondary-filters {
    display: flex;
    align-items: center;
    gap: 10px;
}

.secondary-filters label {
    font-weight: 600;
    color: var(--main-text-color);
    white-space: nowrap;
}

.filter-input {
    padding: 8px 15px;
    border: 2px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.95em;
    background-color: var(--bg-color);
    color: var(--main-text-color);
    transition: all 0.3s;
}

.filter-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 8px rgba(20, 184, 166, 0.3);
    outline: none;
}

.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    flex-grow: 1;
    justify-content: flex-start;
}

.filter-btn {
    background-color: var(--bg-color);
    color: var(--secondary-text-color);
    border: 2px solid var(--border-color);
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
    white-space: nowrap;
}

.filter-btn:hover {
    background-color: var(--border-color);
    color: var(--main-text-color);
    transform: translateY(-2px);
}

.filter-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

#papers-container,
#favorites-container,
#history-container {
    display: grid;
    grid-template-columns: 1fr;
    /* Mobile: 1 column */
    gap: 20px;
    padding-top: 20px;
    padding-bottom: 50px;
    width: 100%;
}

/* Tablet: 2 columns */
@media (min-width: 600px) {

    #papers-container,
    #favorites-container,
    #history-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 25px;
    }
}

/* Desktop: 4 columns */
@media (min-width: 992px) {

    #papers-container,
    #favorites-container,
    #history-container {
        grid-template-columns: repeat(4, 1fr);
        gap: 25px;
    }
}

.paper-card,
.history-item {
    background-color: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-color);
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s, background-color 0.3s;
    border: 2px solid transparent;
}

.history-item {
    border-left: 4px solid var(--primary-color);
}

.paper-card:hover,
.history-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px var(--shadow-color);
    border-color: var(--accent-color);
}

.paper-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.paper-card h3 {
    font-size: 1.2em;
    margin: 0;
    font-weight: 600;
}

.paper-year {
    font-weight: 500;
    color: var(--secondary-text-color);
    font-size: 0.9em;
    margin-top: 5px;
}

.paper-grade {
    font-size: 0.8em;
    padding: 5px 10px;
    border-radius: 6px;
    font-weight: 700;
}

.paper-grade.grade-al {
    background-color: #007bff;
    color: white;
}

.paper-grade.grade-ol {
    background-color: var(--ol-badge-color);
    color: white;
}

body.dark-mode .paper-grade.grade-al {
    background-color: #007bff;
    color: white;
}

body.dark-mode .paper-grade.grade-ol {
    background-color: #34d399;
    color: white;
}

body.dark-mode .filter-btn {
    background-color: #334155;
    border-color: #475569;
    color: var(--main-text-color);
}

body.dark-mode .filter-btn:hover,
body.dark-mode .filter-btn.active {
    background-color: var(--accent-color);
    color: #0f172a;
    border-color: var(--accent-color);
}

body.dark-mode .paper-card {
    border: 2px solid #334155;
}

body.dark-mode .paper-card:hover {
    border-color: var(--accent-color);
}

body.dark-mode .filter-input {
    background-color: #334155;
    border-color: #475569;
}

/* ================================================================= */
/* Modals */
/* ================================================================= */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
}

.modal-content {
    background-color: var(--card-bg);
    margin: 10% auto;
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 40px var(--shadow-color);
    position: relative;
    animation-name: animatetop;
    animation-duration: 0.4s;
    border: 2px solid var(--border-color);
}

@keyframes animatetop {
    from {
        top: -300px;
        opacity: 0
    }

    to {
        top: 0;
        opacity: 1
    }
}

.close-btn {
    color: var(--secondary-text-color);
    float: right;
    font-size: 30px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover,
.close-btn:focus {
    color: var(--danger-color);
    text-decoration: none;
}

#modal-info p {
    margin: 8px 0;
    font-size: 0.95em;
}

#modal-info strong {
    color: var(--primary-color);
    font-weight: 600;
}

body.dark-mode .modal-content {
    background-color: #1e293b;
    border: 2px solid #334155;
}

body.dark-mode .btn-paper:hover {
    background-color: var(--primary-color);
    color: white;
}

body.dark-mode .btn-scheme:hover {
    background-color: var(--success-color);
    color: white;
}

body.dark-mode .btn-preview:hover {
    background-color: var(--accent-color);
    color: white;
}

/* ================================================================= */
/* About & Contact Pages */
/* ================================================================= */
.about-section {
    margin-bottom: 30px;
    padding: 25px;
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow-color);
    transition: background-color 0.3s, box-shadow 0.3s;
    border-left: 4px solid var(--primary-color);
}

.about-section:first-of-type {
    margin-top: 40px;
}

.about-section h2 {
    color: var(--primary-color);
    border-bottom: 3px solid var(--accent-color);
    padding-bottom: 8px;
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.8em;
}

.feature-list {
    list-style: none;
    padding-left: 0;
}

.feature-list li {
    padding: 12px 0;
    font-size: 1em;
    border-bottom: 1px dashed var(--border-color);
}

.feature-list li:last-child {
    border-bottom: none;
}

.footer-note {
    text-align: center;
    padding: 25px;
    margin-top: 40px;
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--secondary-text-color);
    font-size: 0.95em;
}

.contact-form-container {
    max-width: 650px;
    margin: 40px auto;
    padding: 40px;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 4px 20px var(--shadow-color);
    border: 2px solid var(--border-color);
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--primary-color);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    background-color: var(--bg-color);
    color: var(--main-text-color);
    transition: all 0.3s;
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 8px rgba(20, 184, 166, 0.3);
    outline: none;
}

#form-message {
    margin-top: 25px;
    padding: 15px;
    background-color: var(--success-color);
    color: white;
    border-radius: 8px;
    display: none;
    text-align: center;
    font-weight: 600;
}

.submit-btn {
    display: block;
    width: 100%;
    padding: 15px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.2em;
    cursor: pointer;
    font-weight: 700;
    transition: background-color 0.3s, transform 0.1s;
}

.submit-btn:hover {
    background-color: #0f9f8d;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
}

/* ==================== Future Page Classes ==================== */
.future-intro {
    text-align: center;
    font-size: 1.2em;
    color: var(--secondary-text-color);
    margin-bottom: 40px;
}

.future-description {
    font-size: 1.05em;
    line-height: 1.8;
}

.future-highlight {
    margin-top: 30px;
    padding: 20px;
    border-left: 4px solid var(--accent-color);
    border-radius: 8px;
}

.future-highlight-title {
    color: var(--accent-color);
    font-size: 1.2em;
    margin-bottom: 15px;
}

.future-step {
    margin-bottom: 20px;
}

.future-step-title {
    color: var(--primary-color);
    font-size: 1.05em;
    margin-bottom: 8px;
}

.future-step-text {
    padding-left: 20px;
}

/* Additional Future Page Variations */
.future-highlight-success {
    margin-top: 30px;
    padding: 20px;
    border-left: 4px solid var(--success-color);
    border-radius: 8px;
}

.future-highlight-success-title {
    color: var(--success-color);
    font-size: 1.2em;
    margin-bottom: 15px;
}

.future-step-mb15 {
    margin-bottom: 15px;
}

.future-step-mb25 {
    margin-bottom: 25px;
}

.future-highlight-primary {
    margin-top: 30px;
    padding: 25px;
    border-left: 4px solid var(--primary-color);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.future-highlight-primary-title {
    color: var(--primary-color);
    font-size: 1.3em;
    margin-bottom: 20px;
}

.future-step-title-lg {
    color: var(--accent-color);
    font-size: 1.1em;
    margin-bottom: 10px;
}

.future-step-text-sm {
    padding-left: 10px;
}

.future-free-box {
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 8px;
    border: 1px dashed var(--success-color);
}

.future-free-title {
    color: var(--success-color);
    font-size: 1.1em;
    margin-bottom: 8px;
}

.future-cta-box {
    margin-top: 25px;
    padding: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    text-align: center;
}

.future-cta-text {
    font-weight: 600;
    color: var(--primary-color);
}

.future-highlight-danger {
    margin-top: 30px;
    padding: 20px;
    border-left: 4px solid var(--danger-color);
    border-radius: 8px;
}

.future-highlight-danger-title {
    color: var(--danger-color);
    font-size: 1.2em;
    margin-bottom: 15px;
}

/* Future Page - FAQ Section */
.future-faq-container {
    font-size: 1.05em;
    line-height: 1.8;
}

.future-faq-text {
    margin-bottom: 15px;
}

.future-faq-list {
    margin-left: 20px;
    margin-bottom: 20px;
}

.future-faq-list-simple {
    margin-left: 20px;
}

/* Future Page - Timeline Section */
.future-timeline-box {
    background: var(--card-bg);
    padding: 40px 30px;
    border-radius: 16px;
    text-align: center;
    margin-top: 50px;
    color: var(--main-text-color);
    box-shadow: 0 8px 24px var(--shadow-color);
    border: 2px solid var(--border-color);
}

.future-timeline-title {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.8em;
}

.future-timeline-text {
    font-size: 1.2em;
    margin-bottom: 20px;
    line-height: 1.8;
}

.future-timeline-note {
    font-size: 1.15em;
    margin-bottom: 0;
    opacity: 0.95;
    color: var(--secondary-text-color);
}

.future-footer-note {
    font-size: 1.05em;
    padding: 30px;
}

/* Future Page Dark Mode Overrides */
body.dark-mode .future-cta-box {
    background: var(--card-bg) !important;
    border-color: var(--border-color) !important;
}

body.dark-mode .future-timeline-box {
    background: var(--card-bg) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4) !important;
    border: 1px solid var(--border-color) !important;
}




/* ==================== Contact Page Classes ==================== */
.contact-select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    background-color: var(--bg-color);
    color: var(--main-text-color);
}

.rating-group-hidden {
    display: none;
}

.submit-btn:hover {
    background-color: #0f9f8d;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
}

body.dark-mode .contact-form-container {
    border: 2px solid #334155;
}

body.dark-mode .form-group input,
body.dark-mode .form-group textarea {
    background-color: #0f172a;
    border-color: #334155;
}

/* Contact Form Stars */
.star {
    cursor: pointer;
    opacity: 0.3;
    transition: all 0.3s ease;
    display: inline-block;
}

.star:hover {
    transform: scale(1.2);
}

.stars-container {
    display: flex;
    gap: 10px;
    font-size: 2em;
    margin-top: 10px;
}

/* Disabled field styling */
.field-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    background-color: #f0f0f0;
}

body.dark-mode .field-disabled {
    background-color: #1a1a1a;
}

/* Wrapper to catch clicks on disabled fields */
.field-wrapper {
    position: relative;
}

.field-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    cursor: not-allowed;
}

.field-overlay.hidden {
    display: none;
}

/* File Upload Styles */
.file-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    background: var(--bg-color);
    transition: all 0.3s;
    cursor: pointer;
    margin-top: 10px;
}

.file-upload-area.collapsed {
    padding: 12px;
}

.file-upload-area.expanded {
    padding: 30px;
}

.file-upload-area:hover {
    border-color: var(--accent-color);
    background: rgba(20, 184, 166, 0.05);
}

.file-upload-area.dragover {
    border-color: var(--accent-color);
    background: rgba(20, 184, 166, 0.1);
    transform: scale(1.02);
}

.upload-icon {
    font-size: 2em;
    color: var(--accent-color);
    margin-bottom: 5px;
    transition: all 0.3s;
}

.file-upload-area.expanded .upload-icon {
    font-size: 3em;
    margin-bottom: 10px;
}

.upload-text-collapsed {
    display: block;
    font-size: 0.95em;
    color: var(--primary-color);
    font-weight: 600;
}

.upload-text-expanded {
    display: none;
}

.file-upload-area.expanded .upload-text-collapsed {
    display: none;
}

.file-upload-area.expanded .upload-text-expanded {
    display: block;
}

#file-input {
    display: none;
}

.file-list {
    margin-top: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9em;
}

.file-item-icon {
    font-size: 1.2em;
}

.file-item-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-item-size {
    color: var(--secondary-text-color);
    font-size: 0.85em;
}

.file-remove-btn {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 0.8em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.file-remove-btn:hover {
    transform: scale(1.2);
}

.file-info {
    font-size: 0.85em;
    color: var(--secondary-text-color);
    margin-top: 10px;
}

/* ================================================================= */
/* Footer */
/* ================================================================= */
.main-footer {
    background-color: var(--footer-bg);
    color: #cbd5e1;
    text-align: center;
    padding: 25px 0;
    font-size: 0.9em;
    border-top: 4px solid var(--primary-color);
    margin-top: auto;
}

.main-footer a {
    color: #fff;
    font-weight: 500;
}

.main-footer a:hover {
    color: var(--accent-color);
}

.footer-links {
    margin: 4px 0;
}

.footer-links a {
    margin: 0 12px;
    font-weight: 500;
}

.footer-disclaimer {
    font-size: 0.85em;
    opacity: 0.8;
    margin-top: 4px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.4;
}

/* ================================================================= */
/* Home Page Styles */
/* ================================================================= */
.hero-section {
    background: linear-gradient(135deg, var(--primary-color), #4f46e5);
    padding: 60px 20px;
    margin-top: 20px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 8px 24px var(--shadow-color);
    transition: background-color 0.3s;
}

.hero-section .page-title {
    font-size: 3em;
    font-weight: 800;
    color: white;
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: none;
    padding-bottom: 0;
}

.hero-section .tagline {
    font-size: 1.3em;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 30px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.hero-section .cta-button {
    display: inline-block;
    padding: 15px 30px;
    background-color: var(--accent-color);
    color: white;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 700;
    transition: background-color 0.3s, transform 0.2s;
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
}

.hero-section .cta-button:hover {
    background-color: #0f9f8d;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(20, 184, 166, 0.4);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    margin-top: 50px;
    padding-bottom: 50px;
}

.feature-card {
    background-color: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow-color);
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s;
    border-bottom: 4px solid var(--primary-color);
}

.feature-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px var(--shadow-color);
    border-bottom-color: var(--accent-color);
}

.feature-icon {
    font-size: 3em;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.feature-card h3 {
    font-size: 1.3em;
    margin-bottom: 10px;
    color: var(--primary-color);
}

body.dark-mode .hero-section {
    background: linear-gradient(135deg, #1e293b, #334155);
}

body.dark-mode .hero-section .page-title {
    color: white;
}

body.dark-mode .hero-section .tagline {
    color: rgba(255, 255, 255, 0.85);
}

/* ================================================================= */
/* Favorites & History Pages */
/* ================================================================= */
.cta-button {
    display: inline-block;
    padding: 15px 30px;
    background-color: var(--accent-color);
    color: white;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 700;
    text-decoration: none;
    transition: background-color 0.3s, transform 0.2s;
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
}

.cta-button:hover {
    background-color: #0f9f8d;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(20, 184, 166, 0.4);
}

.fav-btn:hover {
    transform: scale(1.2);
}

.fav-btn:active {
    transform: scale(0.9);
}

.remove-fav-btn:hover {
    background: #dc2626 !important;
    transform: scale(1.05);
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--secondary-text-color);
    width: 100%;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.clear-btn {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    margin-top: 2rem;
    transition: all 0.3s;
}

.clear-btn:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}


.history-item-time {
    color: var(--secondary-text-color);
    font-size: 0.85em;
    margin-top: 0.5rem;
}

/* ================================================================= */
/* Tamil Slogan */
/* ================================================================= */
.tamil-slogan {
    font-size: 1rem;
    line-height: 1.5;
    font-weight: 600;
    margin: 20px 0;
}

/* Desktop view (≥769px) */
@media (min-width: 869px) {
    .tamil-slogan {
        text-align: center;
    }

    .tamil-slogan br {
        display: none;
    }

    .tamil-slogan br.desktop-break {
        display: block;
    }

    .header-content {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 25px 0;
        /* Fixed typo -10px */
        flex-wrap: wrap;
        gap: 20px;
    }

    .logo {
        order: 1;
        margin: 0;
    }

    /* Pull theme toggle to the right on the first row */
    #theme-toggle {
        order: 2;
        margin-left: auto;
        display: block;
    }

    .main-nav {
        order: 3;
        width: 100%;
        flex: 1 1 100%;
        /* Force 100% width to ensure wrap */
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 20px;
        /* Reduced from 40px for better fit */
        margin: 15px 0 5px 0;
    }

    .main-nav a {
        white-space: nowrap;
        text-align: center;
        font-size: 0.95em;
        font-weight: 600;
        display: block;
    }

    /* Removed Conflicting Adaptive Links rule - handled in main media query (Line 493+) */

    #search-bar {
        order: 4;
        width: 100%;
        max-width: 500px;
        margin: 10px auto 0 auto;
    }
}

/* ================================================================= */
/* Utilities */
/* ================================================================= */
#loading-message {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

::selection {
    background-color: var(--accent-color);
    color: white;
}

::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

.main-content {
    min-height: calc(100vh - 200px);
    padding: 20px 0;
}

.papers-list {
    min-height: 300px;
}

/* Error Message for Forms */
.error-message {
    color: #ef4444;
    font-size: 0.85rem;
    margin-top: 5px;
    display: none;
    font-weight: 500;
}

.error-border {
    border-color: #ef4444 !important;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.2) !important;
}

/* Toast Notification System */
.toast-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background-color: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toast-in 0.3s ease-out, toast-out 0.3s ease-in 2.7s forwards;
    pointer-events: auto;
    max-width: 90vw;
    text-align: center;
}

.toast-warning {
    background-color: #f59e0b;
    color: #000;
}

.toast-error {
    background-color: #ef4444;
}

.toast-success {
    background-color: #22c55e;
}

@keyframes toast-in {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

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

@keyframes toast-out {
    from {
        transform: translateY(0);
        opacity: 1;
    }

    to {
        transform: translateY(20px);
        opacity: 0;
    }
}

/* ==================== Ads Page Styles ==================== */
.showcase-container {
    padding-top: 40px;
    padding-bottom: 80px;
}

.showcase-header {
    text-align: center;
    margin-bottom: 50px;
}

.showcase-header h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.showcase-header p {
    color: var(--light-text);
    font-size: 1.1rem;
}

.filter-tabs {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

@media (max-width: 600px) {
    .filter-tabs {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 0 5px;
    }

    .filter-tab {
        padding: 10px 5px !important;
        width: 100%;
        font-size: 0.85rem;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
    }


    .showcase-header h1 {
        font-size: 1.8rem !important;
        word-break: break-word;
    }

    .showcase-header p {
        font-size: 0.9rem;
    }
}

.filter-tab {
    padding: 10px 25px;
    border-radius: 30px;
    border: 2px solid var(--border-color);
    background: var(--card-bg);
    color: var(--main-text-color);
    cursor: pointer;
    font-weight: 700;
    transition: 0.3s;
}

.filter-tab.active,
.filter-tab:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.ad-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 30px;
}

.ad-card {
    background: var(--card-bg);
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    position: relative;
}

.ad-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

.ad-image-box {
    position: relative;
    height: 220px;
    overflow: hidden;
    background-color: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dark-mode .ad-image-box {
    background-color: #0f172a;
}

.ad-image-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: 0.5s;
}

.ad-card:hover .ad-image-box img {
    transform: scale(1.1);
}

.ad-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    background: var(--accent-color);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    z-index: 2;
}

.ad-content {
    padding: 25px;
}

.ad-category {
    display: inline-block;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.ad-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 12px;
    line-height: 1.4;
}

.ad-description {
    color: var(--secondary-text-color);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 20px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ad-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.ads-cta-section {
    text-align: center;
    margin-top: 60px;
    padding: 50px 20px;
    background: var(--card-bg);
    border-radius: 24px;
    border: 2px dashed var(--border-color);
    box-shadow: 0 4px 15px var(--shadow-color);
}

.ads-cta-section p {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 30px;
    color: var(--main-text-color);
}


.ad-date {
    font-size: 0.85rem;
    color: var(--secondary-text-color);
}

.ad-contact-btn {
    color: var(--primary-color);
    font-weight: 700;
    text-decoration: none;
    font-size: 0.95rem;
    transition: 0.3s;
}

.ad-contact-btn:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

.book-btn {
    background-color: var(--primary-color);
    color: white;
    padding: 12px 25px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 700;
    transition: 0.3s;
}

.book-btn:hover {
    background-color: var(--secondary-color);
    transform: scale(1.05);
}

.ad-modal {
    display: none;
    position: fixed;
    z-index: 10001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.4s ease;
}

.ad-modal-content {
    background-color: var(--card-bg);
    margin: 5% auto;
    padding: 0;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 800px;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #fff;
    background: rgba(0, 0, 0, 0.4);
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    font-weight: bold;
    z-index: 5;
    transition: 0.3s;
}

.modal-close:hover {
    background: var(--danger-color);
}

.modal-body {
    display: flex;
    flex-direction: column;
    background-color: var(--card-bg);
}

.modal-image-container {
    width: 100%;
    background-color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    max-height: 80vh;
    overflow: hidden;
}

.modal-image {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    display: block;
}

.modal-info {
    padding: 30px;
}

.modal-title {
    font-size: 1.8rem;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.modal-full-description {
    line-height: 1.8;
    color: var(--main-text-color);
    margin-bottom: 25px;
}

.modal-actions {
    display: flex;
    gap: 15px;
    border-top: 1px solid var(--border-color);
    padding-top: 25px;
    justify-content: center;
    /* Center the button */
}

.whatsapp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background-color: #25D366;
    /* WhatsApp Green */
    color: white;
    text-decoration: none;
    padding: 12px 25px;
    border-radius: 30px;
    /* Pill shape */
    font-weight: 700;
    font-size: 1rem;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 4px 10px rgba(37, 211, 102, 0.3);
}

.whatsapp-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(37, 211, 102, 0.4);
    color: white;
    /* Ensure text remains white */
}


#maintenance-info {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--card-bg);
    border: 2px solid var(--danger-color);
    padding: 20px;
    border-radius: 12px;
    z-index: 10002;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 300px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@media (max-width: 600px) {
    .ad-modal-content {
        margin: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        overflow-y: auto;
        /* Allow scrolling within the modal content */
    }

    .modal-image {
        height: 250px;
    }

    .ad-grid {
        grid-template-columns: 1fr;
    }
}

/* ================================================================= */
/* Loading Spinner */
/* ================================================================= */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    width: 100%;
    grid-column: 1 / -1;
    /* Ensure it spans all columns in grid */
}

.loading-text {
    font-size: 1.2em;
    color: var(--secondary-text-color);
    margin-bottom: 25px;
    font-weight: 500;
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--border-color);
    border-top: 5px solid var(--accent-color);
    border-radius: 50%;
    animation: loader-spin 1s linear infinite;
}

@keyframes loader-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

body.dark-mode .spinner {
    border-color: #334155;
    border-top-color: var(--accent-color);
}

/* ==================== Legal Page Classes ==================== */
.legal-container {
    max-width: 900px;
    margin: 40px auto;
    padding: 0 20px;
}

.legal-section {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px var(--shadow-color);
}

.legal-heading {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.4em;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.legal-text {
    margin-bottom: 15px;
    line-height: 1.8;
}

.legal-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 25px 0;
}

.legal-english {
    font-style: italic;
    font-size: 0.95em;
    color: var(--secondary-text-color);
}

.legal-english-mt {
    font-style: italic;
    font-size: 0.95em;
    margin-top: 15px;
    color: var(--secondary-text-color);
}

/* --- Advanced Feedback System Styles --- */

/* 1. Context Menu */
.custom-context-menu {
    position: fixed;
    z-index: 10000;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: 200px;
    overflow: hidden;
    display: none;
}

.custom-context-menu ul {
    list-style: none;
    margin: 0;
    padding: 5px 0;
}

.custom-context-menu li {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #333;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.custom-context-menu li:hover {
    background: #f0f9ff;
    color: var(--primary-color);
}

.custom-context-menu li.separator {
    height: 1px;
    background: #eee;
    margin: 5px 0;
    padding: 0;
}

/* Dark Mode Context Menu */
body.dark-mode .custom-context-menu {
    background: #2d2d2d;
    border-color: #444;
}

body.dark-mode .custom-context-menu li {
    color: #eee;
}

body.dark-mode .custom-context-menu li:hover {
    background: #444;
}

body.dark-mode .custom-context-menu li.separator {
    background: #444;
}

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

.feedback-modal-content {
    background: #fff;
    width: 90%;
    max-width: 400px;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.feedback-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.feedback-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--primary-color);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
}

.feedback-body textarea {
    width: 100%;
    height: 100px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 10px;
    font-family: inherit;
    resize: vertical;
}

.feedback-meta {
    font-size: 0.75rem;
    color: #999;
    margin-bottom: 15px;
}

#feedback-send-btn {
    width: 100%;
    padding: 10px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

#feedback-send-btn:hover {
    background: var(--secondary-color);
}

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

#feedback-status {
    margin-top: 10px;
    font-size: 0.9rem;
    text-align: center;
}

#feedback-status.success {
    color: #4CAF50;
}

#feedback-status.error {
    color: #ff4757;
}

/* Dark Mode Modal */
body.dark-mode .feedback-modal-content {
    background: #1e1e1e;
    color: #eee;
}

body.dark-mode .feedback-header {
    border-bottom-color: #444;
}

body.dark-mode .feedback-body textarea {
    background: #2d2d2d;
    border-color: #444;
    color: #fff;
}

/* ================================================================= */
/* MOBILE FOOTER FIX (Prevent Word Break) */
/* ================================================================= */
@media (max-width: 600px) {
    .footer-links {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 15px !important;
        align-items: center !important;
    }

    .footer-links a {
        white-space: nowrap !important;
        display: inline-block !important;
        margin: 0 !important;
    }
}

/* ================================================================= */
/* MOBILE FOOTER FIX (Prevent Word Break) */
/* ================================================================= */
@media (max-width: 600px) {
    .footer-links {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 15px !important;
        align-items: center !important;
    }

    .footer-links a {
        white-space: nowrap !important;
        display: inline-block !important;
        margin: 0 !important;
    }
}

/* ================================================================= */
/* TRANSPARENCY BANNER */
/* ================================================================= */
.transparency-banner {
    background-color: #fff3cd;
    color: #856404;
    border-bottom: 1px solid #ffeeba;
    padding: 15px 0;
    position: relative;
    animation: slideDown 0.5s ease-out;
    z-index: 1001;
    /* Ensure it's above other content */
}

.banner-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.banner-icon {
    font-size: 1.5rem;
}

.banner-content p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
    flex: 1;
}

#close-banner {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #856404;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.3s;
}

#close-banner:hover {
    opacity: 1;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

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

/* Dark Mode Support */
body.dark-mode .transparency-banner {
    background-color: #3e2c00;
    color: #ffda6a;
    border-bottom-color: #664d03;
}

body.dark-mode #close-banner {
    color: #ffda6a;
}