/* =============================================================================
   Cardinals Tickets — mobile-first Fluent Design (Cardinals palette)
   ============================================================================= */

:root {
    /* Cardinals red + Fluent neutrals, keeping Scorecard's token structure */
    --primary: #c41e3a;
    --primary-dark: #9a1229;
    --primary-soft: #fde7ea;
    --accent-navy: #0c2340;
    --success: #107c10;
    --warning: #ffb900;
    --danger: #d13438;
    --neutral-10: #faf9f8;
    --neutral-20: #f3f2f1;
    --neutral-30: #edebe9;
    --neutral-60: #8a8886;
    --neutral-90: #323130;
    --neutral-100: #201f1e;
    --shadow-4: 0 1.6px 3.6px rgba(0,0,0,.132), 0 0.3px 0.9px rgba(0,0,0,.108);
    --shadow-8: 0 3.2px 7.2px rgba(0,0,0,.132), 0 0.6px 1.8px rgba(0,0,0,.108);
    --shadow-16: 0 6.4px 14.4px rgba(0,0,0,.132), 0 1.2px 3.6px rgba(0,0,0,.108);
    --radius: 6px;
    --radius-lg: 12px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Roboto, sans-serif;
    font-size: 15px;
    color: var(--neutral-90);
    background: var(--neutral-10);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    padding-bottom: calc(32px + var(--safe-bottom));
}

/* --- Header ---------------------------------------------------------------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-4);
    padding-top: var(--safe-top);
}

.app-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
}

.app-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.app-title-mark {
    background: white;
    color: var(--primary);
    font-weight: 800;
    font-size: 12px;
    letter-spacing: 0.5px;
    padding: 4px 8px;
    border-radius: 4px;
    flex: 0 0 auto;
}

.app-title-text {
    font-size: 17px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.icon-btn {
    background: rgba(255,255,255,0.15);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 18px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.icon-btn:hover, .icon-btn:focus-visible { background: rgba(255,255,255,0.28); outline: none; }
.icon-btn.spinning { animation: spin 0.8s linear infinite; }

/* --- Container ------------------------------------------------------------- */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px;
}

@media (min-width: 900px) {
    .container { max-width: 1100px; padding: 24px; }
}

/* --- Alerts / loading ------------------------------------------------------ */
.alert {
    padding: 12px 14px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    font-size: 14px;
    display: none;
}
.alert.show { display: block; }
.alert-info    { background: #deecf9; color: #004578; border-left: 4px solid #0078d4; }
.alert-success { background: #dff6dd; color: #0b6a0b; border-left: 4px solid var(--success); }
.alert-error   { background: #fde7e9; color: #a80000; border-left: 4px solid var(--danger); }
.alert-warning { background: #fff4ce; color: #835b00; border-left: 4px solid var(--warning); }

.loading-box {
    display: none;
    text-align: center;
    padding: 40px 16px;
    color: var(--neutral-60);
}
.loading-box.active { display: block; }
.loading-spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--neutral-30);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
    text-align: center;
    padding: 40px 16px;
    color: var(--neutral-60);
    font-style: italic;
}

/* --- Filters --------------------------------------------------------------- */
.filters {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 16px;
    background: white;
    padding: 14px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-4);
}

@media (min-width: 640px) {
    .filters { grid-template-columns: auto 1fr 1fr; align-items: center; }
    .filter-toggle { grid-column: 1 / -1; }
}

.filter-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--neutral-90);
    cursor: pointer;
    user-select: none;
}
.filter-toggle input { width: 18px; height: 18px; accent-color: var(--primary); }

.filter-field { display: flex; flex-direction: column; gap: 4px; }
.filter-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--neutral-60);
    font-weight: 600;
}
.filters input[type="search"],
.filters select {
    padding: 10px 12px;
    border: 1px solid var(--neutral-30);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 15px;
    background: white;
    width: 100%;
}
.filters input[type="search"]:focus,
.filters select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-soft);
}

/* --- Games list / card ----------------------------------------------------- */
.games-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 900px) {
    .games-list { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1200px) {
    .games-list { grid-template-columns: repeat(3, 1fr); }
}

.game-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-4);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-top: 4px solid var(--primary);
    transition: box-shadow 0.15s;
}
.game-card.past { opacity: 0.55; }
.game-card.sold-out { border-top-color: var(--neutral-30); }

