@charset "utf-8";
/* ***********************************************************************
 *
 *  File:   livescore.css
 *
 *  Brief:  Styles for the live score page, including the flex layout, score feed tables,
 *
 *  Author: Jomar Hønsi, 2026
 *
 * ************************************************************************/

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

    100% {
        transform: rotate(360deg);
    }
}

/* Root */
:root {
    --dot-dimension: 8px;
}

/* Error message */
p.fail {
    color: red;
    font-size: 14px;
}

div.info-container {
    max-width: 100%;
    margin: 0 auto 10px;
    padding: 0;
    text-align: center;

    & span {
        font-size: 13px;
        color: #555;
        display: block;
        margin-bottom: 4px;
    }

    & span#live-match-count {
        display: block;
        font-size: 11px;
        color: #888;
        text-align: center;
        min-height: 16px;
        margin-bottom: 4px;
    }
}

div.flex-layout {
    display: flex;
    align-items: flex-start;
    margin: 0 auto;

    & div {
        flex: 1 1 0;
        min-width: 0;
        margin: 5px;
        padding: 10px;
        border-radius: 8px;
        background-color: var(--bg-text-panel);
    }

    & div#live-container {
        position: relative;
    }

    & div p {
        color: #333;
        font-size: 12px;
    }

    & div#live-score-data {
        & div#live-loader {
            border: 5px solid #075519;
            border-top: 5px solid #e7ddda;
            border-radius: 50%;
            width: 20px;
            height: 20px;
            animation: spin 2s linear infinite;
            display: none;
            margin: 10px auto;
        }

        & p {
            font-size: 14px;
            color: #333;
            margin: 10px 0;
            text-align: justify;
        }

        & .date-header {
            font-size: 13px;
            margin: 5px;
            color: #1c0766;
            text-align: left;
            font-weight: bold;
            cursor: pointer;
            user-select: none;
        }

        & .date-header .toggle-icon {
            display: inline-block;
            font-style: normal;
            transition: transform 0.2s;
        }

        & table.livescore.collapsed .toggle-icon {
            transform: rotate(-90deg);
        }

        & .date-header.today {
            text-shadow: 0 0 6px rgba(100, 60, 200, 0.5);
            font-size: 14px;
        }
    }
}

table.match {
    margin: 0;
    border: 0;
}

/* Popup */
div#alert {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    border: 2px solid #444;
    padding: 10px 16px;
    min-width: 280px;
    display: block;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border-radius: 12px;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 9999;

    & div {
        background-color: #333;
    }

    & .alert-goal {
        font-size: 15px;
        font-weight: bold;
        color: #f0c040;
        letter-spacing: 2px;
        margin-bottom: 6px;
    }

    & .alert-teams {
        font-size: 14px;
        color: #dde;
        margin-bottom: 4px;
    }

    & .alert-score {
        font-size: 22px;
        font-weight: bold;
        color: #7fff7f;
    }
}

audio#audio1 {
    display: none;
}

/* League selector button */
div#live-score-controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-evenly;
    gap: 8px;
    margin: 0 0 4px;
    padding: 6px 10px;
    background: linear-gradient(to bottom, #f5f5f5, #e8e8e8);
    border-radius: var(--border-radius);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

th.session-header-live {
    font-size: 12px;
    font-weight: normal;
    padding: 16px 12px;
    background: linear-gradient(to bottom, #f5f5f5, #e8e8e8);
    border-radius: var(--border-radius);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.6);

    & span {
        padding: 2px 6px;
        font-size: 12px;
        color: #666;
        margin-top: 4px;

        & b {
            color: #08843a;
            font-size: 16px;
            padding: 0 10%;
            letter-spacing: 1.5px;
        }
    }
}

span#league-selection-label,
div#select-display {
    font-size: 12px;
    background-color: transparent;
    font-style: italic;
    align-self: center;
}

div#select-display {
    position: relative;
    user-select: none;

    & .selection-popup {
        position: absolute;
        bottom: calc(100% + 4px);
        left: 0;
        z-index: 100;
        background: #fff;
        border: 1px solid #ccc;
        border-radius: var(--border-radius);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        padding: 6px 0;
        min-width: 160px;
        font-style: normal;
        white-space: nowrap;
    }

    & .selection-popup-heading {
        padding: 4px 12px 6px;
        font-size: 11px;
        font-weight: bold;
        font-style: normal;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #666;
        border-bottom: 1px solid #e0e0e0;
        margin-bottom: 2px;
    }

    & .selection-popup div {
        padding: 4px 12px;
        font-size: 12px;

        &:hover {
            background-color: #f0f0f0;
        }
    }
}

