/* =========================================================
   BPD GAMING NETWORK
   SCOREBOARD OCR PAGE
   ========================================================= */


/* =========================================================
   BASE
   ========================================================= */

* {
    box-sizing: border-box;
}

html {
    color-scheme: dark;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family:
        "Segoe UI",
        Arial,
        sans-serif;
    background: #0b0d12;
    color: #ffffff;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}


/* =========================================================
   PAGE
   ========================================================= */

.page {
    width: min(
        1240px,
        calc(100% - 32px)
    );
    margin: 0 auto;
    padding: 32px 0 48px;
}

.panel {
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.035);
}


/* =========================================================
   HEADER
   ========================================================= */

.page-header {
    margin-bottom: 28px;
}

.page-header-content {
    max-width: 860px;
}

.page-eyebrow {
    margin-bottom: 6px;
    color: #38bdf8;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.page-title {
    margin: 0 0 8px;
    font-size: 30px;
    line-height: 1.2;
}

.page-subtitle {
    margin: 0;
    color: #9aa4b2;
    line-height: 1.55;
}


/* =========================================================
   SECTION HEADINGS
   ========================================================= */

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.section-label {
    margin-bottom: 4px;
    color: #64748b;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.9px;
    text-transform: uppercase;
}

.section-title {
    margin: 0;
    font-size: 18px;
}


/* =========================================================
   SUBMISSION SECTION
   ========================================================= */

.submission-section {
    margin-bottom: 22px;
}

.controls {
    display: grid;
    grid-template-columns:
        minmax(180px, 240px)
        minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.field label {
    color: #cbd5e1;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}

.field-heading {
    display: flex;
    flex-direction: column;
    gap: 6px;
}


/* =========================================================
   FORM CONTROLS
   ========================================================= */

input[type="file"],
input[type="text"],
input[type="number"],
select,
button {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    outline: none;
    background: #151923;
    color: #ffffff;
    transition:
        border-color 0.15s ease,
        background 0.15s ease,
        box-shadow 0.15s ease,
        opacity 0.15s ease;
}

input[type="file"]:focus,
input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
button:focus-visible {
    border-color: #38bdf8;
    box-shadow:
        0 0 0 3px
        rgba(56, 189, 248, 0.12);
}

input[type="text"]::placeholder {
    color: #64748b;
}

input[type="file"] {
    cursor: pointer;
}

input[type="file"]::file-selector-button {
    margin-right: 10px;
    padding: 7px 10px;
    border: 0;
    border-radius: 7px;
    background: #232a38;
    color: #ffffff;
    cursor: pointer;
    font-weight: 700;
}

input[type="file"]::file-selector-button:hover {
    background: #2c3546;
}

select {
    cursor: pointer;
}

button {
    font-weight: 700;
}

button:hover:not(:disabled) {
    border-color: rgba(255, 255, 255, 0.24);
    background: #1d2330;
}


/* =========================================================
   PLAYER NAMES
   ========================================================= */

.player-names-field {
    grid-column: 1 / -1;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.025);
}

.player-names-help {
    color: #7f8b9d;
    font-size: 12px;
    line-height: 1.45;
}

.player-names-grid {
    display: grid;
    grid-template-columns:
        repeat(
            2,
            minmax(0, 1fr)
        );
    gap: 16px;
    margin-top: 6px;
}

.player-team-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.18);
}

.player-team-title {
    margin-bottom: 2px;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.player-name-input {
    text-transform: uppercase;
    font-weight: 600;
}


/* =========================================================
   IMAGE UPLOAD
   ========================================================= */

.image-upload-field {
    grid-column: 1 / -1;
}

.image-upload-control {
    display: grid;
    gap: 8px;
}

.image-upload-help {
    color: #64748b;
    font-size: 12px;
    line-height: 1.45;
}


/* =========================================================
   EXAMPLE
   ========================================================= */

.example-section {
    margin: 22px 0 26px;
}

.example-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 10px 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.035);
    color: inherit;
}

.example-toggle-label {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.example-toggle-arrow-box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 30px;
    flex-shrink: 0;
    margin-left: 12px;
    border: 1px solid rgba(56, 189, 248, 0.45);
    border-radius: 7px;
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        transform 0.18s ease;
}

