/* ============================================
   Football Betting Platform — Design System
   Colors: Teal Blue (#0D9488) + Warm Beige (#F5F0E8)
   Light mode by default, with dark mode toggle support
   ============================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- CSS Variables (Light Theme) --- */
:root {
    /* Primary palette */
    --teal-50: #F0FDFA;
    --teal-100: #CCFBF1;
    --teal-200: #99F6E4;
    --teal-300: #5EEAD4;
    --teal-400: #0D9488;
    --teal-500: #0F766E;
    --teal-600: #0D9488;
    --teal-700: #0F766E;
    --teal-800: #115E59;
    --teal-900: #134E4A;

    /* Beige accent */
    --beige-50: #FDFCFA;
    --beige-100: #F9F6F0;
    --beige-200: #F5F0E8;
    --beige-300: #EDE5D4;
    --beige-400: #DDD0B8;
    --beige-500: #C4B499;

    /* Light backgrounds */
    --bg-primary: #F5F0E8;
    --bg-secondary: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F0EDE6;
    --bg-elevated: #EDE9E0;

    /* Text (dark on light) */
    --text-primary: #1A1A2E;
    --text-secondary: #4A4E5A;
    --text-muted: #7E828E;
    --text-accent: #0D9488;

    /* Borders */
    --border-subtle: rgba(0, 0, 0, 0.06);
    --border-medium: rgba(0, 0, 0, 0.12);
    --border-accent: rgba(13, 148, 136, 0.25);

    /* Status colors */
    --green: #16A34A;
    --green-bg: rgba(22, 163, 74, 0.10);
    --red: #DC2626;
    --red-bg: rgba(220, 38, 38, 0.08);
    --yellow: #CA8A04;
    --yellow-bg: rgba(202, 138, 4, 0.10);
    --blue: #2563EB;
    --blue-bg: rgba(37, 99, 235, 0.08);

    /* Confidence colors */
    --conf-high: #16A34A;
    --conf-medium: #CA8A04;
    --conf-low: #EA580C;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.10);
    --shadow-glow: 0 0 20px rgba(13, 148, 136, 0.10);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --transition-fast: 150ms var(--ease-out);
    --transition-normal: 250ms var(--ease-out);
    --transition-slow: 400ms var(--ease-out);

    /* Bottom nav height */
    --nav-height: 64px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* --- Dark Theme Override --- */
[data-theme="dark"] {
    --bg-primary: #0C0F14;
    --bg-secondary: #141820;
    --bg-card: #1A1F2B;
    --bg-card-hover: #212737;
    --bg-elevated: #252B3A;
    --text-primary: #F5F0E8;
    --text-secondary: #A8ADB8;
    --text-muted: #6B7080;
    --text-accent: #14B8A6;
    --teal-400: #2DD4BF;
    --teal-500: #14B8A6;
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.10);
    --border-accent: rgba(13, 148, 136, 0.3);
    --green: #22C55E;
    --green-bg: rgba(34, 197, 94, 0.12);
    --red: #EF4444;
    --red-bg: rgba(239, 68, 68, 0.12);
    --yellow: #EAB308;
    --yellow-bg: rgba(234, 179, 8, 0.12);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(13, 148, 136, 0.15);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom) + 16px);
}

a {
    color: var(--text-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover { color: var(--teal-400); }

/* --- Utility Classes --- */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

.page {
    display: none;
    animation: fadeIn 0.3s var(--ease-out);
}

.page.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* --- Typography --- */
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
    letter-spacing: -0.02em;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: var(--space-sm);
}

.stat-value {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: all var(--transition-normal);
}

.card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-accent);
    box-shadow: var(--shadow-md);
}

.card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
}

.card + .card { margin-top: var(--space-md); }

/* --- Match Card --- */
.match-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.match-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.match-card + .match-card { margin-top: var(--space-sm); }

.match-card__competition {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-xs);
}

.match-card__teams {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
}

.match-card__team {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex: 1;
    font-weight: 500;
    font-size: 0.9rem;
}

.match-card__team--away { justify-content: flex-end; text-align: right; }

.match-card__team img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.match-card__vs {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    min-width: 24px;
    text-align: center;
}

.match-card__time {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--teal-400);
    text-align: center;
    margin-top: var(--space-sm);
}

.match-card__badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    margin-top: var(--space-sm);
}

