/* Override Django admin's container width on every level it uses to cap
 * content. Hitting all of: #container, #main, #content, .colM, .module,
 * [role=main]. Without `min-width: 0` flex/grid children won't shrink. */
html, body { min-width: 0 !important; }
#container, #header, #main, #content, .colM, .module, [role="main"] {
    max-width: none !important;
    width: auto !important;
    min-width: 0 !important;
}
#content {
    padding: 14px 24px;
}
#content-main { max-width: none !important; }

/* Layout: every section is a fieldset; flex/grid contained inside. Nothing
 * escapes its parent because everything has overflow boundaries. */

.pga-banner {
    background: #e7f4e4;
    border-left: 4px solid #4caf50;
    padding: 6px 12px;
    margin: 8px 0;
}
.pga-meta {
    margin: 6px 0 0 0;
    font-size: 12px;
    color: #555;
}
.pga-section {
    margin: 12px 0;
    padding: 8px 12px;
    border: 1px solid #ccc;
    box-sizing: border-box;
}
.pga-section legend {
    font-weight: bold;
    padding: 0 6px;
}

/* Inline event/csv forms — date input + button on one line */
.pga-inline-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

/* Course config: responsive grid that auto-flows */
.pga-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px 18px;
}
.pga-fieldwrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;     /* prevents grid items from overflowing */
}
.pga-fieldwrap label {
    font-size: 12px;
    font-weight: 600;
    color: #444;
}
.pga-fieldwrap input,
.pga-fieldwrap select {
    box-sizing: border-box;
    width: 100%;
    max-width: 220px;
    padding: 4px 6px;
    border: 1px solid #ccc;
    font-size: 13px;
}
.pga-help {
    font-size: 11px;
    color: #777;
    line-height: 1.3;
}
.pga-preflight-error {
    background: #fdecea;
    border: 1px solid #f5c6c2;
    padding: 10px;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 900px;
}
.pga-pulldata {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed #ddd;
}
.pga-pulldata .pga-help { max-width: 560px; margin-top: 4px; }
.pga-pulldata-status { margin-left: 10px; font-size: 12px; }

/* Round-mode radios in a horizontal strip */
.pga-radios ul {
    display: flex;
    gap: 16px;
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Tables */
.pga-table-scroll {
    overflow-x: auto;
}
.pga-player-table,
.pga-summary-table,
.pga-wave-table {
    border-collapse: collapse;
    font-size: 12px;
    width: 100%;
}
.pga-wave-table {
    max-width: 540px;
}
.pga-player-table th,
.pga-player-table td,
.pga-summary-table th,
.pga-summary-table td,
.pga-wave-table th,
.pga-wave-table td {
    border: 1px solid #ddd;
    padding: 2px 4px;
    text-align: right;
}
.pga-player-table th:nth-child(2),
.pga-player-table td:nth-child(2),
.pga-summary-table th:nth-child(2),
.pga-summary-table td:nth-child(2) {
    text-align: left;
}
.pga-player-table input,
.pga-wave-table input,
.pga-wave-table select {
    width: 70px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    padding: 1px 3px;
    font-size: 12px;
}
.pga-player-table input.pga-name { width: 140px; }
.pga-player-table input.pga-pid  { width: 80px; }
.pga-thead-top th { background: #f0f0f0; }

/* Sortable headers (result page summary table). */
.pga-summary-table th.pga-sort { cursor: pointer; user-select: none; }
.pga-summary-table th.pga-sort:hover { background: #e8e8e8; }
.pga-summary-table th.pga-sort-asc::after  { content: " ▲"; font-size: 10px; }
.pga-summary-table th.pga-sort-desc::after { content: " ▼"; font-size: 10px; }

/* Player-table row coloring by match quality (set from autofill.js). */
.pga-row-unmatched td:first-child {
    background: #ffd6d6;
    border-left: 3px solid #c62828;
}
.pga-row-name-only td:first-child {
    background: #fff4d2;
    border-left: 3px solid #f9a825;
}
.pga-row-wd-suspect td:first-child {
    background: #e0e0e0;
    border-left: 3px solid #757575;
}
.pga-scen-a-h    { background: #eef6ff !important; }
.pga-scen-b-h    { background: #fdf3ee !important; }
.pga-scen-b-hidden .pga-scen-b-h,
.pga-scen-b-hidden .pga-scen-b-c { display: none; }

.pga-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.pga-toolbar .pga-spacer { flex: 1; }

.pga-run-bar {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-top: 12px;
}
.pga-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
}
.pga-checkbox input { margin: 0; }
.pga-checkbox .pga-help { margin-left: 4px; }

#pga-run-btn {
    background: #1976d2;
    color: white;
    border: none;
    padding: 8px 16px;
    font-weight: bold;
    cursor: pointer;
}
#pga-run-btn:hover { background: #0d5fa8; }

/* Result page action bar (back link + ship button) */
.pga-result-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 8px 0 12px;
    flex-wrap: wrap;
}
.pga-ship-btn {
    background: #2e7d32;
    color: white;
    border: none;
    padding: 6px 14px;
    font-weight: bold;
    cursor: pointer;
}
.pga-ship-btn:hover { background: #1b5e20; }

/* Result page: collapse rows, modal histogram */
.pga-row-header { cursor: pointer; }
.pga-row-header:hover { background: #f4f7fb; }
.pga-toggle { width: 16px; color: #777; text-align: center; }
.pga-pid-link {
    color: #1976d2;
    text-decoration: none;
    font-family: monospace;
    margin-left: 6px;
}
.pga-pid-link:hover { text-decoration: underline; }
.pga-row-child { background: #fafafa; color: #555; }
.pga-row-child td { font-size: 11px; }
.pga-player { text-align: left; }
.pga-name { font-weight: 600; }
.pga-player-indent { padding-left: 24px !important; color: #aaa; }

.pga-modal {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
/* `display: flex` above overrides the [hidden] attribute's default
 * display:none, so we need an explicit override or the modal shows on load. */
.pga-modal[hidden] { display: none !important; }
.pga-modal-card {
    background: white;
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    width: 700px;
    max-width: 95vw;
    padding: 12px 16px 16px;
}
.pga-modal-head {
    display: flex; align-items: center;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 8px; margin-bottom: 8px;
}
.pga-modal-head h3 { flex: 1; margin: 0; font-size: 16px; }
.pga-modal-head button {
    border: none; background: none; font-size: 22px; cursor: pointer; color: #666;
}
.pga-modal-body svg { display: block; width: 100%; height: 320px; }
