/*
===========================================
FILE: css/global.css
PURPOSE: Global shared styles for all pages
===========================================

This file contains all shared CSS across the site to reduce
duplication and maintain consistency.

USAGE:
All pages should include this file via:
<link rel="stylesheet" href="css/global.css">

CONTENTS:
- Base styles & CSS reset
- Brand colors (CSS variables)
- Layout components (container, card)
- Typography
- Sub-navigation pills
- Coming soon sections
- Feature cards
- Buttons & CTA
- Mobile responsive styles

DEPENDENCIES: None (standalone)

RELATED FILES:
- All HTML pages reference this file
- docs/02-ARCHITECTURE.md - Design system documentation
- docs/README.md - Documentation overview

MAINTENANCE:
- When adding new shared styles, document them here
- Keep related styles grouped in sections
- Update docs/01-FILE-INDEX.md if adding major new sections
- Update docs/02-ARCHITECTURE.md design system section for new patterns

===========================================
*/

/* ========================================
   BASE STYLES & RESET
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background-color: #f8f9fa;
    color: #343a40;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Content area that should grow to push footer down */
body > .container,
body > div:not(#header-placeholder):not(#footer-placeholder) {
    flex: 1 0 auto;
    width: 100%; /* Ensure full width */
}

/* Footer will stick to bottom */
#footer-placeholder {
    flex-shrink: 0;
    margin-top: auto;
}

/* Header placeholder - reserve space to prevent layout shift */
#header-placeholder {
    min-height: 78px; /* Reserve space for header */
}

/* Loading state for header */
#header-placeholder:empty {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* ========================================
   BRAND COLORS (CSS Variables)
   ======================================== */

:root {
    --brand-primary: #1B89D9;
    --brand-dark: #12294B;
    --brand-white: #FFFFFF;
    --brand-light-gray: #f8f9fa;

    /* ========================================
       INSTITUTION/DISTRICT TYPE COLORS
       USE THESE CONSISTENTLY ACROSS ALL CHARTS
       ======================================== */
    /* Public institutions/districts - Blue */
    --public-color: #2E86AB;

    /* Private institutions/schools - Purple */
    --private-color: #A23B72;

    /* Gray for inactive/comparison data */
    --inactive-gray: #CCCCCC;

    /* Segment Size Color Schemes */
    /* Size Distribution (Blue) - for enrollment/count-based visualizations */
    --size-very-small-blue: #93c5fd;
    --size-small-blue: #60a5fa;
    --size-medium-blue: #3b82f6;
    --size-large-blue: #2563eb;
    --size-very-large-blue: #1d4ed8;

    /* Revenue Density (Green) - for TAM/revenue-based visualizations */
    /* Darker = Higher TAM density */
    --size-very-small-green: #86efac;
    --size-small-green: #4ade80;
    --size-medium-green: #22c55e;
    --size-large-green: #16a34a;
    --size-very-large-green: #15803d;
}

/* ========================================
   LAYOUT COMPONENTS
   ======================================== */

.container {
    padding: 0 20px 20px 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.card {
    background-color: white;
    padding: 50px;
    margin-bottom: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card h2 {
    margin-bottom: 30px;
    font-size: 24px;
}

/* ========================================
   TYPOGRAPHY
   ======================================== */

h4 {
    font-size: 20px;
    font-weight: 600;
    color: #12294B;
    margin-bottom: 30px;
}

.page-title {
    font-size: 42px;
    font-weight: 700;
    color: var(--brand-dark);
    margin-bottom: 16px;
    letter-spacing: -0.5px;
}

.page-subtitle {
    font-size: 18px;
    color: #6b7280;
    margin-bottom: 40px;
}

/* ========================================
   SUB-NAVIGATION PILLS
   Used on: Higher Ed pages, K-12 pages
   ======================================== */

/* Reserve space for subnav to prevent layout shift */
#subnav-placeholder {
    min-height: 48px;
    display: flex;
    align-items: center;
}

/* Loading state - show skeleton before JS loads */
#subnav-placeholder:empty::before {
    content: '';
    display: block;
    width: 400px;
    height: 36px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 20px;
}

.subnav-pills {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: 40px;
}

.pill-link {
    color: #6b7280;
    text-decoration: none;
    padding: 8px 20px;
    border-radius: 999px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    background-color: transparent;
    white-space: nowrap;
}

.pill-link:hover {
    color: #12294B;
    background-color: #e5e7eb;
}

.pill-link.active {
    color: white;
    background-color: #1B89D9;
    font-weight: 600;
}

/* ========================================
   COMING SOON SECTIONS
   Used on: Placeholder/insight pages
   ======================================== */