.badge--bet {
    background: var(--green-bg);
    color: var(--green);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge--no-bet {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge--pending {
    background: var(--yellow-bg);
    color: var(--yellow);
    border: 1px solid rgba(234, 179, 8, 0.2);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 44px;
}

.btn--primary {
    background: linear-gradient(135deg, var(--teal-600), var(--teal-700));
    color: white;
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.3);
}

.btn--primary:hover {
    background: linear-gradient(135deg, var(--teal-500), var(--teal-600));
    box-shadow: 0 4px 16px rgba(13, 148, 136, 0.4);
    transform: translateY(-1px);
}

.btn--primary:active { transform: translateY(0); }

.btn--secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
}

.btn--secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-accent);
}

.btn--danger {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn--full { width: 100%; }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* --- Inputs --- */
.input-group { margin-bottom: var(--space-md); }

.input-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 1rem;
    min-height: 44px;
    transition: border-color var(--transition-fast);
    outline: none;
}

.input:focus {
    border-color: var(--teal-600);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.input--code {
    font-family: var(--font-mono);
    font-size: 1.75rem;
    text-align: center;
    letter-spacing: 0.5em;
    padding-left: 0.5em;
}

select.input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23A8ADB8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* --- Bottom Navigation --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-height) + var(--safe-area-bottom));
    padding-bottom: var(--safe-area-bottom);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-medium);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.04);
    z-index: 1000;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-xs) var(--space-sm);
    color: var(--text-muted);
    font-size: 0.6rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.nav-item:hover, .nav-item.active {
    color: var(--teal-500);
}

.nav-item svg {
    width: 22px;
    height: 22px;
    stroke-width: 1.5;
}

/* --- Probability Bar --- */
.prob-bar {
    display: flex;
    height: 6px;
    border-radius: var(--radius-full);
    overflow: hidden;
    gap: 2px;
    margin: var(--space-sm) 0;
}

.prob-bar__segment {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.prob-bar__segment--home { background: var(--teal-500); }
.prob-bar__segment--draw { background: var(--beige-400); }
.prob-bar__segment--away { background: var(--text-muted); }

.prob-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.prob-labels span { font-family: var(--font-mono); }
.prob-labels .home-prob { color: var(--teal-400); }
.prob-labels .away-prob { color: var(--text-secondary); }

/* --- Tags / Chips --- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
}

.chip--teal { background: rgba(13, 148, 136, 0.15); color: var(--teal-400); }
.chip--green { background: var(--green-bg); color: var(--green); }
.chip--red { background: var(--red-bg); color: var(--red); }
.chip--yellow { background: var(--yellow-bg); color: var(--yellow); }

/* --- Confidence indicator --- */
.confidence {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.75rem;
    font-weight: 600;
}

.confidence--high { color: var(--conf-high); }
.confidence--medium { color: var(--conf-medium); }
.confidence--low { color: var(--conf-low); }

.confidence-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.confidence--high .confidence-dot { background: var(--conf-high); }
.confidence--medium .confidence-dot { background: var(--conf-medium); }
.confidence--low .confidence-dot { background: var(--conf-low); }

/* --- Layer Accordion --- */
.layer {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: var(--space-sm);
}

.layer__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    cursor: pointer;
    background: var(--bg-card);
    transition: background var(--transition-fast);
    user-select: none;
}

.layer__header:hover { background: var(--bg-card-hover); }

.layer__title {
    font-weight: 600;
    font-size: 0.875rem;
}

.layer__chevron {
    transition: transform var(--transition-normal);
    color: var(--text-muted);
}

.layer.open .layer__chevron { transform: rotate(180deg); }

.layer__content {
    display: none;
    padding: var(--space-md);
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
}

.layer.open .layer__content { display: block; }

/* --- Loading spinner --- */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-medium);
    border-top-color: var(--teal-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: var(--space-2xl) auto;
}

.loading-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: var(--space-md);
}

/* --- Toast notifications --- */
.toast-container {
    position: fixed;
    top: var(--space-md);
    right: var(--space-md);
    left: var(--space-md);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    pointer-events: none;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    font-size: 0.85rem;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s var(--ease-out);
    pointer-events: auto;
}

.toast--success { border-left: 3px solid var(--green); }
.toast--error { border-left: 3px solid var(--red); }
.toast--warning { border-left: 3px solid var(--yellow); }

/* --- Login Page --- */
.login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-xl);
    background: linear-gradient(180deg, var(--teal-50) 0%, var(--beige-200) 100%);
}

