/* Seating Arrangement System */

/* Dark theme is the default; [data-theme="light"] switches to light. */
:root {
    color-scheme: dark;
    --green: #2ea043;
    --green-dark: #116329;
    --green-strong: #3fb950;
    --green-tint: rgba(46, 160, 67, 0.15);
    --bg: #0d1117;
    --card: #161b22;
    --border: #30363d;
    --text: #e6edf3;
    --muted: #8b949e;
    --danger: #f85149;
    --danger-bg: rgba(248, 81, 73, 0.12);
    --danger-border: rgba(248, 81, 73, 0.45);
    --radius: 10px;
    /* saturation/lightness of the per-section tiles (hue comes from JS via --hue) */
    --seat-s: 45%;
    --seat-l: 20%;
    --seat-border-s: 35%;
    --seat-border-l: 38%;
    --seat-text-s: 65%;
    --seat-text-l: 78%;
}

:root[data-theme="light"] {
    color-scheme: light;
    --green: #1a7f37;
    --green-strong: #116329;
    --green-tint: #f0fff4;
    --bg: #f6f8fa;
    --card: #ffffff;
    --border: #d0d7de;
    --text: #1f2328;
    --muted: #59636e;
    --danger: #cf222e;
    --danger-bg: #fff5f5;
    --danger-border: #ffcdd2;
    --seat-s: 70%;
    --seat-l: 92%;
    --seat-border-s: 45%;
    --seat-border-l: 65%;
    --seat-text-s: 60%;
    --seat-text-l: 28%;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
}

/* header / footer */

.site-header {
    background: var(--card);
    border-bottom: 3px solid var(--green);
    padding: 14px 0;
}

.site-header .container {
    display: flex;
    align-items: baseline;
    gap: 14px;
    flex-wrap: wrap;
}

.brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--green-strong);
    text-decoration: none;
}

.theme-toggle {
    margin-left: auto;
    align-self: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
}

.theme-toggle:hover {
    background: var(--bg);
}

.tagline {
    color: var(--muted);
    font-size: 0.85rem;
}

.site-footer {
    margin-top: 40px;
    padding: 14px 0;
    background: var(--green-dark);
    color: #fff;
    font-size: 0.85rem;
}

.footer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.footer-links {
    display: flex;
    gap: 16px;
}

.site-footer a {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.lead {
    margin: 22px 4px 0;
    color: var(--muted);
    font-size: 1.02rem;
    max-width: 720px;
}

/* cards */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin: 20px 0;
}

.card h2 {
    margin: 0 0 16px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--green);
    color: #fff;
    font-size: 0.85rem;
    flex: none;
}

/* dropzone */

.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    transition: border-color 0.15s, background 0.15s;
}

.dropzone.drag {
    border-color: var(--green);
    background: var(--green-tint);
}

.dropzone p {
    margin: 6px 0;
}

.dropzone-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 10px 0;
}

.hint {
    color: var(--muted);
    font-size: 0.85rem;
}

.hint code {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
}

.errors {
    margin-top: 14px;
    padding: 10px 14px;
    border: 1px solid var(--danger-border);
    border-radius: 6px;
    background: var(--danger-bg);
    color: var(--danger);
    font-size: 0.85rem;
}

.errors p {
    margin: 3px 0;
}

#inputSummary {
    margin-top: 14px;
}

.summary-line {
    margin: 0 0 8px;
    font-weight: 600;
}

/* chips */

.chips,
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    display: inline-block;
    padding: 3px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    font-size: 0.85rem;
}

.chip-empty {
    border-style: dashed;
    color: var(--muted);
}

.chip-conflict {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-bg);
}

.chip-colored {
    background: hsl(var(--hue), var(--seat-s), var(--seat-l));
    border-color: hsl(var(--hue), var(--seat-border-s), var(--seat-border-l));
}

/* config */

.config-grid {
    display: flex;
    align-items: end;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.config-grid label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.9rem;
    font-weight: 600;
}

.config-grid input[type="number"] {
    width: 110px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
}

.capacity-note {
    color: var(--muted);
    font-size: 0.9rem;
    padding-bottom: 8px;
}

.strategy {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin: 0 0 18px;
}

.strategy legend {
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0 6px;
}

.strategy label {
    display: block;
    margin: 5px 0;
    font-size: 0.9rem;
}

/* buttons */

.btn {
    display: inline-block;
    text-decoration: none;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card);
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
    background: var(--bg);
}

.btn-primary {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.btn-primary:hover {
    background: var(--green-dark);
    border-color: var(--green-dark);
}

.btn-ghost {
    background: transparent;
    color: var(--green-strong);
    border-color: var(--green);
}

.btn-ghost:hover {
    background: var(--green-tint);
}

.btn-lg {
    padding: 10px 26px;
    font-size: 1rem;
}

/* results */

.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.stat {
    min-width: 110px;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--green-strong);
}