.coming-soon {
    background-color: white;
    padding: 80px 40px;
    margin-bottom: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

.coming-soon h2 {
    font-size: 32px;
    color: var(--brand-primary);
    margin-bottom: 20px;
}

.coming-soon p {
    font-size: 18px;
    color: #6b7280;
    margin-bottom: 30px;
    line-height: 1.8;
}

/* ========================================
   FEATURE CARDS
   Used on: Search page (currently)
   ======================================== */

.features-preview {
    background-color: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.features-preview h3 {
    font-size: 24px;
    color: var(--brand-dark);
    margin-bottom: 20px;
    text-align: center;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-top: 30px;
}

.feature-card {
    background: linear-gradient(135deg, rgba(27, 137, 217, 0.03) 0%, rgba(18, 41, 75, 0.03) 100%);
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.feature-card h4 {
    color: var(--brand-primary);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
}

.feature-card p {
    font-size: 14px;
    color: #4b5563;
    line-height: 1.6;
}

/* ========================================
   BUTTONS & CTA
   ======================================== */

.cta-button {
    display: inline-block;
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-dark) 100%);
    color: white;
    padding: 14px 32px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(27, 137, 217, 0.2);
}

.cta-button:hover {
    box-shadow: 0 4px 8px rgba(27, 137, 217, 0.3);
    transform: translateY(-2px);
}

/* ========================================
   KPI CARDS & DATA DISPLAY
   ======================================== */

.kpi-section {
    margin-bottom: 40px;
}

.kpi-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin: 0 -8px;
}

/* Standard KPI Cards (White) */
.kpi-card {
    background-color: white;
    padding: 24px;
    margin: 8px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid #f0f0f0;
    flex: 1;
    min-width: 200px;
    align-self: stretch;
}

.kpi-card:hover {
    box-shadow: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.08);
}

.kpi-label {
    margin: 0 0 8px 0;
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    margin: 0;
    font-size: 32px;
    font-weight: 700;
    line-height: 1.2;
}

.kpi-card.compact {
    align-self: flex-start;
}

.kpi-card.compact .kpi-value {
    margin-bottom: 0;
}

/* TAM/Revenue Cards (Solid Green with White Text) */
.kpi-card.tam-card {
    background-color: #2ca02c;
    box-shadow: none;
    border: none;
    color: white;
}

.kpi-card.tam-card:hover {
    box-shadow: none;
    transform: translateY(-2px);
}

.kpi-card.tam-card .kpi-label {
    color: white;
    opacity: 0.95;
}