.login-logo {
    width: 120px;
    height: 120px;
    max-width: 120px;
    max-height: 120px;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
}

.login-logo img {
    width: 120px;
    height: 120px;
    max-width: 120px;
    object-fit: cover;
    border-radius: var(--radius-xl);
}

.login-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: var(--space-xs);
    color: #1A1A2E;
}

.login-subtitle {
    font-size: 0.85rem;
    color: #7E828E;
    margin-bottom: var(--space-xl);
}

.login-form {
    width: 100%;
    max-width: 320px;
    position: relative;
    z-index: 10;
}

.login-form .input {
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.15);
    color: #1A1A2E;
}

.login-form .input--code {
    background: #FFFFFF;
    color: #1A1A2E;
}

.login-form .input::placeholder {
    color: #A0A4B0;
}

.login-error {
    color: var(--red);
    font-size: 0.8rem;
    text-align: center;
    margin-top: var(--space-sm);
    min-height: 20px;
}

/* --- Header --- */
.page-header {
    padding: var(--space-lg) 0 var(--space-md);
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 100;
}

/* --- Theme meta-color --- */
[data-theme="dark"] .page-header {
    background: #0C0F14;
}

/* --- Stat grid --- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
}

.stat-grid .card {
    padding: var(--space-md);
    text-align: center;
}

/* --- Toggle switch --- */
.toggle {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-medium);
    transition: background var(--transition-fast);
    cursor: pointer;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 2px;
    top: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.toggle input:checked + .toggle-slider {
    background: var(--teal-700);
    border-color: var(--teal-600);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: white;
}

/* --- Empty state --- */
.empty-state {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    color: var(--text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: var(--space-md);
    opacity: 0.3;
}

/* --- Responsive --- */
@media (min-width: 768px) {
    .container { max-width: 560px; }
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1024px) {
    .container { max-width: 640px; }
}

/* ─── Traffic Light Market Grid ─── */
.market-grid {
    display: grid; gap: 8px;
}
.market-grid--3 { grid-template-columns: repeat(3, 1fr); }
.market-grid--2 { grid-template-columns: repeat(2, 1fr); }

.market-cell {
    text-align: center; padding: 10px 6px;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    transition: all 0.2s ease;
}
.market-cell__label {
    font-size: 0.7rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    margin-bottom: 4px; color: var(--text-muted);
}
.market-cell__odds {
    font-size: 1.1rem; font-weight: 700;
    color: var(--text-primary); margin-bottom: 2px;
}
.market-cell__prob {
    font-size: 0.7rem; color: var(--text-muted);
}
.market-cell__signal {
    font-size: 0.6rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.8px;
    margin-top: 4px; padding: 2px 6px;
    border-radius: 4px; display: inline-block;
}

/* Pastel traffic light colors */
.light--green {
    background: #E8F5E9; border-color: #81C784;
}
.light--green .market-cell__signal {
    background: #81C784; color: #1B5E20;
}
.light--yellow {
    background: #FFF8E1; border-color: #FFD54F;
}
.light--yellow .market-cell__signal {
    background: #FFD54F; color: #E65100;
}
.light--red {
    background: #FFEBEE; border-color: #E57373;
}
.light--red .market-cell__signal {
    background: #E57373; color: #B71C1C;
}
.light--grey {
    background: var(--bg-secondary); border-color: var(--border-color);
}

/* Neutral badge */
.badge--neutral {
    background: #FFF8E1; color: #E65100;
    border: 1px solid #FFD54F;
    padding: 4px 12px; border-radius: var(--radius-sm);
    font-size: 0.75rem; font-weight: 600;
}

/* ─── Stat Categories ─── */
.stat-cats {
    display: flex; flex-direction: column; gap: 6px;
}
.stat-cat-row {
    display: flex; justify-content: space-between;
    align-items: center; padding: 6px 10px;
    background: var(--bg-secondary); border-radius: var(--radius-sm);
}
.stat-cat-label {
    font-size: 0.75rem; color: var(--text-muted);
}
.stat-cat-value {
    font-size: 0.75rem; font-weight: 700;
    padding: 2px 8px; border-radius: 4px;
}
.cat--home {
    background: #E8F5E9; color: #2E7D32;
}
.cat--away {
    background: #FFEBEE; color: #C62828;
}
.cat--equal {
    background: #FFF8E1; color: #E65100;
}