.stat-warn .stat-value {
    color: var(--danger);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--muted);
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.toolbar-actions {
    display: flex;
    gap: 8px;
}

.tabs {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.tab {
    padding: 7px 18px;
    border: none;
    background: var(--card);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
}

.tab.active {
    background: var(--green);
    color: #fff;
}

.legend {
    margin-bottom: 16px;
}

/* room-wise view */

.room {
    margin-bottom: 26px;
}

.room h3 {
    margin: 0 0 10px;
    font-size: 1rem;
}

.room-scroll {
    overflow-x: auto;
    padding-bottom: 6px;
}

.room-grid {
    display: flex;
    gap: 10px;
}

.room-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.col-head {
    text-align: center;
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.seat {
    position: relative;
    min-width: 128px;
    padding: 6px 10px 6px 26px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card);
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
}

.seat-no {
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.68rem;
    color: var(--muted);
}

.seat-roll {
    font-weight: 600;
    white-space: nowrap;
}

.seat-sec {
    font-size: 0.72rem;
    font-weight: 600;
}

.seat-colored {
    background: hsl(var(--hue), var(--seat-s), var(--seat-l));
    border-color: hsl(var(--hue), var(--seat-border-s), var(--seat-border-l));
}

.seat-colored .seat-sec {
    color: hsl(var(--hue), var(--seat-text-s), var(--seat-text-l));
}

.seat-empty {
    border-style: dashed;
    color: var(--muted);
    background: var(--bg);
    justify-content: center;
}

/* second (blank) line so empty tiles match filled-tile height and rows stay aligned */
.seat-empty::after {
    content: "\a0";
    font-size: 0.72rem;
}

.seat-conflict {
    outline: 2px solid var(--danger);
    outline-offset: 1px;
}

/* section-wise view — blocks flow into side-by-side columns */

.section-view {
    columns: 290px;
    column-gap: 24px;
}

.section-block {
    margin-bottom: 26px;
    break-inside: avoid;
}

.section-block h3 {
    margin: 0 0 8px;
    padding-left: 10px;
    font-size: 1rem;
    border-left: 5px solid hsl(var(--hue, 0), 60%, 55%);
}

.section-table {
    border-collapse: collapse;
    width: 100%;
}

.section-table th,
.section-table td {
    border: 1px solid var(--border);
    padding: 5px 14px;
    font-size: 0.85rem;
    text-align: left;
}

.section-table th {
    background: var(--bg);
}

/* help card */

#helpCard details {
    border-top: 1px solid var(--border);
    padding: 10px 4px;
}

#helpCard details:first-of-type {
    border-top: none;
}

#helpCard summary {
    font-weight: 600;
    cursor: pointer;
    font-size: 0.95rem;
}

#helpCard p,
#helpCard ol,
#helpCard ul {
    margin: 8px 0 4px;
    color: var(--text);
    font-size: 0.9rem;
    max-width: 780px;
}

#helpCard li {
    margin: 4px 0;
}

#helpCard code {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
}

/* print */

@media print {

    /* always print in light, whatever the on-screen theme */
    :root,
    :root[data-theme="dark"] {
        --bg: #ffffff;
        --card: #ffffff;
        --border: #d0d7de;
        --text: #1f2328;
        --muted: #59636e;
        --green-strong: #116329;
        --danger: #cf222e;
        --seat-s: 70%;
        --seat-l: 92%;
        --seat-border-s: 45%;
        --seat-border-l: 65%;
        --seat-text-s: 60%;
        --seat-text-l: 28%;
    }

    body {
        background: #fff;
    }

    .site-header,
    .site-footer,
    #inputCard,
    #configCard,
    #helpCard,
    .lead,
    .toolbar {
        display: none;
    }

    .card {
        border: none;
        padding: 0;
        margin: 0;
    }

    .room,
    .section-block {
        break-inside: avoid;
    }

    .seat,
    .chip,
    .stat {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}

@media (max-width: 640px) {
    .card {
        padding: 16px;
    }

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

    .toolbar-actions {
        justify-content: stretch;
    }

    .toolbar-actions .btn {
        flex: 1;
    }

    .tagline {
        display: none;
    }

    /* compact seat tiles so more columns fit on a phone */
    .seat {
        min-width: 92px;
        padding: 4px 6px 4px 19px;
        font-size: 0.7rem;
        border-radius: 5px;
    }

    .seat-no {
        left: 4px;
        font-size: 0.58rem;
    }

    .seat-sec,
    .seat-empty::after {
        font-size: 0.64rem;
    }

    .room-grid {
        gap: 6px;
    }

    .room-col {
        gap: 4px;
    }

    .col-head {
        font-size: 0.64rem;
    }
}
