/* ============================================================
   Design tokens
   ============================================================ */
:root {
    --bg: #eef2f6;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #dde5ee;
    --border-strong: #cbd5e1;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --accent: #f59e0b;
    --success: #16a34a;
    --success-hover: #15803d;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-md: 0 4px 14px rgba(16, 24, 40, .10);
}

/* ============================================================
   Base
   ============================================================ */
body {
    min-width: 350px;
    margin: 0;
    padding: 24px;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text);
    background-color: var(--bg);
}

h1, h2, h3 {
    color: var(--text);
}

h3 {
    margin: 0 0 0.6em;
    font-size: 1.05rem;
    letter-spacing: .01em;
}

a {
    color: var(--primary);
}

ul {
    margin-block-start: 0.1em;
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 28px 0;
}

/* ============================================================
   Page header
   ============================================================ */
.app-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 8px 0 20px;
    margin-bottom: 8px;
}

.app-logo {
    width: 96px;
    height: 96px;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(16, 24, 40, .15));
}

.app-title {
    margin: 0;
    font-size: 2.1rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
    background: linear-gradient(90deg, #1e3a5f, #2563eb);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ============================================================
   Card panels (Options / Notes / Save-Load)
   ============================================================ */
#options,
#notes {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 22px;
}

#options label {
    cursor: pointer;
}

#options > div {
    padding: 3px 0;
}

#notes #notesText {
    color: var(--muted);
    font-size: 0.92rem;
}

#notes li {
    margin-bottom: 4px;
}

/* ============================================================
   Form controls
   ============================================================ */
select,
input[type="text"],
input[type="number"] {
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 5px 8px;
    box-sizing: border-box;
}

select {
    cursor: pointer;
}

select:focus,
input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    vertical-align: -2px;
    margin-right: 4px;
    cursor: pointer;
}

/* ============================================================
   Buttons
   ============================================================ */
button {
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    padding: 7px 16px;
    margin: 4px 4px 4px 0;
    cursor: pointer;
    transition: background-color .15s ease, transform .05s ease;
}

button:hover {
    background: var(--primary-hover);
}

button:active {
    transform: translateY(1px);
}

.big-button {
    font-size: 1.25rem;
    font-weight: 700;
    padding: 12px 32px;
    margin: 8px 0;
    background: var(--success);
    box-shadow: var(--shadow-md);
}

.big-button:hover {
    background: var(--success-hover);
}

/* "Upload"-style pill buttons (Save/Load actions) */
.custom-file-upload {
    cursor: pointer;
    padding: 7px 18px;
    margin: 0 4px;
    background-color: var(--primary);
    color: #fff;
    font-weight: 600;
    border-radius: var(--radius-sm);
    display: inline-block;
    transition: background-color .15s ease;
}

.custom-file-upload:hover {
    background-color: var(--primary-hover);
}

/* Save/Load fieldsets */
fieldset#saveLoadRoster,
fieldset#saveLoadLineup {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 14px 16px;
}

fieldset#saveLoadRoster legend,
fieldset#saveLoadLineup legend {
    font-weight: 700;
    color: var(--muted);
    padding: 0 6px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* ============================================================
   Tables
   ============================================================ */
table {
    border-collapse: collapse;
    width: 100%;
}

th,
td {
    border: 1px solid var(--border);
    padding: 0.5em 0.6em;
}

th {
    background-color: var(--surface-2);
    font-weight: 700;
    color: var(--text);
}

tr:nth-child(even) {
    background-color: var(--surface-2);
}

tr[draggable="true"] {
    cursor: grab;
}

tr[draggable="true"]:hover {
    background-color: #e8f1ff;
}

/* Roster table sits in a rounded, scrollable card */
#rosterContainer {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-top: 20px;
    overflow-x: auto;
}

/* Inputs that live inside table cells fill their cell */
td input[type="text"],
td input[type="number"] {
    width: 100%;
}

.table-input {
    box-sizing: border-box;
    width: 100%;
    padding: 4px;
}

#fieldingTable th.column-dragging {
    opacity: 0.5;
}

/* ============================================================
   Lineup output section
   ============================================================ */
.lineup-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    margin-bottom: 12px;
}

.lineup-toolbar-icons {
    display: flex;
    align-items: center;
    gap: 12px;
}

#lineupSection {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 22px;
    margin-top: 8px;
}

.editable-header {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 14px;
    margin: 16px 0;
    background-color: var(--surface-2);
    cursor: text;
    text-align: center;
    position: relative;
    z-index: 1;
}

.editable-header:focus {
    outline: none;
    border-color: var(--primary);
    background-color: #fff;
}

.table-container {
    position: relative;
}

.editButton {
    position: absolute;
    top: 0;
    left: 0;
    margin: 10px;
}

.commentsBox {
    display: none;
    width: 100%;
    min-height: 6rem;
    overflow-y: hidden;
    resize: vertical;
}

/* ============================================================
   Icons & field display
   ============================================================ */
.info-icon {
    height: 1em;
    vertical-align: top;
    cursor: help;
}

.fieldIcon {
    width: 1em;
    height: 1em;
    margin-left: 1em;
    cursor: pointer;
}

.svg-container {
    width: 100vw;
    height: 100vh;
    min-width: 350px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.svg-container svg {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}

/* ============================================================
   Utility / state classes
   ============================================================ */
.hidden {
    display: none;
}

.req-violation {
    background-color: #ffe0b2 !important;
    outline: 2px solid orange;
}

.gradient-text {
    background: linear-gradient(to bottom, blue, green, blue);
    -webkit-background-clip: text;
    color: transparent;
    font-weight: bold;
    display: inline-block;
}

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

.blinking {
    animation: blink 1s infinite;
}

/* ============================================================
   Layout grid (Options + Notes + Save/Load)
   ============================================================ */
.split-container {
    position: relative;
    display: grid;
    grid-template-columns: minmax(320px, 1fr) 2fr;
    grid-template-areas:
        "options notes"
        "saveload notes";
    gap: 20px;
    align-items: start;
}

#options {
    min-width: 320px;
    grid-area: options;
}

#notes {
    grid-area: notes;
}

#saveload {
    grid-area: saveload;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 800px) {
    body {
        padding: 14px;
    }

    .split-container {
        grid-template-columns: 1fr;
        grid-template-areas:
            "notes"
            "options"
            "saveload";
    }

    .app-title {
        font-size: 1.5rem;
    }

    .app-logo {
        width: 64px;
        height: 64px;
    }
}

/* ============================================================
   Print
   ============================================================ */
@media print {
    body {
        background: #fff;
        padding: 0;
    }

    #lineupSection {
        border: none;
        box-shadow: none;
        padding: 0;
    }

    .hide-on-print {
        display: none !important;
    }

    textarea {
        border: none !important;
        outline: none !important;
        resize: none;
    }
}
