/* ============================================
   LiveLeagueFPL - Design System
   ============================================

   Color Palette:
   - Background:     #12141a (near-black, cool undertone)
   - Surface:        #1a1d24 (cards, inputs)
   - Elevated:       #252a33 (headers, hover states)
   - Border:         #2d323c

   - Text Primary:   #e3e5e8
   - Text Secondary: #8b929b
   - Text Muted:     #5c6370

   - Accent:         #4db6ac (muted teal - "live/data" feel)
   - Accent Hover:   #3d9d94

   - Success:        #6bcf7f (rank up)
   - Error:          #e06c75 (rank down, errors)

   ============================================ */

:root {
    --bg-base: #12141a;
    --bg-surface: #1a1d24;
    --bg-elevated: #252a33;
    --border: #2d323c;

    --text-primary: #e3e5e8;
    --text-secondary: #8b929b;
    --text-muted: #5c6370;

    --accent: #4db6ac;
    --accent-hover: #3d9d94;
    --accent-subtle: rgba(77, 182, 172, 0.15);

    --accent-orange: #b6654d;
    --accent-orange-hover: #9d5542;
    --accent-orange-subtle: rgba(182, 101, 77, 0.15);

    --success: #6bcf7f;
    --error: #e06c75;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    margin: 0;
    padding: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 600px;
    margin: 0 auto;
}

/* ============================================
   Title Treatment
   ============================================ */

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 24px 0;
    letter-spacing: -0.02em;
}

h1 .live {
    color: var(--accent);
}

h2 {
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

/* ============================================
   Controls (Input, Button, Select)
   ============================================ */

.controls {
    margin-bottom: 20px;
}

.controls label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

#team-input-section {
    margin-bottom: 16px;
}

.input-group {
    display: flex;
    gap: 8px;
}

.input-group input {
    flex: 1;
    min-width: 0;
    padding: 12px 14px;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-surface);
    color: var(--text-primary);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.input-group button {
    padding: 12px 20px;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: var(--bg-base);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
}

.input-group button:hover {
    background: var(--accent-hover);
}

.input-group button:active {
    transform: scale(0.98);
}

.help-text {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.help-text strong {
    color: var(--accent);
}

.help-text a {
    color: var(--accent);
    text-decoration: none;
}

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

#league-section {
    margin-top: 16px;
}

.controls select {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.15s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b929b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.controls select:focus {
    outline: none;
    border-color: var(--accent);
}

/* ============================================
   League Info Header
   ============================================ */

#league-info {
    margin-bottom: 16px;
    padding: 16px;
    background: var(--bg-surface);
    border-radius: 10px;
    border: 1px solid var(--border);
}

#league-info p {
    margin: 8px 0 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.deadline {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* ============================================
   Live Match Indicator
   ============================================ */

#live-match {
    padding: 12px 16px;
    background: var(--accent-orange-subtle);
    border: 1px solid var(--accent-orange);
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

#live-match::before {
    content: '';
    width: 8px;
    height: 8px;
    min-width: 8px;
    background: var(--accent-orange);
    border-radius: 50%;
    animation: pulse-orange 2s ease-in-out infinite;
    margin-top: 5px;
}

#live-match.hidden {
    display: none;
}

#live-match .live-match-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#live-match .match-score {
    font-weight: 600;
}

#live-match .match-goals,
#live-match .match-reds,
#live-match .match-yellows {
    font-size: 0.85rem;
    font-weight: 400;
    opacity: 0.9;
}

#live-match .match-spacer {
    font-size: 0.85rem;
    visibility: hidden;
}

#live-match .carousel-dots {
    font-size: 0.625rem;
    color: var(--text-muted);
    letter-spacing: 2px;
    margin-left: auto;
    opacity: 0.7;
    align-self: center;
}

/* Refresh pulse animation */
#live-match.refreshing {
    animation: refresh-pulse 0.6s ease-out;
}

@keyframes refresh-pulse {
    0% {
        background: var(--accent-orange-subtle);
        border-color: var(--accent-orange);
    }
    50% {
        background: rgba(182, 101, 77, 0.35);
        border-color: #d4785c;
    }
    100% {
        background: var(--accent-orange-subtle);
        border-color: var(--accent-orange);
    }
}

@keyframes pulse-orange {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.1); }
}

/* ============================================
   Banner Stack
   ============================================ */

#banner-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

#banner-stack:empty {
    display: none;
}

.banner-item {
    padding: 10px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--accent);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: banner-fade-in 0.3s ease;
}

.banner-item .banner-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
    min-width: 45px;
}

.banner-item .banner-text {
    flex: 1;
}

.banner-share {
    padding: 4px 10px;
    font-size: 0.6875rem;
    font-weight: 600;
    border: 1px solid var(--accent);
    border-radius: 4px;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.banner-share:hover {
    background: var(--accent);
    color: var(--bg-base);
}

@keyframes banner-fade-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Live Indicator
   ============================================ */

.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.live-indicator::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(77, 182, 172, 0.5);
    }
    50% {
        opacity: 0.7;
        box-shadow: 0 0 0 6px rgba(77, 182, 172, 0);
    }
}

/* ============================================
   Standings Table
   ============================================ */

#standings-container {
    transition: opacity 0.15s ease-out;
}

#standings-container.loading {
    opacity: 0.4;
}

#standings-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-surface);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    font-size: 0.9375rem;
}

#standings-table th,
#standings-table td {
    padding: 12px;
    text-align: left;
}

#standings-table th {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.6875rem;
    letter-spacing: 0.05em;
}

#standings-table tbody tr {
    border-top: 1px solid var(--border);
}

