/**
 * Live Scoreboard CSS
 * Responsive scoreboard, fixtures grid, admin controls, and timeline styles.
 */

:root {
    --scoreboard-navy: #17335c;
    --scoreboard-blue: #2a5caa;
    --scoreboard-gold: #ffd166;
    --scoreboard-ice: #eef4ff;
    --scoreboard-ink: #122033;
    --scoreboard-muted: #66758c;
    --scoreboard-panel: #ffffff;
    --scoreboard-line: #d9e1ee;
    --scoreboard-success: #1f9d55;
    --scoreboard-warning: #f0b429;
    --scoreboard-danger: #d64545;
    --scoreboard-shadow: 0 14px 36px rgba(18, 32, 51, 0.18);
}

.scoreboard-shell {
    margin: 20px auto;
    max-width: 920px;
}

.scoreboard-shell.compact {
    margin: 0;
    max-width: none;
}

.scoreboard-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px 16px;
    margin-bottom: 10px;
    color: var(--scoreboard-ink);
}

.scoreboard-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.scoreboard-pitch,
.fixture-pitch,
.compact-meta {
    color: var(--team-meta-color, var(--scoreboard-muted));
    font-size: 0.9rem;
}

.scoreboard {
    font-family: Arial, sans-serif;
    background: linear-gradient(135deg, var(--scoreboard-navy) 0%, var(--scoreboard-blue) 100%);
    border-radius: 20px;
    box-shadow: var(--scoreboard-shadow);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.scoreboard.compact {
    border-radius: 16px;
    box-shadow: none;
}

.scoreboard .border {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: stretch;
    gap: 16px;
    padding: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
}

.team {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 12px;
    min-width: 0;
    padding: 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.12);
}

.team-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-width: 0;
}

.team-copy {
    flex: 1;
    min-width: 0;
}

.team-logo {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border: 3px solid rgba(255, 255, 255, 0.82);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.22);
    flex-shrink: 0;
}

.team-logo img {
    width: 78%;
    height: 78%;
    object-fit: contain;
    display: block;
}

.team-name {
    color: var(--team-text-color, #fff);
    font-size: clamp(1rem, 1.8vw, 1.18rem);
    font-weight: 700;
    line-height: 1.2;
    white-space: normal;
    word-break: break-word;
    text-align: left;
}

.team-score {
    color: var(--team-score-color, var(--scoreboard-gold));
    font-size: clamp(2rem, 4vw, 3.4rem);
    font-weight: 800;
    line-height: 1;
    flex-shrink: 0;
    min-width: 2.4ch;
    text-align: right;
}

.away-team .team-name {
    text-align: right;
}

.away-team .team-body {
    justify-content: flex-end;
}

.away-team .team-copy {
    text-align: right;
}

.team-score.score-changed {
    transform: scale(1.08);
}

.timer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 128px;
    text-align: center;
    color: #fff;
}

.timer {
    min-width: 110px;
    padding: 12px 16px;
    border-radius: 14px;
    background: rgba(6, 13, 26, 0.28);
    font-size: clamp(1.25rem, 2vw, 2rem);
    font-weight: 700;
    letter-spacing: 0.04em;
}

.timer.active {
    background: rgba(31, 157, 85, 0.28);
    animation: pulse 2s infinite;
}

.timer.inactive {
    background: rgba(214, 69, 69, 0.22);
}

.half-indicator {
    margin-top: 10px;
    font-size: 0.86rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.8);
}

.timer-summary-only {
    min-width: 0;
}

.timer-summary-only .half-indicator {
    margin-top: 0;
    font-size: 0.95rem;
}

.scoreboard.game-off {
    opacity: 0.93;
}

.pre-match-config {
    width: 100%;
    margin-bottom: 14px;
    padding: 18px;
    border: 1px solid rgba(42, 92, 170, 0.16);
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(239, 245, 255, 0.96)),
        linear-gradient(135deg, rgba(23, 51, 92, 0.08), rgba(42, 92, 170, 0.02));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.88),
        0 12px 24px rgba(18, 32, 51, 0.08);
    position: relative;
}

.pre-match-config::before {
    content: "Pre-match setup";
    display: inline-flex;
    align-items: center;
    margin-bottom: 14px;
    padding: 6px 11px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--scoreboard-navy), var(--scoreboard-blue));
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.pre-match-config-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    gap: 14px;
    margin-bottom: 16px;
}

.pre-match-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: var(--scoreboard-ink);
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.pre-match-field span:first-child {
    color: var(--scoreboard-muted);
}