.kpi-card.tam-card .kpi-value {
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.kpi-card.tam-card p {
    color: white;
    opacity: 0.9;
}

/* ========================================
   KEY INSIGHTS
   ======================================== */

.key-insights {
    background: #f0f9ff;
    border-left: 4px solid #1B89D9;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 70px;
}

.key-insights h5 {
    font-size: 16.7px;
    font-weight: 600;
    color: #12294B;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.key-insights h5::before {
    content: "";
    display: inline-block;
    width: 18px;
    height: 18px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231B89D9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18h6'/%3E%3Cpath d='M10 22h4'/%3E%3Cpath d='M15.09 14c.18-.98.65-1.74 1.41-2.5A4.65 4.65 0 0 0 18 8 6 6 0 0 0 6 8c0 1 .23 2.23 1.5 3.5A4.61 4.61 0 0 1 8.91 14'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    flex-shrink: 0;
}

.key-insights ul {
    margin: 0;
    padding-left: 20px;
    color: #374151;
    font-size: 16.7px;
    line-height: 1.8;
}

.key-insights li {
    margin-bottom: 4px;
}

.key-insights p {
    font-size: 16.7px;
    color: #374151;
}

/* ========================================
   CHART TITLES & LABELS
   ======================================== */

.chart-title-small {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 8px 0;
    text-align: center;
}

.color-swatch {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

.color-swatch-inline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.color-swatch-inline .swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.section-title-with-swatch {
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 20px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.footnote {
    font-size: 12px;
    color: #6b7280;
    margin: 0 0 30px 8px;
    font-style: italic;
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .container {
        padding: 20px 15px;
    }

    .card {
        padding: 30px 20px;
    }

    .page-title {
        font-size: 32px;
    }

    .page-subtitle {
        font-size: 16px;
    }

    .coming-soon {
        padding: 50px 25px;
    }

    .features-preview {
        padding: 30px 20px;
    }

    /* Subnav section header */
    #subnav-placeholder > div {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }

    #subnav-placeholder h2 {
        font-size: 28px;
    }

    .subnav-pills {
        width: 100%;
        margin-left: 0;
        flex-wrap: wrap;
        gap: 8px;
    }

    .pill-link {
        flex: 0 1 auto;
        text-align: center;
        padding: 8px 16px;
        font-size: 13px;
        white-space: nowrap;
    }

    /* KPI Cards - Stack vertically on mobile */
    .kpi-row {
        flex-direction: column;
    }

    .kpi-card {
        min-width: 100%;
        margin: 8px 0;
    }

    /* Key Insights - Reduce padding */
    .key-insights {
        padding: 16px;
        margin-bottom: 40px;
    }

    .key-insights h5 {
        font-size: 15px;
    }

    .key-insights ul,
    .key-insights p {
        font-size: 15px;
    }

    /* Typography adjustments */
    h4 {
        font-size: 18px;
        margin-bottom: 20px;
    }

    /* Chart containers - ensure proper spacing */
    .kpi-section {
        margin-bottom: 30px;
    }

    /* Reduce heading sizes */
    .card h2 {
        font-size: 20px;
        margin-bottom: 20px;
    }

    /* Footnotes */
    .footnote {
        font-size: 11px;
        margin-bottom: 20px;
    }

    /* Grid Layouts - Mobile responsive overrides */
    /* 4-column grids become 1 column */
    [style*="grid-template-columns: 1fr 1fr 1fr 1fr"],
    [style*="grid-template-columns: repeat(4"] {
        grid-template-columns: 1fr !important;
    }

    /* 3-column grids become 1 column */
    [style*="grid-template-columns: 1fr 1fr 1fr"]:not([style*="1fr 1fr 1fr 1fr"]),
    [style*="grid-template-columns: repeat(3"] {
        grid-template-columns: 1fr !important;
    }

    /* 5-column grids become 1 column */
    [style*="grid-template-columns: repeat(5"] {
        grid-template-columns: 1fr !important;
    }

    /* 7-column grids become 1 column */
    [style*="grid-template-columns: repeat(7"] {
        grid-template-columns: 1fr !important;
    }

    /* 2-column grids become 1 column */
    [style*="grid-template-columns: 1fr 1fr"]:not([style*="1fr 1fr 1fr"]) {
        grid-template-columns: 1fr !important;
    }

    /* Flex layouts that should stack */
    [style*="display: flex"][style*="justify-content: space-between"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px;
    }

    /* Reduce gap sizes on mobile */
    [style*="gap: 30px"] {
        gap: 20px !important;
    }

    [style*="gap: 20px"] {
        gap: 12px !important;
    }

    [style*="gap: 16px"] {
        gap: 12px !important;
    }
}

/* ========================================
   PAGE TRANSITIONS
   ======================================== */

/* Fade in page content sections (but not subnav header area) */
/* Add slight delay to let header/subnav load first */
.page-content,
.kpi-section,
.key-insights,
.coming-soon,
.features-preview {
    animation: fadeIn 0.2s ease-in 0.05s both;
}

/* Dashboard pages handle their own loading, don't animate */
#dashboard .page-content {
    animation: none;
    opacity: 1;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Smooth transitions for navigation links */
a {
    transition: all 0.2s ease;
}

/* Page exit fade for content only (requires JavaScript) */
.container.page-exit .page-content,
.container.page-exit .kpi-section,
.container.page-exit .key-insights,
.container.page-exit .coming-soon,
.container.page-exit .features-preview {
    animation: fadeOut 0.2s ease-out forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* ========================================
   SKELETON LOADERS FOR CHARTS
   ======================================== */

/* Chart placeholder while loading */
.chart-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
    min-height: 400px;
    position: relative;
    overflow: hidden;
}

.chart-skeleton.compact {
    min-height: 300px;
}

.chart-skeleton.tall {
    min-height: 500px;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Skeleton will be automatically removed when Plotly renders */
/* Plotly replaces innerHTML completely, removing the skeleton div */

/* KPI card skeleton */
.kpi-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 20px;
}

.kpi-skeleton-label {
    height: 16px;
    width: 60%;
    background: rgba(0,0,0,0.1);
    border-radius: 4px;
    margin-bottom: 12px;
}

.kpi-skeleton-value {
    height: 32px;
    width: 40%;
    background: rgba(0,0,0,0.15);
    border-radius: 4px;
}

/* Table skeleton */
.table-skeleton {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
}

.table-skeleton-row {
    height: 48px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 8px;
}

/* Map skeleton */
.map-skeleton {
    background: linear-gradient(135deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 14px;
}

/* Loading spinner (alternative to skeleton) */
.loading-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--brand-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 40px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Slider skeleton */
.slider-skeleton {
    height: 8px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    margin: 15px 0;
}

/* Filter skeleton (for dropdowns) */
.filter-skeleton {
    height: 38px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
}
