/* =========================================
   1. Design System & Variables
   ========================================= */
:root {
    /* Primary Colors */
    --primary-color: #0f172a;
    --accent-color: #0d9488;
    --accent-hover: #0f766e;

    /* Contract Status Colors */
    --color-contracted-reviews: #10b981;  /* Emerald Green */
    --color-contracted-noreviews: #3b82f6;/* Royal Blue */
    --color-nocontract-reviews: #f59e0b;  /* Amber */
    --color-nocontract-noreviews: #94a3b8;/* Slate Gray */

    /* Secondary/Support Colors */
    --secondary-bg: #f8fafc;
    --text-main: #334155;
    --text-muted: #64748b;
    --text-light: #f1f5f9;

    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.88);
    --glass-border: 1px solid rgba(255, 255, 255, 0.6);
    --glass-shadow: 0 10px 30px 0 rgba(31, 38, 135, 0.1);
    --glass-blur: blur(16px);

    /* Layout */
    --header-height: 70px;
    --sidebar-width: 420px;
    --border-radius: 16px;
    --transition-speed: 0.3s;
}

/* =========================================
   2. Global Reset & Typography
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto; /* Desktop scroll allowed! */
}

h1, h2, h3, h4, button, input {
    font-family: 'Outfit', sans-serif;
}

/* Hide mobile search view on desktop */
#mobile-search-view {
    display: none;
}

/* =========================================
   3. Header
   ========================================= */
header {
    height: var(--header-height);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border-bottom: var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    z-index: 100;
    position: relative;
}

.header-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--primary-color) 0%, #334155 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-season-tag {
    background: linear-gradient(135deg, #0d9488, #10b981);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* =========================================
   4. Main Layout (Desktop)
   ========================================= */
main {
    display: flex;
    max-width: 1700px;
    margin: 0 auto;
    width: 100%;
    padding: 24px;
    gap: 24px;
    min-height: calc(100vh - var(--header-height) - 70px);
}

.map-view-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.map-container {
    flex: 1;
    background: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--glass-shadow);
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.7);
    height: calc(100vh - var(--header-height) - 120px);
    min-height: 550px;
}

#world-map {
    width: 100%;
    height: 100%;
    min-height: 550px;
    background: #eef2f6;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* =========================================
   5. Minimalizable / Collapsible Map Legend
   ========================================= */
.map-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 10px 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 20;
    max-width: 300px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
}

.map-legend:hover {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.legend-toggle-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-color);
    padding: 0;
    gap: 12px;
}

.legend-arrow {
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: transform 0.3s;
}

.legend-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

/* Collapsed state */
.map-legend.collapsed {
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.92);
}

.map-legend.collapsed .legend-grid {
    display: none;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-main);
    font-weight: 500;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-dot.status-contracted-reviews { background: var(--color-contracted-reviews); }
.legend-dot.status-contracted-noreviews { background: var(--color-contracted-noreviews); }
.legend-dot.status-nocontract-reviews { background: var(--color-nocontract-reviews); }
.legend-dot.status-nocontract-noreviews { background: var(--color-nocontract-noreviews); }

/* SVG Map Path Styling & Hover Effects */
path, polygon {
    transition: fill 0.25s ease, stroke 0.25s ease, transform 0.25s ease, filter 0.25s ease;
    stroke: #ffffff;
    stroke-width: 0.6;
    cursor: pointer;
}

path.status-contracted-reviews, polygon.status-contracted-reviews {
    fill: var(--color-contracted-reviews);
}
path.status-contracted-noreviews, polygon.status-contracted-noreviews {
    fill: var(--color-contracted-noreviews);
}
path.status-nocontract-reviews, polygon.status-nocontract-reviews {
    fill: var(--color-nocontract-reviews);
}
path.status-nocontract-noreviews, polygon.status-nocontract-noreviews {
    fill: var(--color-nocontract-noreviews);
}

path:hover, polygon:hover {
    fill: #ec4899 !important;
    filter: drop-shadow(0 4px 8px rgba(236, 72, 153, 0.4));
    stroke: #ffffff;
    stroke-width: 1.2;
}

path[active="true"], polygon[active="true"] {
    fill: #8b5cf6 !important;
    stroke: #ffffff;
    stroke-width: 1.5;
    filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.6));
}

/* =========================================
   6. Sidebar & Filters
   ========================================= */
.sidebar {
    width: var(--sidebar-width);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--glass-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: calc(100vh - var(--header-height) - 120px);
    max-height: calc(100vh - var(--header-height) - 120px);
}

