/* ============================================
   EDUTOPIA ANALYTICS DASHBOARD
   Brand Style Guide Implementation
   ============================================ */

/* ===== ROOT VARIABLES ===== */
:root {
    /* Edutopia Brand Colors */
    --edutopia-orange: #FF4C00;
    --dark-orange: #FF780D;
    --tangerine: #FF9B0D;
    --sunshine: #FFBC0D;
    --midnight-blue: #1D2A44;
    --space-blue: #004861;
    --pacific-blue: #0094C7;
    
    /* Supporting Colors */
    --white: #FFFFFF;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    
    /* Shadows - Minimalist (lighter, more subtle) */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
    --shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 4px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 8px 0 rgba(0, 0, 0, 0.08);
}

/* ===== BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--gray-50);
    color: var(--midnight-blue);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* ===== HEADER ===== */
.header {
    background: var(--midnight-blue);
    border-radius: 12px;
    padding: 40px;
    margin-bottom: 32px;
    box-shadow: var(--shadow-md);
    color: var(--white);
    position: relative;
    border-top: 4px solid var(--edutopia-orange);
}

.header-content h1 {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    margin-top: 24px;
}

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

.control-group label {
    font-weight: 600;
    color: var(--white);
    font-size: 0.95rem;
}

.quarter-select {
    padding: 12px 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.quarter-select:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--edutopia-orange);
}

.quarter-select:focus {
    outline: none;
    border-color: var(--edutopia-orange);
    box-shadow: 0 0 0 3px rgba(255, 76, 0, 0.3);
}

.quarter-select option {
    background: var(--midnight-blue);
    color: var(--white);
}

.last-updated {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 400;
}

/* ===== SECTIONS ===== */
.section {
    margin-bottom: 40px;
}

.section-title {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--midnight-blue);
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--gray-200);
}

.subsection-title {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--midnight-blue);
    margin-bottom: 16px;
}

/* ===== KPI GRID ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.kpi-card {
    background: var(--white);
    border-radius: 8px;
    padding: 24px;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
    border-left: 4px solid var(--gray-300);
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Color-coded borders */
.kpi-traffic {
    border-left-color: var(--pacific-blue);
}

.kpi-engagement {
    border-left-color: var(--tangerine);
}

.kpi-conversion {
    border-left-color: var(--edutopia-orange);
}

.kpi-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.kpi-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 2.75rem;
    font-weight: 700;
    color: var(--midnight-blue);
    line-height: 1.2;
    letter-spacing: -1px;
    margin-bottom: 8px;
}

.kpi-sublabel {
    font-size: 0.85rem;
    color: var(--gray-600);
    font-weight: 500;
}

/* ===== METRICS GRID ===== */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.metric-card {
    background: var(--white);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
    border-left: 4px solid var(--gray-300);
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.metric-conversion {
    border-left-color: var(--edutopia-orange);
}

.metric-engagement {
    border-left-color: var(--pacific-blue);
}

.metric-retention {
    border-left-color: var(--sunshine);
}

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

.metric-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-700);
}

.metric-value {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--midnight-blue);
    line-height: 1.2;
    margin-bottom: 6px;
}

.metric-sublabel {
    font-size: 0.8rem;
    color: var(--gray-600);
}

/* ===== INFO ICONS ===== */
.info-icon {
    background: none;
    border: none;
    color: var(--edutopia-orange);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px;
    margin-left: 4px;
    transition: all 0.2s ease;
    opacity: 0.8;
    line-height: 1;
    font-weight: bold;
}

.info-icon:hover {
    opacity: 1;
    transform: scale(1.15);
    color: var(--dark-orange);
}

.info-icon:focus {
    outline: 2px solid var(--edutopia-orange);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ===== TOOLTIPS ===== */
.tooltip-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(29, 42, 68, 0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tooltip-content {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 650px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    border-top: 4px solid var(--edutopia-orange);
}

.tooltip-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: var(--gray-200);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.tooltip-close:hover {
    background: var(--edutopia-orange);
    color: var(--white);
    transform: rotate(90deg);
}

.tooltip-body {
    padding: 36px;
}

.tooltip-body h3 {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--midnight-blue);
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--edutopia-orange);
}

.tooltip-section {
    margin-bottom: 24px;
}

.tooltip-section:last-child {
    margin-bottom: 0;
}

.tooltip-section h4 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--midnight-blue);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tooltip-section p {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--gray-700);
    margin: 0;
}

/* ===== TABLES ===== */
.table-container {
    background: var(--white);
    border-radius: 8px;
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 32px;
    overflow-x: auto;
}

.conversion-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.conversion-table thead {
    background: var(--midnight-blue);
    color: var(--white);
}

.conversion-table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.conversion-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-200);
}

.conversion-table tbody tr {
    transition: all 0.2s ease;
}

.conversion-table tbody tr:hover {
    background: rgba(255, 76, 0, 0.05);
    transform: scale(1.005);
}

.conversion-table tbody tr:last-child td {
    border-bottom: none;
}

.rate {
    font-weight: 700;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.rate.high {
    color: var(--edutopia-orange);
}

.rate.medium {
    color: var(--tangerine);
}

.rate.low {
    color: var(--gray-600);
}

/* ===== CHARTS ===== */
.chart-container {
    background: var(--white);
    border-radius: 8px;
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 32px;
    transition: all 0.2s ease;
}

.chart-container:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.chart-container canvas {
    max-height: 400px;
}

/* ===== ANIMATIONS ===== */
/* Minimal animations removed for cleaner aesthetic */

/* Loading spinner */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 60px;
    flex-direction: column;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--edutopia-orange);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    .header {
        padding: 28px 24px;
    }
    
    .header-content h1 {
        font-size: 2rem;
    }
    
    .kpi-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .kpi-value {
        font-size: 2.25rem;
    }
    
    .metric-value {
        font-size: 1.75rem;
    }
    
    .tooltip-content {
        width: 95%;
    }
    
    .tooltip-body {
        padding: 28px 20px;
    }
    
    .conversion-table {
        font-size: 0.85rem;
    }
    
    .conversion-table th,
    .conversion-table td {
        padding: 10px 12px;
    }
}

@media (max-width: 480px) {
    .header-content h1 {
        font-size: 1.75rem;
    }
    
    .section-title {
        font-size: 1.5rem;
    }
    
    .kpi-value {
        font-size: 2rem;
    }
    
    .quarter-select {
        width: 100%;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .header-controls,
    .info-icon,
    .tooltip-container {
        display: none !important;
    }
    
    body {
        background: white;
    }
    
    .kpi-card,
    .metric-card,
    .table-container,
    .chart-container {
        break-inside: avoid;
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid var(--gray-300);
    }
}

/* ===== UTILITY CLASSES ===== */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--gray-600);
}

.mb-0 {
    margin-bottom: 0;
}

.mt-2 {
    margin-top: 16px;
}