.example-toggle:hover
.example-toggle-arrow-box {
    border-color: rgba(56, 189, 248, 0.70);
    background: rgba(56, 189, 248, 0.20);
}

.example-toggle:active
.example-toggle-arrow-box {
    transform: scale(0.94);
}

.example-content {
    margin-top: 10px;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
}

.example-content[hidden] {
    display: none;
}

.example-image {
    display: block;
    width: 100%;
    max-width: 900px;
    height: auto;
    margin: 0 auto;
    border-radius: 8px;
}

.example-help {
    margin-top: 10px;
    color: #7f8b9d;
    font-size: 12px;
    line-height: 1.5;
}


/* =========================================================
   SCOREBOARD PREVIEW
   ========================================================= */

.scoreboard-preview-section {
    margin-top: 24px;
}

.canvas-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 280px;
    overflow: hidden;
    border: 1px dashed rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    background: #080a0f;
}

#scoreboardCanvas {
    display: block;
    max-width: 100%;
    height: auto;
    cursor: default;
    touch-action: none;
    user-select: none;
}

#scoreboardCanvas[hidden] {
    display: none;
}

.empty-state {
    padding: 64px 20px;
    color: #64748b;
    text-align: center;
}


/* =========================================================
   CROP FALLBACK
   ========================================================= */

.crop-fallback {
    margin-top: 14px;
    padding: 14px;
    border: 1px solid rgba(245, 158, 11, 0.28);
    border-radius: 10px;
    background: rgba(245, 158, 11, 0.06);
}

.crop-fallback[hidden] {
    display: none;
}

.crop-fallback-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.crop-fallback-label {
    margin-bottom: 5px;
    color: #fbbf24;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.9px;
    text-transform: uppercase;
}

.crop-help {
    max-width: 760px;
    color: #cbd5e1;
    font-size: 13px;
    line-height: 1.5;
}

#resetCropBtn {
    width: auto;
    min-width: 130px;
    flex-shrink: 0;
}


/* =========================================================
   SUBMISSION ACTIONS
   ========================================================= */

.submission-actions-section {
    margin-top: 20px;
}

.actions {
    display: flex;
    gap: 12px;
}

.actions button {
    width: auto;
    min-width: 180px;
}

#submitBtn {
    background: #15231b;
    border-color: rgba(34, 197, 94, 0.35);
}

#submitBtn:hover:not(:disabled) {
    background: #193020;
    border-color: rgba(34, 197, 94, 0.60);
}


/* =========================================================
   LOADING
   ========================================================= */

.loading-wrap {
    width: 100%;
    margin-top: 16px;
    padding: 14px;
    border: 1px solid rgba(56, 189, 248, 0.18);
    border-radius: 10px;
    background: rgba(56, 189, 248, 0.035);
}

.loading-wrap[hidden] {
    display: none;
}

.loading-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

#loadingPercent {
    color: #38bdf8;
}

.loading-bar {
    position: relative;
    width: 100%;
    height: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.045);
}

.loading-fill {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(
        90deg,
        #0ea5e9,
        #38bdf8,
        #67e8f9
    );
    box-shadow:
        0 0 12px
        rgba(56, 189, 248, 0.45);
    transition: width 0.25s ease;
}


/* =========================================================
   STATUS
   ========================================================= */

.status {
    margin-top: 16px;
    padding: 14px 16px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: #cbd5e1;
    line-height: 1.45;
    white-space: pre-wrap;
}


/* =========================================================
   RESULTS MODAL
   ========================================================= */

.results-modal {
    width: min(
        1120px,
        calc(100% - 24px)
    );
    max-height: min(
        90vh,
        900px
    );
    padding: 0;
    overflow: hidden;
    border: 1px solid rgba(56, 189, 248, 0.28);
    border-radius: 16px;
    background: #10141d;
    color: #ffffff;
    box-shadow:
        0 24px 80px
        rgba(0, 0, 0, 0.62);
}

.results-modal::backdrop {
    background: rgba(3, 6, 12, 0.82);
    backdrop-filter: blur(5px);
}

.results-modal-card {
    max-height: min(
        90vh,
        900px
    );
    padding: 22px;
    overflow-y: auto;
}

.results-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.results-modal-label {
    margin-bottom: 4px;
    color: #38bdf8;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
}

