:root {
    --bg-dark: #0f1520;
    --bg-card: #171d28;
    --bg-card-hover: #1e2634;
    --bg-panel: #111823;
    --border-main: #2a3342;
    --text-primary: #f8fafc;
    --text-muted: #8b9bb4;
    --accent-green: #22c55e;
    --accent-green-bg: rgba(34, 197, 94, 0.15);
    --accent-red: #fca5a5;
    --accent-blue: #38bdf8;
    --accent-blue: #3b82f6;
    --accent-gold: #eab308;
    --card-radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; }
body { background-color: var(--bg-dark); color: var(--text-primary); min-height: 100vh; overflow-x: hidden; font-size: 14px; }

/* LAYOUT */
.app-layout { max-width: 1400px; margin: 0 auto; padding: 1rem 2rem; }
.main-container { display: grid; grid-template-columns: 1fr 340px; gap: 2rem; margin-top: 1.5rem; align-items: start; }

/* HEADER */
.app-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 0; border-bottom: 1px solid var(--border-main); }
.header-left .logo-area { display: flex; align-items: center; gap: 8px; }
.header-left h1 { font-size: 1.25rem; font-weight: 700; color: #fff; }
.badge-season { font-size: 0.75rem; color: var(--accent-green); border: 1px solid var(--accent-green); border-radius: 12px; padding: 2px 8px; background: var(--accent-green-bg); margin-left: 8px; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 12px; }
.sync-status { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-muted); margin-right: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #fbbf24; }
.status-dot.ready { background: var(--accent-green); }
.status-dot.error { background: #ef4444; }
.btn { background: var(--bg-card); color: var(--text-muted); border: 1px solid var(--border-main); padding: 6px 14px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: 0.85rem; font-weight: 500; transition: all 0.2s; }
.btn:hover { background: var(--bg-card-hover); color: #fff; }

/* METRICS SHELF */
.metrics-shelf { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 1.5rem; }
.metric-card { background: var(--bg-panel); border: 1px solid var(--border-main); border-radius: var(--card-radius); padding: 1rem; display: flex; align-items: center; gap: 16px; }
.metric-icon-circle { width: 48px; height: 48px; border-radius: 50%; background: conic-gradient(var(--accent-green) calc(var(--progress, 0) * 1%), var(--border-main) 0); display: flex; justify-content: center; align-items: center; font-weight: 700; color: var(--text-muted); position: relative; }
.metric-icon-circle::before { content: ''; position: absolute; inset: 3px; background: var(--bg-panel); border-radius: 50%; z-index: 1; }
#metric-percent { position: relative; z-index: 2; }
.metric-info { display: flex; flex-direction: column; gap: 4px; }
.metric-label { font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); font-weight: 600; letter-spacing: 0.5px; }
.metric-value { font-size: 1.35rem; font-weight: 700; color: #fff; }
.metric-sublabel { font-size: 0.75rem; color: var(--text-muted); }
.metric-card.highlight-blue { border-top: 3px solid var(--accent-blue); }
.metric-card.highlight-blue .metric-value { color: var(--accent-blue); }
.metric-card.highlight-green { border-top: 3px solid var(--accent-green); }
.metric-card.highlight-green .metric-value { color: var(--accent-green); }
.metric-card.highlight-gold { border-top: 3px solid var(--accent-gold); }
.metric-card.highlight-gold .metric-value { color: var(--accent-gold); }

/* TABS */
.tabs-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 1rem; }
.tab-btn { background: var(--bg-panel); border: 1px solid var(--border-main); border-radius: var(--card-radius); padding: 1rem; display: flex; flex-direction: column; align-items: center; cursor: pointer; color: var(--text-muted); transition: all 0.2s; position: relative; }
.tab-btn:hover { background: var(--bg-card-hover); }
.tab-btn.active { background: var(--bg-card-hover); border-bottom: 3px solid var(--accent-green); color: #fff; }
.tab-date { font-size: 0.75rem; margin-bottom: 4px; }
.tab-title { font-weight: 600; font-size: 1rem; }
.tab-badge { margin-top: 4px; background: rgba(255,255,255,0.1); padding: 2px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 700; }
.tab-btn.active .tab-badge { background: var(--accent-green); color: #000; }

/* FILTERS */
.filters-row { display: flex; align-items: center; gap: 12px; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border-main); }
.filter-label { color: var(--text-muted); font-size: 0.85rem; }
.filter-btn { background: transparent; border: 1px solid var(--border-main); color: var(--text-muted); border-radius: 20px; padding: 6px 14px; font-size: 0.8rem; cursor: pointer; transition: 0.2s; display: flex; align-items: center; gap: 6px; }
.filter-btn:hover { background: rgba(255,255,255,0.05); }
.filter-btn.active { background: rgba(255,255,255,0.1); color: #fff; border-color: rgba(255,255,255,0.4); }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    width: fit-content;
    white-space: nowrap;
}

.fun-badge {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.game-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

/* GAMES LIST */
.games-header h3 { font-size: 0.85rem; color: var(--accent-green); letter-spacing: 1px; margin-bottom: 1rem; }
.games-list { display: flex; flex-direction: column; gap: 8px; }
.game-card-row { background: var(--bg-panel); border: 1px solid var(--border-main); border-radius: var(--card-radius); display: grid; grid-template-columns: 1fr 1fr 180px; padding: 1.25rem 1.5rem; align-items: center; }
.game-card-row:hover { border-color: rgba(255,255,255,0.15); background: var(--bg-card-hover); }

.team-split { display: flex; flex-direction: column; gap: 1rem; }
.matchup-team { display: flex; align-items: center; gap: 12px; }
.team-name { font-weight: 600; font-size: 1rem; }
.team-name.unseen-text { color: #fff; }

.unseen-icon { color: #ef4444; font-size: 1.1rem; }
.seen-icon { color: var(--accent-green); font-size: 1.1rem; font-weight: 800; }

.pitcher-split { display: flex; flex-direction: column; gap: 1rem; color: var(--text-muted); font-size: 0.85rem; margin-left: 2rem;}
.electric-sp { color: var(--accent-gold); font-weight: 700; display: flex; align-items: center; gap: 4px; }
.electric-star { font-size: 14px !important; }

.game-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.game-time { font-weight: 700; color: #fff; font-size: 0.9rem; }
.game-networks { font-size: 0.75rem; color: var(--text-muted); }
.game-location { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 2px; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    width: fit-content;
    white-space: nowrap;
}

.fun-badge {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.game-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 4px;
}

.both-unseen-badge { 
    background: var(--accent-green-bg); 
    color: var(--accent-green); 
    border: 1px solid var(--accent-green); 
}
.showcase-badge {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.2), rgba(236, 72, 153, 0.2));
    color: #f472b6;
    border: 1px solid rgba(236, 72, 153, 0.4);
    cursor: help;
}
.network-badge { 
    background: rgba(255,255,255,0.1); 
    color: #fff; 
    border: 1px solid rgba(255,255,255,0.2);
}

/* RIGHT SIDEBAR */
.sidebar-right { background: var(--bg-panel); border: 1px solid var(--border-main); border-radius: var(--card-radius); padding: 1.5rem; }
.sidebar-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-main); padding-bottom: 1rem; margin-bottom: 1rem; }
.sidebar-title h3 { font-size: 1rem; color: #fff; margin-bottom: 2px; }
.sidebar-subtitle { font-size: 0.75rem; color: var(--text-muted); }
.sidebar-circle-badge { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--accent-green); color: var(--accent-green); display: flex; justify-content: center; align-items: center; font-size: 0.8rem; font-weight: 700; background: var(--accent-green-bg); }

.divisions-container { display: flex; flex-direction: column; gap: 1.5rem; }
.division-header { display: flex; justify-content: space-between; font-size: 0.75rem; font-weight: 700; color: var(--text-muted); margin-bottom: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; }
.division-counts { background: rgba(255,255,255,0.05); padding: 2px 6px; border-radius: 4px; }
.team-checklist-item { display: flex; align-items: center; gap: 10px; margin-bottom: 0.6rem; font-size: 0.85rem; color: var(--text-muted); }
.team-checklist-item.is-unseen { color: #fff; }
.custom-checkbox { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--text-muted); background: transparent; display: flex; justify-content: center; align-items: center; cursor: pointer; }
.team-checklist-item.is-seen .custom-checkbox { background: var(--accent-green-bg); border-color: var(--accent-green); color: var(--accent-green); font-size: 10px; font-weight: 800; }
.team-record { color: var(--text-muted); font-weight: 400; margin-left: 4px; }

/* ERROR & LOADING */
.loading-state, .error-msg { text-align: center; padding: 2rem; color: var(--text-muted); }
.error-msg { color: #fca5a5; }

/* FOOTER */
.app-footer { margin-top: 2rem; padding: 2rem 0; text-align: center; }
.footer-content { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; letter-spacing: 0.5px; opacity: 0.7; }
.bolt-small { color: var(--accent-gold); margin-right: 4px; }
.diamond-icon { margin-left: 0; margin-right: 4px; font-size: 0.9rem; }
.footer-separator { margin: 0 12px; opacity: 0.5; }
.footer-link { color: var(--text-muted); text-decoration: none; border-bottom: 1px solid transparent; transition: all 0.2s; }
.footer-link:hover { color: var(--accent-gold); border-bottom-color: var(--accent-gold); }

.sidebar-bolt { color: var(--accent-gold); font-size: 14px !important; vertical-align: middle; margin-left: 2px; }
.sidebar-featured { color: var(--accent-blue); font-size: 13px !important; vertical-align: middle; margin-left: 2px; cursor: help; }
.team-record { margin-left: 6px; }
.sidebar-fun { font-size: 11px; margin-left: 4px; opacity: 0.8; cursor: help; }

/* MOBILE RESPONSIVENESS */
.electric-badge {
    background: rgba(234, 179, 8, 0.15);
    color: var(--accent-gold);
    border: 1px solid rgba(234, 179, 8, 0.3);
}

.hot-hitter-badge {
    background: rgba(249, 115, 22, 0.15);
    color: #f97316;
    border: 1px solid rgba(249, 115, 22, 0.35);
    cursor: help;
}

.milestone-badge {
    background: rgba(234, 179, 8, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(234, 179, 8, 0.45);
    cursor: help;
}

@media (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .app-layout { padding: 0.5rem 1rem; }
    .main-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    .metrics-shelf {
        grid-template-columns: repeat(2, 1fr);
    }
    .metrics-shelf .metric-card:nth-child(3),
    .metrics-shelf .metric-card:nth-child(4) {
        display: none;
    }
    .filters-row {
        gap: 8px;
    }
    .filter-btn {
        padding: 6px 10px;
    }
    .filter-text, .filter-label {
        display: none;
    }
    .game-card-row {
        display: flex;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0.85rem;
    }
    .team-split {
        flex: 1 1 auto;
        min-width: 0; /* Prevents flex items from overflowing parent */
    }
    .team-name {
        white-space: normal;
        word-break: break-word;
    }
    .pitcher-split {
        display: none;
    }
    .game-meta {
        flex: 0 1 auto;
        max-width: 55%; /* Forces long locations and badges to wrap */
        width: auto;
    }
    .game-location {
        white-space: normal;
        word-break: break-word;
    }
    .sidebar-right {
        margin-top: 1rem;
    }
}

/* TOAST NOTIFICATION */
.toast-notification {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    background: var(--bg-panel);
    border: 1px solid var(--border-main);
    border-radius: 50px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    opacity: 0;
    pointer-events: none;
}

.toast-icon {
    font-size: 24px;
}

.toast-success {
    border-color: rgba(236, 72, 153, 0.4);
}
.toast-success .toast-icon {
    color: #f472b6;
}

.toast-error {
    border-color: rgba(239, 68, 68, 0.4);
}
.toast-error .toast-icon {
    color: #ef4444;
}

.toast-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}

.toast-notification.success-anim {
    animation: popupBottomRight 3s forwards cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes popupBottomRight {
    0% { transform: translateY(50px); opacity: 0; }
    10% { transform: translateY(0); opacity: 1; }
    90% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(50px); opacity: 0; }
}

.toast-notification.error-anim {
    animation: popupBottomRight 5s forwards cubic-bezier(0.4, 0, 0.2, 1);
}