.game-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.game-date-block {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    flex: 0 0 auto;
}
.game-day  { font-size: 11px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--primary); }
.game-date { font-size: 22px; font-weight: 700; color: var(--neutral-100); }
.game-time { font-size: 12px; color: var(--neutral-60); margin-top: 2px; }

.game-matchup {
    flex: 1 1 auto;
    text-align: right;
}
.game-matchup-title { font-size: 16px; font-weight: 600; color: var(--neutral-100); }
.game-matchup-sub   { font-size: 12px; color: var(--neutral-60); margin-top: 2px; }

/* Seat pair rows */
.seat-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid var(--neutral-20);
    padding-top: 10px;
}

.seat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--neutral-10);
    padding: 10px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--neutral-20);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    min-height: 56px; /* thumb target */
}
.seat-row:hover, .seat-row:focus-visible {
    background: white;
    border-color: var(--primary-soft);
    outline: none;
}

.seat-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.seat-label-main { font-size: 14px; font-weight: 600; color: var(--neutral-90); }
.seat-label-sub  {
    font-size: 12px;
    color: var(--neutral-60);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    flex: 0 0 auto;
}
.status-available      { background: #dff6dd; color: #0b6a0b; }
.status-given-away     { background: #deecf9; color: #004578; }
.status-sold-resale    { background: #fff4ce; color: #835b00; }
.status-sold-friends   { background: #ffe4e8; color: #8a0a1a; }

/* "Give all 4" shortcut */
.give-all-btn {
    background: var(--neutral-10);
    border: 1px dashed var(--neutral-30);
    color: var(--primary-dark);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    width: 100%;
    min-height: 44px;
}
.give-all-btn:hover, .give-all-btn:focus-visible {
    background: var(--primary-soft);
    border-style: solid;
    outline: none;
}
.give-all-btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--neutral-10);
}

/* --- Buttons --------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
    min-height: 44px;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost   { background: transparent; color: var(--neutral-90); }
.btn-ghost:hover { background: var(--neutral-20); }

/* --- Bottom sheet ---------------------------------------------------------- */
.sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 100;
    animation: fade-in 0.15s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 101;
    background: white;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-16);
    padding: 8px 20px 12px;
    animation: slide-up 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
    max-height: 90vh;
    max-height: 90dvh;           /* shrinks when keyboard opens on modern browsers */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    /* JS sets --kb-offset to the keyboard height (via visualViewport) */
    transform: translateY(calc(var(--kb-offset, 0px) * -1));
    transition: transform 0.15s ease-out;
}

/* Sticky action bar so Save/Cancel stay visible even when the sheet scrolls */
.sheet-actions-sticky {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 12px 0 calc(4px + var(--safe-bottom));
    margin-top: auto;
    box-shadow: 0 -8px 12px -8px rgba(0,0,0,0.12);
}
@keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

@media (min-width: 640px) {
    .sheet {
        left: 50%;
        right: auto;
        bottom: auto;
        top: 10%;
        transform: translateX(-50%);
        width: min(480px, 90vw);
        border-radius: var(--radius-lg);
        animation: fade-in 0.15s ease-out;
    }
}

.sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--neutral-30);
    border-radius: 2px;
    margin: 6px auto 16px;
}
@media (min-width: 640px) { .sheet-handle { display: none; } }

.sheet-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--neutral-100);
    margin-bottom: 4px;
}
.sheet-subtitle {
    font-size: 13px;
    color: var(--neutral-60);
    margin-bottom: 16px;
}

.sheet-section { margin-bottom: 18px; }

.field-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--neutral-60);
    font-weight: 600;
    margin-bottom: 8px;
}

.status-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.status-option {
    padding: 12px 10px;
    border: 2px solid var(--neutral-30);
    background: white;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    font-family: inherit;
    transition: border-color 0.15s, background 0.15s;
    min-height: 48px;
}
.status-option:hover { border-color: var(--primary-soft); }
.status-option.selected {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary-dark);
}

#sheet-recipient {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px; /* >=16px avoids iOS zoom on focus */
    border: 1px solid var(--neutral-30);
    border-radius: var(--radius);
    font-family: inherit;
    background: white;
}
#sheet-recipient:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-soft);
}

.sheet-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 8px;
}

/* --- Utility --------------------------------------------------------------- */
[hidden] { display: none !important; }