.results-modal-header h2 {
    margin: 0;
    font-size: 23px;
}

.results-modal-description {
    margin: 7px 0 0;
    color: #94a3b8;
    font-size: 13px;
    line-height: 1.45;
}

.results-modal-close {
    width: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    flex-shrink: 0;
    font-size: 26px;
    line-height: 1;
}


/* =========================================================
   RESULTS REVIEW SECTION
   ========================================================= */

.results-review-section {
    margin-top: 4px;
}

.results-review-heading {
    margin-bottom: 12px;
}

.results-review-label {
    margin-bottom: 4px;
    color: #64748b;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.9px;
    text-transform: uppercase;
}

.results-review-heading h3 {
    margin: 0;
    font-size: 18px;
}

.results-summary {
    min-width: 0;
}


/* =========================================================
   REVIEW TABLE
   ========================================================= */

.ocr-review-help {
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.025);
    color: #94a3b8;
    font-size: 12px;
    line-height: 1.5;
}

.ocr-review-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.16);
}

.ocr-review-table {
    width: 100%;
    min-width: 940px;
    border-collapse: collapse;
    table-layout: auto;
}

.ocr-review-table th,
.ocr-review-table td {
    padding: 9px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    border-right: 1px solid rgba(255, 255, 255, 0.045);
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}

.ocr-review-table th:last-child,
.ocr-review-table td:last-child {
    border-right: 0;
}

.ocr-review-table tbody tr:last-child td {
    border-bottom: 0;
}

.ocr-review-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #151923;
    color: #94a3b8;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}

.ocr-review-table td {
    color: #e2e8f0;
    font-size: 12px;
}

.ocr-review-table td:nth-child(2) {
    max-width: 190px;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
}

.ocr-review-table td:nth-child(3) {
    color: #94a3b8;
    font-weight: 700;
    text-transform: capitalize;
}


/* =========================================================
   FULL OCR REPORT
   ========================================================= */

.results-details {
    margin-top: 18px;
}

.results-details summary {
    cursor: pointer;
    color: #94a3b8;
    font-size: 12px;
    font-weight: 700;
}

.results-details pre {
    max-height: 360px;
    margin: 10px 0 0;
    padding: 14px;
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 9px;
    background: #080a0f;
    color: #dbeafe;
    font-family:
        Consolas,
        "Courier New",
        monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}


/* =========================================================
   RESPONSIVE - TABLET
   ========================================================= */

@media (
    max-width: 900px
) {
    .controls {
        grid-template-columns:
            minmax(150px, 200px)
            minmax(0, 1fr);
    }

    .results-modal {
        width: calc(
            100% - 18px
        );
    }
}


/* =========================================================
   RESPONSIVE - MOBILE
   ========================================================= */

@media (
    max-width: 760px
) {
    .page {
        width: min(
            100% - 20px,
            1240px
        );
        padding: 20px 0 32px;
    }

    .panel {
        padding: 18px;
    }

    .page-title {
        font-size: 25px;
    }

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

    .player-names-field,
    .image-upload-field {
        grid-column: auto;
    }

    .player-names-field {
        padding: 14px;
    }

    .player-names-grid {
        grid-template-columns: 1fr;
    }

    .canvas-wrap {
        min-height: 220px;
    }

    .crop-fallback-header {
        flex-direction: column;
    }

    #resetCropBtn {
        width: 100%;
    }

    .actions {
        flex-direction: column;
    }

    .actions button {
        width: 100%;
    }

    .results-modal-card {
        padding: 17px;
    }

    .results-modal-header h2 {
        font-size: 20px;
    }
}


/* =========================================================
   RESPONSIVE - SMALL MOBILE
   ========================================================= */

@media (
    max-width: 480px
) {
    .page {
        width: min(
            100% - 14px,
            1240px
        );
    }

    .panel {
        padding: 14px;
        border-radius: 12px;
    }

    .player-team-group {
        padding: 12px;
    }

    input[type="file"],
    input[type="text"],
    input[type="number"],
    select,
    button {
        min-height: 42px;
        font-size: 14px;
    }

    .results-modal {
        width: calc(
            100% - 10px
        );
        border-radius: 12px;
    }

    .results-modal-card {
        padding: 14px;
    }
}