.sidebar h2 {
    font-size: 1.35rem;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.desktop-search {
    margin-bottom: 1rem;
    position: relative;
    z-index: 20;
}

#country-search-desktop, #country-search {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.9);
    transition: all 0.25s ease;
    color: var(--text-main);
}

#country-search-desktop:focus, #country-search:focus {
    background: #ffffff;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.2);
    outline: none;
}

.suggestions-list {
    list-style: none;
    background: #ffffff;
    border-radius: 12px;
    margin-top: 6px;
    max-height: 280px;
    overflow-y: auto;
    position: absolute;
    width: 100%;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    z-index: 100;
    display: none;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.search-suggestion-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.88rem;
}

.search-suggestion-item:hover {
    background: #f8fafc;
}

.suggestion-badge {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

/* Sidebar Filters */
.filter-group-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 10px;
    margin-bottom: 6px;
}

.filter-pills {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.filter-pill {
    cursor: pointer;
}

.filter-pill input {
    display: none;
}

.filter-pill span {
    display: inline-block;
    padding: 6px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-main);
    transition: all 0.2s;
}

.filter-pill input:checked + span {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
}

/* Reviews List & Cards */
#reviews-scroll {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
}

.review-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 1.1rem;
    margin-bottom: 1rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    transition: transform 0.2s, box-shadow 0.2s;
}

.review-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    border-color: var(--accent-color);
}

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

.review-author strong {
    color: var(--primary-color);
    font-size: 0.95rem;
}

