/* ===== CSS Variables ===== */
:root {
    --primary-color: #2563EB;
    --primary-hover: #1d4ed8;
    --secondary-color: #475569;
    --accent-color: #38BDF8;
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --border-color: #E5E7EB;
    --bg-light: #F8FAFC;
    --bg-white: #FFFFFF;
    --soft-blue: #EAF0FF;
    --error-color: #ef4444;
    --success-color: #10b981;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --transition: all 0.2s ease;
}

/* ===== Reset & Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-light);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p {
    margin-bottom: 1rem;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-hover);
}

/* ===== Screen Reader Only ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ===== Container ===== */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ===== Header ===== */
.site-header {
    background-color: var(--bg-white);
    box-shadow: var(--shadow-sm);
    position: relative;
    top: 0;
    z-index: 100;
}

.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    padding-top: 1rem;
    padding-bottom: 1rem;
}

.site-title {
    font-size: 1.5rem;
    margin: 0;
    flex-shrink: 0;
}

.site-title a {
    color: var(--primary-color);
    font-weight: 800;
}

.site-nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.site-nav a {
    color: var(--text-secondary);
    font-weight: 500;
    padding: 0.5rem;
    transition: var(--transition);
}

.site-nav a:hover,
.site-nav a.active {
    color: var(--primary-color);
}

/* Auth Button */
.auth-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.auth-button:hover {
    background: var(--bg-light);
    border-color: var(--primary-color);
}

.auth-button img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

/* User Menu Dropdown */
.user-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 1rem;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: 1000;
    overflow: hidden;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.user-menu-item:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

.user-menu-item span {
    font-size: 1.2rem;
}

/* Mobile Nav Toggle */
.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    padding: 0;
    flex-shrink: 0;
}

.site-title {
    margin: 0;
}

.site-nav {
    margin-left: auto;
}

.nav-toggle:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

.nav-toggle:active {
    transform: scale(0.95);
}

.nav-toggle svg {
    width: 24px;
    height: 24px;
    transition: var(--transition);
}

.site-header.nav-open .nav-toggle {
    background: var(--bg-light);
}

.site-header.nav-open .nav-toggle svg {
    transform: rotate(90deg);
}

@media (max-width: 768px) {
    .site-header .container {
        justify-content: center;
        flex-wrap: nowrap;
    }

    .site-title {
        flex: 1;
        text-align: center;
    }

    .nav-toggle {
        display: inline-flex;
        position: absolute;
        right: 1rem;
        top: 50%;
        transform: translateY(-50%);
    }

    .site-nav {
        display: none;
        position: absolute;
        top: calc(100% + 0.75rem);
        right: 1rem;
        min-width: 200px;
        flex-direction: column;
        gap: 0;
        padding: 0.5rem;
        border-radius: 16px;
        background-color: var(--bg-white);
        border: 1px solid var(--border-color);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
        z-index: 200;
        opacity: 0;
        transform: translateY(-8px);
        transition: opacity 0.2s ease, transform 0.2s ease;
    }

    .site-nav a {
        padding: 0.875rem 1rem;
        border-radius: 10px;
        background: transparent;
        font-size: 0.9375rem;
        transition: var(--transition);
    }

    .site-nav a:hover,
    .site-nav a.active {
        background: var(--soft-blue);
        color: var(--primary-color);
    }

    .site-header.nav-open .site-nav {
        display: flex;
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Ad Placeholders ===== */
.ad {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    padding: 2rem;
    margin: 1rem auto;
    border-radius: 8px;
    max-width: 100%;
    font-weight: 600;
}

.ad-top {
    max-width: 728px;
    min-height: 90px;
}

.ad-inline {
    max-width: 300px;
    min-height: 250px;
    margin: 2rem auto;
}

.ad-footer {
    max-width: 728px;
    min-height: 90px;
    margin-top: 2rem;
}

/* ===== Main Content ===== */
.main-content {
    min-height: 60vh;
    padding: 2rem 0;
}

/* ===== Filters Section ===== */
.filters-section {
    background-color: var(--bg-white);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
    position: relative;
    z-index: 50;
}

.filters-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (min-width: 640px) {
    .filters-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .filters-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.filter-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.filter-label-spacer {
    color: transparent;
}

.filter-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background-color: var(--bg-white);
    transition: var(--transition);
    cursor: pointer;
}

.filter-clear-btn {
    width: 100%;
    padding: 0.75rem;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Type Toggle Buttons */
.type-toggle {
    display: flex;
    gap: 0.5rem;
}

.type-btn {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-white);
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
}

.type-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.type-btn.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Search Box */
.search-box {
    margin: 1rem 0;
}

.search-input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Buttons */
.btn-primary,
.btn-secondary {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-size: 1rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--bg-light);
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--secondary-color);
    color: var(--text-primary);
}