.pre-match-field select,
.pre-match-field input {
    width: 100%;
    min-height: 48px;
    border: 1px solid rgba(23, 51, 92, 0.12);
    border-radius: 14px;
    background: #fff;
    box-shadow: inset 0 1px 2px rgba(18, 32, 51, 0.04);
    color: var(--scoreboard-ink);
    font-size: 0.98rem;
    font-weight: 700;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.pre-match-field select {
    appearance: none;
    padding: 0 48px 0 16px;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--scoreboard-blue) 50%),
        linear-gradient(135deg, var(--scoreboard-blue) 50%, transparent 50%);
    background-position:
        calc(100% - 22px) calc(50% - 2px),
        calc(100% - 16px) calc(50% - 2px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

.pre-match-field input {
    padding: 0 14px;
}

.pre-match-field select:focus,
.pre-match-field input:focus {
    outline: none;
    border-color: rgba(37, 99, 235, 0.4);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.pre-match-inline {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pre-match-half-duration {
    max-width: 110px;
    text-align: center;
}

.pre-match-suffix {
    color: var(--scoreboard-muted);
    font-size: 0.92rem;
    font-weight: 700;
    white-space: nowrap;
}

.live-fixtures-container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 12px;
}

.live-fixtures-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 18px;
}

.fixture-card {
    background: var(--scoreboard-panel);
    border-radius: 20px;
    box-shadow: var(--scoreboard-shadow);
    overflow: hidden;
}

.fixture-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.live-scoreboard-day-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.fixture-card-link:hover,
.fixture-card-link:focus,
.live-scoreboard-day-link:hover,
.live-scoreboard-day-link:focus {
    color: inherit;
    text-decoration: none;
}

.fixture-card:hover {
    transform: translateY(-2px);
}

.fixture-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px 16px;
    padding: 16px 18px 10px;
}

.fixture-title {
    color: var(--scoreboard-ink);
    font-size: 1rem;
    font-weight: 700;
}