#standings-table tbody tr:hover {
    background: var(--bg-elevated);
}

/* Numeric columns right-aligned */
#standings-table th:nth-child(3),
#standings-table th:nth-child(4),
#standings-table th:nth-child(5),
#standings-table td:nth-child(3),
#standings-table td:nth-child(4),
#standings-table td:nth-child(5) {
    text-align: right;
}

/* Rank column */
#standings-table td:first-child {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Entry info hierarchy */
.team-name-primary {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.manager-name-secondary {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.captain-info {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.captain-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 14px;
    font-size: 0.5625rem;
    font-weight: 700;
    border-radius: 3px;
    background: var(--border);
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* Chip badges */
.chip-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    border-radius: 4px;
    text-transform: uppercase;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.chip-3xc {
    background: rgba(77, 182, 172, 0.15);
    color: var(--accent);
    border-color: rgba(77, 182, 172, 0.3);
}

.chip-bboost {
    background: rgba(107, 207, 127, 0.15);
    color: var(--success);
    border-color: rgba(107, 207, 127, 0.3);
}

.chip-freehit {
    background: rgba(178, 132, 190, 0.15);
    color: #b284be;
    border-color: rgba(178, 132, 190, 0.3);
}

.chip-wildcard {
    background: rgba(240, 180, 89, 0.15);
    color: #f0b459;
    border-color: rgba(240, 180, 89, 0.3);
}

/* Transfer hit indicator */
.transfer-hit {
    color: var(--error);
    font-size: 0.75rem;
    opacity: 0.9;
}

/* ============================================
   Rank Change Indicators
   ============================================ */

.rank-up {
    color: var(--success);
    font-size: 0.6875rem;
    font-weight: 600;
    margin-left: 4px;
}

.rank-down {
    color: var(--error);
    font-size: 0.6875rem;
    font-weight: 600;
    margin-left: 4px;
}

/* ============================================
   Status Bar
   ============================================ */

#status {
    margin-top: 16px;
    font-size: 0.8125rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

#loading {
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 6px;
}

#loading::before {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid var(--accent-subtle);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.error {
    color: var(--error);
}

.hidden {
    display: none !important;
}

/* ============================================
   Responsive Adjustments
   ============================================ */

@media (max-width: 480px) {
    body {
        padding: 12px;
    }

    #standings-table th,
    #standings-table td {
        padding: 10px 8px;
    }

    #standings-table {
        font-size: 0.875rem;
    }

    .manager-name-secondary {
        font-size: 0.75rem;
    }

    .captain-info {
        font-size: 0.6875rem;
    }

    /* Hide "Players Left" column on very small screens */
    #standings-table th:nth-child(5),
    #standings-table td:nth-child(5) {
        display: none;
    }
}

/* ============================================
   Mock Mode
   ============================================ */

body.mock-mode {
    border-top: 3px solid var(--accent-orange);
}

body.mock-mode h1 .live {
    color: var(--accent-orange);
}

.mock-controls {
    background: var(--bg-surface);
    border: 1px solid var(--accent-orange);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}

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

.mock-badge {
    background: var(--accent-orange);
    color: var(--bg-base);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.mock-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mock-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.mock-group label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 50px;
}

.mock-group select {
    padding: 6px 10px;
    font-size: 0.8125rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-base);
    color: var(--text-primary);
}

.mock-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    background: var(--accent-orange);
    color: var(--bg-base);
    cursor: pointer;
    transition: background 0.15s ease;
}

.mock-btn:hover {
    background: var(--accent-orange-hover);
}

.mock-reset {
    background: var(--error);
}

.mock-reset:hover {
    background: #c95a62;
}

.mock-log {
    margin-top: 10px;
    font-size: 0.75rem;
    font-family: monospace;
    color: var(--text-muted);
    min-height: 1.2em;
}

/* ============================================
   Public League View
   ============================================ */

.public-league-notice {
    background: var(--accent-subtle);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 12px 16px;
}

.public-league-notice p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.public-league-notice a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.public-league-notice a:hover {
    text-decoration: underline;
}

#team-picker {
    width: 100%;
    margin-top: 10px;
    padding: 12px 14px;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--card-bg);
    color: var(--text);
    cursor: pointer;
}

#team-picker:focus {
    outline: none;
    border-color: var(--accent);
}

/* ============================================
   Notification Bell
   ============================================ */

.notify-bell {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    margin-left: 12px;
    opacity: 0.5;
    transition: opacity 0.2s ease, transform 0.2s ease;
    vertical-align: middle;
}

.notify-bell:hover {
    opacity: 1;
    transform: scale(1.1);
}

.notify-bell.subscribed {
    opacity: 1;
}

.notify-bell.subscribed::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    margin-left: -8px;
    margin-top: -4px;
}

/* ============================================
   Missed Events Recap
   ============================================ */

.missed-events {
    background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-elevated) 100%);
    border: 1px solid var(--accent);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 16px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.missed-events-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--accent);
    font-size: 0.875rem;
}

.dismiss-recap {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.dismiss-recap:hover {
    color: var(--text-primary);
}

.missed-event-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-top: 1px solid var(--border);
    font-size: 0.875rem;
}

.missed-event-item:first-of-type {
    border-top: none;
}

.event-emoji {
    font-size: 1rem;
    min-width: 24px;
    text-align: center;
}

.event-text {
    color: var(--text-primary);
}

/* ============================================
   View History Link
   ============================================ */

.view-history-link {
    display: block;
    text-align: center;
    padding: 10px;
    margin-top: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.15s ease;
}

.view-history-link:hover {
    color: var(--accent);
}