/* ===== Loading State ===== */
.loading-state {
    text-align: center;
    padding: 3rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Results Section ===== */
.results-section {
    margin-top: 2rem;
    overflow: visible;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.results-count {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Results Grid */
.results-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    overflow: visible;
}

@media (min-width: 768px) {
    .results-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .results-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Result Card */
.result-card {
    background-color: var(--bg-white);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    border: 2px solid transparent;
    overflow: visible !important;
    position: relative;
    z-index: 1;
}

.result-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    z-index: 10000;
}

.result-card-header {
    margin-bottom: 1rem;
}

.result-subject {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.result-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-level {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-year {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-type {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-phase {
    background-color: #e0e7ff;
    color: #3730a3;
}

.result-source {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.result-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-pdf {
    flex: 1;
    padding: 0.75rem;
    background-color: var(--primary-color);
    color: white !important;
    text-align: center;
    border-radius: 8px;
    font-weight: 600;
    transition: var(--transition);
    display: inline-block;
    text-decoration: none;
}

.btn-pdf:hover {
    background-color: var(--primary-hover);
    color: white !important;
    transform: translateY(-1px);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-icon {
    width: 64px;
    height: 64px;
    color: var(--text-secondary);
    margin: 0 auto 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
}

/* ===== Footer ===== */
.site-footer {
    background-color: var(--bg-white);
    border-top: 1px solid var(--border-color);
    padding: 3rem 0 1.5rem;
    margin-top: 0;
}

.site-footer a {
    color: var(--text-secondary);
    transition: var(--transition);
}

.site-footer a:hover {
    color: var(--primary-color);
}

.site-footer p {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.site-footer h3 {
    color: var(--text-primary);
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.site-footer h4 {
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.site-footer ul {
    list-style: none;
    padding: 0;
}

.site-footer ul li {
    margin-bottom: 0.75rem;
}

/* Footer Grid */
.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 3rem;
    padding: 3rem 0;
    border-bottom: 1px solid var(--border-color);
}

.footer-bottom {
    padding-top: 2rem;
    text-align: center;
}

.footer-bottom p {
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.disclaimer {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ===== About Page ===== */
.about-content {
    background-color: var(--bg-white);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    max-width: 800px;
    margin: 0 auto;
}

.about-content section {
    margin-bottom: 2rem;
}

.about-content h1 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 2.5rem;
}

.about-content h2 {
    color: var(--text-primary);
    margin-top: 2rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.about-content ul {
    list-style: none;
    padding-left: 1.5rem;
}

.about-content li {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.5rem;
}

.about-content li:before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: bold;
}

.cta-box {
    text-align: center;
    margin-top: 3rem;
    padding: 2rem;
    background-color: var(--bg-light);
    border-radius: 8px;
}

/* ===== Mobile Optimizations ===== */
@media (max-width: 640px) {
    .site-header .container {
        flex-direction: column;
        gap: 1rem;
    }

    .site-nav {
        gap: 1rem;
    }

    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.25rem; }

    .filters-section {
        position: static;
    }

    .ad-top,
    .ad-footer {
        min-height: 50px;
        font-size: 0.875rem;
    }
}

/* ===== Print Styles ===== */
@media print {
    .site-header,
    .site-footer,
    .filters-section,
    .ad {
        display: none;
    }
}
/* ===== Cookie Consent Banner ===== */
.cookie-consent {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.97) 0%, rgba(29, 78, 216, 0.97) 100%);
    color: white;
    padding: 1.25rem 1rem;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    border-top: 3px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    transform: translateY(0);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
    opacity: 1;
}

.cookie-consent.hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

.cookie-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.cookie-text {
    flex: 1;
    min-width: 250px;
}

.cookie-text p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
}

.cookie-text a {
    color: #FCD34D;
    text-decoration: underline;
    font-weight: 600;
    transition: color 0.2s ease;
}

.cookie-text a:hover {
    color: #FDE68A;
}

.cookie-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.cookie-buttons button {
    padding: 0.65rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-accept {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-accept:hover {
    background: #F8FAFC;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-reject {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-reject:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

@media (max-width: 768px) {
    .cookie-content {
        flex-direction: column;
        text-align: center;
    }
    
    .cookie-buttons {
        width: 100%;
        justify-content: center;
    }
    
    .cookie-buttons button {
        flex: 1;
        min-width: 120px;
    }
}

/* ===== Google AdSense Styles ===== */
.ad-container {
    margin: 2rem auto;
    padding: 1rem;
    text-align: center;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.ad-label {
    font-size: 0.75rem;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

/* Top Banner Ad (728x90 or responsive) */
.ad-top-banner {
    max-width: 728px;
    min-height: 90px;
    margin: 1.5rem auto;
}

/* Sidebar Ad (300x250) */
.ad-sidebar {
    width: 300px;
    min-height: 250px;
    margin: 1rem 0;
    position: sticky;
    top: 100px;
}

/* In-feed Ad (responsive) */
.ad-in-feed {
    max-width: 100%;
    min-height: 120px;
    margin: 2rem 0;
}

/* Bottom Banner Ad */
.ad-bottom-banner {
    max-width: 728px;
    min-height: 90px;
    margin: 2rem auto;
}

/* Responsive ads */
@media (max-width: 768px) {
    .ad-top-banner,
    .ad-bottom-banner {
        max-width: 320px;
        min-height: 100px;
    }
    
    .ad-sidebar {
        width: 100%;
        max-width: 320px;
        margin: 1rem auto;
        position: relative;
        top: auto;
    }
}

/* Ads: hide placeholders until an ad is successfully initialized */
.ad-container,
.ad-in-feed-card,
.result-card.ad-in-feed-card,
.ad-top-banner,
.ad-bottom-banner {
    display: none !important;
}

.ad-container.ads-visible,
.ad-in-feed-card.ads-visible,
.result-card.ad-in-feed-card.ads-visible,
.ad-top-banner.ads-visible,
.ad-bottom-banner.ads-visible {
    display: block !important;
}

/* Small transition to reduce flash when ad appears */
.ad-container,
.ad-in-feed-card {
    transition: opacity 200ms ease-in-out;
    opacity: 1;
}

/* Hide ads for premium users (optional) */
/* body.premium-user .ad-container {
    display: none;
} */
/* Ads now shown to all users including premium */

/* In-feed ad card (looks like result card) */
.ad-in-feed-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px dashed #dee2e6;
    position: relative;
}

.ad-in-feed-card .ad-label {
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 0.7rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    background: white;
    padding: 2px 8px;
    border-radius: 4px;
    z-index: 10;
}

.ad-in-feed-card:hover {
    transform: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Hide in-feed ads for premium users */
/* body.premium-user .ad-in-feed-card {
    display: none !important;
} */
/* Ads now shown to all users including premium */