.review-year {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.review-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.review-location {
    font-weight: 600;
    color: var(--text-main);
}

.star-rating {
    color: #f59e0b;
    letter-spacing: 1px;
}

.review-text {
    font-style: italic;
    color: var(--text-main);
    line-height: 1.5;
    font-size: 0.9rem;
}

.toggle-review, .btn-load-more, .btn-reset-filter {
    color: var(--accent-color);
    background: none;
    border: none;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

.btn-load-more {
    width: 100%;
    padding: 10px;
    background: #f1f5f9;
    border-radius: 8px;
    color: var(--primary-color);
    margin-top: 10px;
}

.btn-load-more:hover {
    background: #e2e8f0;
}

.active-filter-banner {
    background: #e0f2fe;
    border: 1px solid #bae6fd;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-reset-filter {
    margin-top: 0;
    color: #0284c7;
    text-decoration: underline;
}

/* =========================================
   7. Status Badges
   ========================================= */
.status-badge, .card-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    line-height: 1.2;
}

.badge-contracted-reviews {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.badge-contracted-noreviews {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.badge-nocontract-reviews {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.badge-nocontract-noreviews {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

/* =========================================
   8. Tooltip / Info Box
   ========================================= */
#info-box {
    position: fixed;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.94);
    color: #ffffff;
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 0.88rem;
    pointer-events: none;
    backdrop-filter: blur(8px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s, transform 0.2s;
    max-width: 300px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

#info-box.show {
    opacity: 1;
    transform: translateY(0);
}

.info-header {
    margin-bottom: 8px;
}

.info-header strong {
    display: block;
    font-size: 1.05rem;
    margin-bottom: 4px;
}

.info-org {
    font-size: 0.8rem;
    color: #cbd5e1;
    margin-bottom: 8px;
}

.info-notice {
    font-size: 0.78rem;
    padding: 6px 10px;
    border-radius: 6px;
    margin-top: 6px;
    line-height: 1.4;
}

.info-blue { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
.info-gray { background: rgba(255, 255, 255, 0.1); color: #cbd5e1; }

.rec-bar {
    background: rgba(255, 255, 255, 0.2);
    height: 5px;
    border-radius: 3px;
    margin: 8px 0 4px;
    overflow: hidden;
}

.rec-fill {
    height: 100%;
    background: var(--accent-color);
}

/* =========================================
   9. Contracted Countries Grid Section
   ========================================= */
.contracts-view-section {
    display: none;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    background: var(--glass-bg);
    border-radius: var(--border-radius);
    padding: 20px;
}

.contracts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
    margin-top: 14px;
}

.contract-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.contract-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
    border-color: var(--accent-color);
}

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

.contract-card-header h4 {
    font-size: 1rem;
    color: var(--primary-color);
}

.contract-org-pill {
    font-size: 0.72rem;
    font-weight: 700;
    background: #f1f5f9;
    color: #334155;
    padding: 2px 8px;
    border-radius: 10px;
}

.contract-status-text {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}

.contract-rating-sub {
    font-size: 0.8rem;
    color: #f59e0b;
    margin-top: 4px;
}

/* =========================================
   10. Footer
   ========================================= */
footer {
    background: var(--primary-color);
    color: var(--text-light);
    padding: 20px 2rem;
    text-align: center;
    margin-top: 20px;
}

.footer-content p {
    margin-bottom: 4px;
}

/* =========================================
   11. Mobile Bottom Sheet & Bottom Nav
   ========================================= */
.mobile-bottom-nav {
    display: none;
}

.mobile-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #ffffff;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    padding: 16px 20px 30px;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-sheet.open {
    transform: translateY(0);
}

.sheet-handle {
    width: 40px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 2px;
    margin: 0 auto 14px;
}

.sheet-close {
    position: absolute;
    top: 14px;
    right: 18px;
    font-size: 1.6rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.sheet-title {
    font-size: 1.4rem;
    color: var(--primary-color);
    margin-bottom: 6px;
}

.sheet-badge-wrap {
    margin-bottom: 12px;
}

.sheet-org {
    font-size: 0.9rem;
    color: var(--text-main);
    margin-bottom: 12px;
}

.sheet-rating {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    margin-bottom: 6px;
}

.sheet-score { font-weight: 700; color: var(--primary-color); }
.sheet-count { font-size: 0.85rem; color: var(--text-muted); }
.sheet-rec { font-size: 0.85rem; color: var(--accent-color); font-weight: 600; margin-top: 4px; }

.sheet-btn-action {
    width: 100%;
    padding: 12px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    margin-top: 16px;
    cursor: pointer;
}

.sheet-btn-action:hover {
    background: var(--accent-hover);
}

.sheet-notice {
    padding: 12px;
    border-radius: 10px;
    font-size: 0.85rem;
    line-height: 1.5;
    margin-top: 10px;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
}

.modal-content {
    background: #ffffff;
    padding: 2.2rem;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 520px;
    width: 90%;
    text-align: left;
}

.modal-content h2 {
    color: var(--primary-color);
    margin-bottom: 0.8rem;
    font-size: 1.4rem;
}

.modal-content p {
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--text-main);
}

#close-modal {
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 2rem;
    border-radius: 50px;
    font-weight: 700;
    margin-top: 1.4rem;
    border: none;
    cursor: pointer;
    display: block;
    width: 100%;
}

/* =========================================
   12. Media Queries (Mobile & Tablet)
   ========================================= */
@media (max-width: 1024px) {
    main {
        padding: 16px;
        gap: 16px;
    }
    .sidebar {
        width: 360px;
    }
}

@media (max-width: 768px) {
    header {
        height: 60px;
        padding: 0 1rem;
    }

    header h1 {
        font-size: 1.15rem;
    }

    .header-season-tag {
        font-size: 0.68rem;
        padding: 3px 8px;
    }

    main {
        flex-direction: column;
        padding: 12px;
        padding-bottom: 75px; /* Space for bottom nav */
        height: auto;
        min-height: 0;
    }

    .map-view-section {
        display: block;
    }

    .map-container {
        height: 55vh;
        min-height: 360px;
    }

    .map-legend {
        bottom: 12px;
        left: 12px;
        padding: 8px 12px;
        max-width: 250px;
    }

    .sidebar {
        width: 100%;
        display: none; /* Controlled by bottom nav tabs */
        border-radius: var(--border-radius);
        height: auto;
        max-height: none;
    }

    .contracts-view-section {
        display: none;
    }

    /* Mobile Search View (Hero) */
    #mobile-search-view {
        display: block;
        padding: 12px 16px;
        background: rgba(15, 23, 42, 0.05);
        margin-bottom: 8px;
    }

    #mobile-search-view h2 {
        font-size: 1.3rem;
        margin-bottom: 10px;
    }

    .mobile-search-hint {
        font-size: 0.8rem;
        color: var(--text-muted);
        margin-top: 6px;
    }

    /* Mobile Bottom Navigation Bar */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 62px;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(12px);
        border-top: 1px solid rgba(0, 0, 0, 0.1);
        z-index: 9000;
        justify-content: space-around;
        align-items: center;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.05);
    }

    .mobile-nav-item {
        background: none;
        border: none;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        color: var(--text-muted);
        font-size: 0.75rem;
        font-weight: 600;
        padding: 6px 12px;
        cursor: pointer;
        transition: color 0.2s;
    }

    .mobile-nav-item .nav-icon {
        font-size: 1.2rem;
    }

    .mobile-nav-item.active {
        color: var(--accent-color);
    }
}