/*
=============================================
PREDICTION TRACKER - STYLES
Mobile-first responsive design
=============================================
*/

/* ==================== CSS VARIABLES ==================== */
:root {
    /* Colors */
    --primary: #1e40af;
    --primary-light: #3b82f6;
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;

    /* Grays */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;

    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);

    /* Font sizes */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 2rem;
}


/* ==================== RESET & BASE ==================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
}


/* ==================== APP CONTAINER ==================== */
.app {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    box-shadow: var(--shadow-lg);
}


/* ==================== HEADER ==================== */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: var(--space-lg);
    text-align: center;
}

.header h1 {
    font-size: var(--text-2xl);
    font-weight: 700;
    margin-bottom: var(--space-xs);
}

.header-subtitle {
    font-size: var(--text-sm);
    opacity: 0.9;
    margin-bottom: var(--space-md);
}

.header-stats {
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
    margin-top: var(--space-md);
}

.header-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header-stat-value {
    font-size: var(--text-xl);
    font-weight: 700;
}

.header-stat-label {
    font-size: var(--text-xs);
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}


/* ==================== TABS ==================== */
.tabs {
    display: flex;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab {
    flex: 1;
    min-width: fit-content;
    padding: var(--space-md);
    background: none;
    border: none;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tab:hover {
    color: var(--gray-700);
    background: var(--gray-100);
}

.tab.active {
    color: var(--primary);
    background: white;
    border-bottom: 2px solid var(--primary);
}


/* ==================== TAB CONTENT ==================== */
.tab-content {
    display: none;
    padding: var(--space-md);
}

.tab-content.active {
    display: block;
}


/* ==================== SECTION HEADER ==================== */
.section-header {
    margin-bottom: var(--space-md);
}

.section-header h2 {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--gray-800);
}

.section-header p {
    font-size: var(--text-sm);
    color: var(--gray-500);
}


/* ==================== FILTER BAR ==================== */
.filter-bar {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}

.filter-bar select {
    flex: 1;
    min-width: 140px;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    background: white;
    color: var(--gray-700);
    cursor: pointer;
}

.filter-bar select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}


/* ==================== PREDICTION CARDS ==================== */
.prediction-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.prediction-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.prediction-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* Resolved card states */
.prediction-card.happened {
    border-left: 4px solid var(--success);
}

.prediction-card.did-not-happen {
    border-left: 4px solid var(--danger);
}

.prediction-card.overdue {
    border-left: 4px solid var(--warning);
}

.prediction-name {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: var(--space-xs);
}

.prediction-description {
    font-size: var(--text-sm);
    color: var(--gray-600);
    margin-bottom: var(--space-sm);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.prediction-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    align-items: center;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-xs) var(--space-sm);
    border-radius: 999px;
    font-size: var(--text-xs);
    font-weight: 500;
}

.badge-probability {
    background: #dbeafe;
    color: var(--primary);
}

.badge-category {
    background: var(--gray-200);
    color: var(--gray-700);
}

.badge-date {
    background: var(--gray-100);
    color: var(--gray-600);
}

.badge-happened {
    background: var(--success-light);
    color: var(--success);
}

.badge-did-not-happen {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-overdue {
    background: var(--warning-light);
    color: #92400e;
}

.badge-brier {
    background: #f3e8ff;
    color: #7c3aed;
}


/* ==================== STATS ==================== */
.stats-grid {
    display: grid;
    gap: var(--space-md);
}

.stat-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: var(--space-md);
}

.stat-card.featured {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
}

.stat-card h3 {
    font-size: var(--text-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-sm);
    opacity: 0.9;
}

.stat-card.featured h3 {
    color: white;
}

.stat-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    margin-bottom: var(--space-xs);
}

.stat-explanation {
    font-size: var(--text-sm);
    opacity: 0.9;
}

.stat-subtitle {
    font-size: var(--text-sm);
    color: var(--gray-500);
    margin-bottom: var(--space-sm);
}

.stat-breakdown {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm);
    background: white;
    border-radius: var(--radius-sm);
}

.stat-row-label {
    font-size: var(--text-sm);
    color: var(--gray-700);
}