.fixture-state {
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.fixture-state.active {
    background: #daf5e6;
    color: #17663a;
}

.fixture-state.inactive {
    background: #e7edf5;
    color: #516075;
}

.fixture-scoreboard {
    padding: 0 14px 14px;
}

.fixture-scoreboard .scoreboard .border {
    grid-template-columns: 1fr;
    gap: 12px;
}

.fixture-scoreboard .team {
    padding: 14px;
}

.fixture-scoreboard .timer-container {
    min-width: 0;
    order: -1;
}

.fixture-scoreboard .team-logo {
    display: none;
}

.fixture-scoreboard .team-name {
    font-size: 0.98rem;
}

.fixture-scoreboard .compact-meta {
    display: none;
}

.no-fixtures {
    padding: 56px 20px;
    text-align: center;
    color: var(--scoreboard-muted);
}

.fixtures-pagination {
    padding: 14px 4px 0;
    text-align: center;
    color: var(--scoreboard-muted);
}

.loading {
    padding: 40px 20px;
    text-align: center;
    color: #fff;
}

.scoreboard.loading {
    background: linear-gradient(135deg, #5b6777 0%, #384455 100%);
}

.spinner {
    width: 30px;
    height: 30px;
    margin: 0 auto 16px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--scoreboard-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.scoreboard.error {
    background: linear-gradient(135deg, #b83d3d 0%, #8f2727 100%);
}

.scoreboard-error {
    margin: 20px 0;
    padding: 15px;
    border: 1px solid #f4c4c4;
    border-radius: 8px;
    background: #fff0f0;
    color: #7a1f1f;
}

.scoreboard-controls {
    margin-top: 18px;
    background: #fff;
    border-radius: 18px;
    box-shadow: var(--scoreboard-shadow);
    overflow: hidden;
}

.match-controls {
    padding: 20px;
    background:
        radial-gradient(circle at top right, rgba(42, 92, 170, 0.08), transparent 32%),
        linear-gradient(180deg, #f8fbff 0%, #f2f6fc 100%);
    border-bottom: 1px solid var(--scoreboard-line);
}

.match-controls h4,
.event-timeline h4 {
    margin: 0 0 14px;
    color: var(--scoreboard-ink);
}

.control-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: 0;
    border-radius: 999px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(18, 32, 51, 0.12);
    transition: filter 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
    filter: brightness(0.96);
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(18, 32, 51, 0.16);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    filter: none;
    box-shadow: none;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-secondary {
    background: #64748b;
    color: #fff;
}

.btn-success {
    background: #1f9d55;
    color: #fff;
}

.btn-warning {
    background: #f0b429;
    color: #1f2937;
}

.btn-danger {
    background: #d64545;
    color: #fff;
}

.btn-info {
    background: #0ea5b7;
    color: #fff;
}

.finished-message {
    padding: 12px 14px;
    border-radius: 12px;
    background: #e3f6ea;
    color: #17663a;
    font-weight: 700;
}

.team-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.team-control-selector {
    display: none;
    gap: 10px;
    padding: 16px 20px 0;
}

.btn-selector {
    background: #e7edf5;
    color: var(--scoreboard-ink);
}

.btn-selector.is-selected {
    background: var(--scoreboard-blue);
    color: #fff;
}

.team-control-section {
    padding: 20px;
}

.team-control-section:first-child {
    border-right: 1px solid var(--scoreboard-line);
}

.team-control-section h5 {
    margin: 0 0 14px;
    color: var(--scoreboard-ink);
    font-size: 1rem;
}

.scoring-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.card-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.event-timeline {
    padding: 20px;
    border-top: 1px solid var(--scoreboard-line);
    background: #fff;
}

.timeline {
    position: relative;
}

.timeline::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 18px;
    width: 2px;
    background: var(--scoreboard-line);
}

.timeline-item {
    position: relative;
    margin-bottom: 16px;
    padding-left: 58px;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-marker {
    position: absolute;
    top: 12px;
    left: 18px;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 999px;
    background: #2563eb;
    color: #fff;
    box-shadow: 0 0 0 4px #fff;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    transform: translateX(-50%);
}

.timeline-marker.match {
    min-width: 18px;
    width: 18px;
    height: 18px;
    padding: 0;
    border-radius: 50%;
    background: #0f766e;
}

.timeline-marker.card {
    min-width: 18px;
    width: 18px;
    height: 26px;
    padding: 0;
    border-radius: 4px;
}

.timeline-marker.yellow-card {
    background: #facc15;
}

.timeline-marker.red-card {
    background: #dc2626;
}

.timeline-content {
    position: relative;
    padding: 14px 16px;
    border: 2px solid #2563eb;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 6px 18px rgba(18, 32, 51, 0.08);
}

.timeline-content.away {
    background: #f8fbff;
}

.major-match-event .timeline-marker.match {
    width: 22px;
    min-width: 22px;
    height: 22px;
    background: linear-gradient(135deg, #d97706, #f59e0b);
    box-shadow: 0 0 0 4px #fff, 0 8px 18px rgba(217, 119, 6, 0.28);
}

.timeline-content-major {
    background: linear-gradient(135deg, #fff7ed 0%, #fffbeb 100%);
    border-width: 3px;
    background-clip: padding-box;
    box-shadow: 0 10px 24px rgba(217, 119, 6, 0.14);
}

.timeline-content-major p {
    font-weight: 800;
    letter-spacing: 0.01em;
}

.timeline-content p {
    margin: 0;
    padding-right: 26px;
    color: var(--scoreboard-ink);
    line-height: 1.45;
}

.delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 50%;
    background: var(--scoreboard-danger);
    color: #fff;
    cursor: pointer;
}


.wp-admin .scoreboard-shell {
    margin: 10px 0;
    max-width: none;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

@media (max-width: 900px) {
    .scoreboard .border {
        grid-template-columns: 1fr;
    }

    .timer-container {
        min-width: 0;
        order: -1;
    }

    .team-controls {
        grid-template-columns: 1fr;
    }

    .team-control-selector {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .team-control-section {
        display: none;
        border-right: 0;
        border-bottom: 0;
    }

    .team-control-section.is-selected {
        display: block;
    }

}

@media (max-width: 640px) {
    .live-fixtures-container {
        padding: 8px;
    }

    .live-fixtures-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .fixture-header {
        flex-direction: column;
        align-items: stretch;
    }

    .scoreboard-shell {
        margin: 14px auto;
    }

    .pre-match-config {
        padding: 16px;
        border-radius: 16px;
    }

    .pre-match-config-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .pre-match-inline {
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
    }

    .pre-match-half-duration {
        max-width: none;
        text-align: left;
    }

    .pre-match-suffix {
        font-size: 0.84rem;
    }

    .scoreboard .border {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: 14px;
        gap: 12px;
        align-items: stretch;
    }

    .timer-container {
        grid-column: 1 / -1;
        order: -1;
    }

    .team {
        gap: 10px;
        padding: 12px;
    }

    .team-body {
        justify-content: center;
        gap: 10px;
    }

    .team-copy {
        display: none;
    }

    .team-name,
    .away-team .team-name,
    .away-team .team-copy {
        text-align: center;
    }

    .team-score {
        font-size: clamp(1.8rem, 10vw, 2.8rem);
        min-width: 1.6ch;
        text-align: center;
    }

    .team-logo {
        width: 48px;
        height: 48px;
    }

    .timer {
        min-width: 0;
        width: 100%;
    }

    .half-indicator {
        font-size: 0.8rem;
    }

    .match-controls,
    .team-control-section,
    .event-timeline {
        padding: 16px;
    }

    .control-buttons,
    .scoring-buttons,
    .card-buttons {
        grid-template-columns: 1fr;
    }

    .control-buttons {
        display: grid;
    }

    .btn {
        width: 100%;
    }

    .timeline::before {
        left: 14px;
    }

    .timeline-item {
        padding-left: 44px;
    }

    .timeline-marker {
        left: 14px;
        min-width: 24px;
        height: 24px;
        padding: 0 6px;
        font-size: 0.66rem;
    }

    .timeline-marker.match {
        min-width: 16px;
        width: 16px;
        height: 16px;
    }

    .timeline-marker.card {
        min-width: 16px;
        width: 16px;
        height: 22px;
    }

    .timeline-content p {
        padding-right: 22px;
        font-size: 0.95rem;
    }
}

@media print {
    .scoreboard-controls,
    .delete-btn,
    .control-buttons {
        display: none !important;
    }

    .scoreboard {
        box-shadow: none;
        border: 2px solid #333;
    }
}