button#league-select-btn {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: var(--border-radius);
    border: 1px solid var(--bg-header);
    background-color: var(--bg-header);
    color: var(--hf-text);
    cursor: pointer;

    &:hover {
        opacity: 0.8;
    }
}

/* League selection modal */
dialog#league-modal {
    border: none;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    min-width: 200px;

    & h3 {
        margin: 0;
        padding: 10px 16px;
        background-color: var(--bg-header);
        color: var(--hf-text);
        border-radius: 8px 8px 0 0;
        font-size: 14px;
        letter-spacing: 1px;
    }

    & #league-checkboxes {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 14px 16px;

        & label {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 14px;
            cursor: pointer;
        }

        & input[type=checkbox] {
            width: 16px;
            height: 16px;
            accent-color: var(--bg-header);
            cursor: pointer;
        }
    }

    & .modal-actions {
        display: flex;
        justify-content: flex-end;
        gap: 8px;
        padding: 10px 16px;
        border-top: 1px solid #ddd;

        & button {
            padding: 5px 14px;
            border-radius: var(--border-radius);
            border: 1px solid #888;
            cursor: pointer;
            font-size: 13px;
        }

        & #league-modal-apply {
            background-color: var(--bg-header);
            color: var(--hf-text);
            border-color: var(--bg-header);

            &:hover {
                opacity: 0.85;
            }
        }

        & #league-modal-cancel:hover {
            background-color: #eee;
        }
    }
}

dialog#league-modal::backdrop {
    background: rgba(0, 0, 0, 0.35);
}

/* Live score feed */
span.update-info {
    display: block;
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
    text-align: center;
    padding: 10px;
}

@keyframes blink-red {
    0%, 100% {
        color: #08843a;
    }

    50% {
        color: red;
    }
}

@keyframes live-dot-pulse {
    0%, 80%, 100% {
        opacity: 1;
    }

    90% {
        opacity: 0;
    }
}

span#update-ts {
    font-size: 12px;
    color: #08843a;
    align-self: center;

    &.blink-red {
        animation: blink-red 1s ease-in-out 5;
    }
}

table.livescore {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;

    & col.col-home,
    & col.col-away {
        width: 30%;
    }

    & col.col-time {
        width: 10%;
    }

    & col.col-score {
        width: 10%;
    }

    & col.col-live {
        width: 5%;
    }

    & th {
        background-color: #cde;
        color: #333;
        padding: 4px 6px;
        text-align: left;
    }

    & td {
        padding: 3px 6px;
        border-bottom: 1px solid #ccc;
        text-align: left;
    }

    & .col-score {
        text-align: center;
        font-weight: bold;
        white-space: nowrap;
    }

    & th:nth-child(5),
    & th:nth-child(6),
    & td:nth-child(5),
    & td:nth-child(6) {
        text-align: center;
    }

    &.today {
        outline: 2px solid #055242;
    }

    & tr.match-live {
        background-color: #ffffcc;
        font-weight: bold;
    }

    & span.live-dot {
        display: block;
        width: var(--dot-dimension);
        height: var(--dot-dimension);
        margin: auto;
        border-radius: 50%;
        background: radial-gradient(circle at 35% 35%, #a8ffca, #22c55e 50%, #0d6b35);
        box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
        animation: live-dot-pulse 10s ease-in-out infinite;
    }

    & tr.match-finished {
        color: #666;
    }

    & tr.match-betting {
        background-color: #fff4e0;
        font-weight: bold;
    }

    &.collapsed thead,
    &.collapsed tbody {
        display: none;
    }
}

p.no-matches {
    font-size: 13px;
    color: #888;
    padding: 10px 0;
}

/* ---- Mobile / narrow-screen layout ---- */
@media (max-width: 700px) {

    /* Stack the two panels vertically */
    div.flex-layout {
        flex-direction: column;

        & div {
            margin: 4px 0;
        }
    }

    /* Fix the score alert: switch from absolute (inside panel) to fixed (viewport) */
    div#live-container {
        position: static;
    }

    div#alert {
        position: fixed;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        min-width: 240px;
        max-width: calc(100vw - 32px);
    }

    /* Controls bar: wrap and centre on small screens */
    div#live-score-controls {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    span#update-ts {
        width: 100%;
    }

    /* Livescore table: hide the Status column to save space */
    table.livescore {
        font-size: 11px;

        & col.col-status {
            display: none;
        }

        & thead tr th:nth-child(5),
        & tbody tr td:nth-child(5) {
            display: none;
            text-align: center;
        }

        & col.col-home,
        & col.col-away {
            width: 33%;
        }

        & col.col-time {
            width: 16%;
        }

        & col.col-score {
            width: 18%;
        }

        & col.col-live {
            width: 5%;
        }
    }

    span.update-info {
        font-size: 12px;
        padding: 6px;
    }
}