.stat-row-value {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--gray-900);
}

/* Brier score bar visualization */
.brier-bar {
    width: 80px;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
    margin-left: var(--space-sm);
}

.brier-bar-fill {
    height: 100%;
    background: var(--success);
    transition: width 0.3s ease;
}

.brier-bar-fill.poor {
    background: var(--danger);
}

.brier-bar-fill.average {
    background: var(--warning);
}


/* ==================== RECENT RESULTS ==================== */
.recent-results {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.result-dot {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    font-weight: 600;
    color: white;
}

.result-dot.good {
    background: var(--success);
}

.result-dot.poor {
    background: var(--danger);
}


/* ==================== ABOUT CONTENT ==================== */
.about-content {
    line-height: 1.7;
}

.about-content h3 {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--gray-800);
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
}

.about-content h3:first-child {
    margin-top: 0;
}

.about-content p {
    margin-bottom: var(--space-md);
    color: var(--gray-700);
}

.about-content ul {
    margin-left: var(--space-lg);
    margin-bottom: var(--space-md);
}

.about-content li {
    margin-bottom: var(--space-xs);
    color: var(--gray-700);
}

.about-content code {
    background: var(--gray-100);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-family: 'Courier New', monospace;
    font-size: var(--text-sm);
}


/* ==================== MODAL ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: calc(100% - var(--space-xl));
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    z-index: 1;
}

.modal-close {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    background: none;
    border: none;
    font-size: var(--text-2xl);
    color: var(--gray-400);
    cursor: pointer;
    padding: var(--space-sm);
    line-height: 1;
}

.modal-close:hover {
    color: var(--gray-600);
}

#modalBody {
    padding: var(--space-lg);
}

.modal-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: var(--space-sm);
    padding-right: var(--space-xl);
}

.modal-description {
    font-size: var(--text-base);
    color: var(--gray-600);
    margin-bottom: var(--space-md);
    line-height: 1.6;
}

.modal-details {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    padding: var(--space-md);
    background: var(--gray-50);
    border-radius: var(--radius-md);
}

.modal-detail-row {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-sm);
}

.modal-detail-label {
    color: var(--gray-500);
}

.modal-detail-value {
    font-weight: 500;
    color: var(--gray-800);
}

/* History section in modal */
.modal-history {
    margin-top: var(--space-md);
}

.modal-history h4 {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: var(--space-sm);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.history-item {
    font-size: var(--text-sm);
    color: var(--gray-600);
    padding: var(--space-sm);
    background: var(--gray-50);
    border-radius: var(--radius-sm);
}

.history-item-date {
    color: var(--gray-400);
    font-size: var(--text-xs);
}


/* ==================== FOOTER ==================== */
.footer {
    padding: var(--space-lg);
    text-align: center;
    border-top: 1px solid var(--gray-200);
}

.footer a {
    color: var(--primary);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}


/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center;
    padding: var(--space-xl);
    color: var(--gray-500);
}

.empty-state p {
    margin-bottom: var(--space-md);
}


/* ==================== LOADING STATE ==================== */
.loading {
    text-align: center;
    padding: var(--space-xl);
    color: var(--gray-500);
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--space-md);
}

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


/* ==================== ERROR STATE ==================== */
.error-state {
    text-align: center;
    padding: var(--space-xl);
    color: var(--danger);
}


/* ==================== RESPONSIVE - TABLET+ ==================== */
@media (min-width: 640px) {
    .header {
        padding: var(--space-xl);
    }

    .header h1 {
        font-size: var(--text-3xl);
    }

    .header-stats {
        gap: var(--space-xl);
    }

    .header-stat-value {
        font-size: var(--text-2xl);
    }

    .tab-content {
        padding: var(--space-lg);
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-card.featured {
        grid-column: span 2;
    }
}


/* ==================== RESPONSIVE - DESKTOP ==================== */
@media (min-width: 1024px) {
    body {
        padding: var(--space-xl) 0;
    }

    .app {
        border-radius: var(--radius-lg);
        min-height: auto;
    }
}


/* ==================== UTILITY CLASSES ==================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
