/* ============================================================
   JP Skating Club — Admin Dashboard
   Design: cool rink-ice palette with full mobile support
   ============================================================ */

:root {
    --ink: #10151B;
    --rink: #0E7C86;
    --rink-dark: #0A5A62;
    --rink-light: #E5F5F3;
    --frost: #F0F4F5;
    --amber: #F2994A;
    --amber-light: #FDF0E2;
    --coral: #E5484D;
    --coral-light: #FBE7E8;
    --mint: #2BB673;
    --mint-light: #E3F6EC;
    --white: #FFFFFF;
    --border: #E2E8EC;
    --text: #1B2730;
    --text-muted: #647079;
    --sidebar-w: 240px;

    --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
    --font-body: 'Inter', 'Segoe UI', sans-serif;
    --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

    --radius: 10px;
    --shadow: 0 1px 3px rgba(16,21,27,0.07), 0 8px 24px rgba(16,21,27,0.06);
    --shadow-sm: 0 1px 2px rgba(16,21,27,0.05);
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    background: var(--frost);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--ink);
    margin: 0 0 4px;
}

a { color: var(--rink-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
table { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }

:focus-visible {
    outline: 2px solid var(--rink);
    outline-offset: 2px;
}

/* =============================================
   LAYOUT SHELL
   ============================================= */

.shell { display: flex; min-height: 100vh; }

/* =============================================
   SIDEBAR
   ============================================= */

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--ink);
    color: #C9D6DA;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.28s ease;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.sidebar-brand img { height: 34px; width: auto; border-radius: 6px; }
.sidebar-brand .brand-icon {
    height: 36px; width: 36px; border-radius: 8px;
    background: var(--rink); color: white;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700; font-size: 14px;
    flex-shrink: 0;
}
.sidebar-brand .brand-name {
    font-family: var(--font-display); font-weight: 600; color: white;
    font-size: 15px; line-height: 1.25; flex: 1; min-width: 0;
}

/* Close button inside sidebar (mobile) */
.sidebar-close-btn {
    display: none;
    background: none; border: none; color: #9FB2B8; cursor: pointer;
    padding: 4px; border-radius: 6px; line-height: 1;
    flex-shrink: 0;
}
.sidebar-close-btn:hover { color: white; background: rgba(255,255,255,0.1); }

.sidebar-nav { padding: 12px 10px; flex: 1; }

.sidebar-section-label {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em;
    color: #6B7C82; margin: 18px 10px 5px; font-weight: 600;
}

.sidebar-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 8px; color: #C9D6DA;
    font-size: 14px; font-weight: 500; margin-bottom: 2px;
    border-left: 3px solid transparent;
    transition: background 0.15s, color 0.15s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.07); text-decoration: none; color: white; }
.sidebar-nav a.active {
    background: rgba(14,124,134,0.25); color: white;
    border-left-color: var(--rink);
}
.sidebar-nav .dot { width: 6px; height: 6px; border-radius: 50%; background: #57676E; flex-shrink: 0; }
.sidebar-nav a.active .dot { background: var(--rink); }
.sidebar-nav .nav-icon { width: 18px; text-align: center; flex-shrink: 0; font-size: 15px; }

.sidebar-foot {
    padding: 14px 20px; border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 13px; flex-shrink: 0;
}
.sidebar-foot a { color: #9FB2B8; }
.sidebar-foot a:hover { color: white; }

/* =============================================
   SIDEBAR OVERLAY (mobile)
   ============================================= */

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0; z-index: 199;
    background: rgba(16,21,27,0.55);
    opacity: 0;
    transition: opacity 0.28s ease;
}

/* =============================================
   MAIN AREA
   ============================================= */

.main {
    flex: 1; min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex; flex-direction: column;
    min-height: 100vh;
}

/* =============================================
   TOP BAR
   ============================================= */

.topbar {
    display: flex; align-items: center; gap: 12px;
    padding: 0 24px; height: 60px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
    box-shadow: var(--shadow-sm);
}

/* Hamburger button */
.hamburger-btn {
    display: none;
    background: none; border: none; cursor: pointer;
    padding: 8px; border-radius: 8px;
    color: var(--text); flex-shrink: 0;
    transition: background 0.15s;
}
.hamburger-btn:hover { background: var(--frost); }
.hamburger-btn svg { display: block; }

.topbar-spacer { flex: 1; }

.topbar-left { display: flex; align-items: center; gap: 10px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.who { font-size: 13px; color: var(--text-muted); }
.who strong { color: var(--text); }

/* =============================================
   CONTENT
   ============================================= */

.content {
    padding: 26px 28px;
    max-width: 1220px;
    flex: 1;
}

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

.page-head { margin-bottom: 24px; }
.page-head .lane-line {
    margin-top: 10px; height: 4px; width: 64px; border-radius: 4px;
    background: repeating-linear-gradient(90deg, var(--rink) 0 14px, var(--rink-light) 14px 20px);
}
.page-head-row {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 12px; flex-wrap: wrap;
}
.page-head p.subtitle { color: var(--text-muted); margin: 4px 0 0; font-size: 14px; }

/* =============================================
   STAT GRID
   ============================================= */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow); }

.stat-card .label {
    font-size: 11.5px; color: var(--text-muted); font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
}
.stat-card .value {
    font-family: var(--font-display); font-size: 30px; font-weight: 700;
    color: var(--ink); margin-top: 8px; font-variant-numeric: tabular-nums;
    line-height: 1;
}
.stat-card .value.accent-rink { color: var(--rink-dark); }
.stat-card .value.accent-amber { color: var(--amber); }
.stat-card .value.accent-coral { color: var(--coral); }
.stat-card .value.accent-mint { color: #1f9c5c; }

/* =============================================
   CARDS
   ============================================= */

.card {
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 20px 22px; margin-bottom: 20px;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px; gap: 12px; flex-wrap: wrap;
}
.card-head h3 { font-size: 15px; }

/* =============================================
   FORMS
   ============================================= */

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-group { margin-bottom: 14px; display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-group .hint { font-size: 12px; color: var(--text-muted); }

input[type="text"], input[type="number"], input[type="password"],
input[type="date"], input[type="tel"], input[type="email"], input[type="file"],
select, textarea {
    font-family: var(--font-body); font-size: 14px; padding: 9px 12px;
    border: 1.5px solid var(--border); border-radius: 8px;
    background: var(--white); color: var(--text); width: 100%;
    transition: border-color 0.15s;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
    border-color: var(--rink); outline: none;
    box-shadow: 0 0 0 3px rgba(14,124,134,0.12);
}

.radio-row, .check-row { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-row label, .check-row label { font-weight: 500; font-size: 14px; display: flex; align-items: center; gap: 6px; }

input[readonly] {
    background: var(--frost); color: var(--text-muted); cursor: not-allowed;
}
input[readonly]:focus { box-shadow: none; }

fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin: 0 0 14px; }
fieldset legend { font-size: 12.5px; font-weight: 600; color: var(--text-muted); padding: 0 4px; }

/* =============================================
   BUTTONS
   ============================================= */

.btn {
    display: inline-flex; align-items: center; gap: 6px; justify-content: center;
    font-family: var(--font-body); font-weight: 600; font-size: 13.5px;
    padding: 9px 16px; border-radius: 8px; border: 1.5px solid transparent;
    cursor: pointer; background: var(--white); color: var(--text);
    border-color: var(--border); text-decoration: none; line-height: 1.2;
    transition: all 0.15s; white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(0.97); }
.btn-primary { background: var(--rink); border-color: var(--rink); color: white; }
.btn-primary:hover { background: var(--rink-dark); filter: none; }
.btn-amber { background: var(--amber); border-color: var(--amber); color: white; }
.btn-coral { background: var(--coral); border-color: var(--coral); color: white; }
.btn-mint { background: var(--mint); border-color: var(--mint); color: white; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--frost); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* =============================================
   TABLES
   ============================================= */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 480px; }
table.data th {
    text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--text-muted); border-bottom: 2px solid var(--border);
    padding: 10px 12px; font-weight: 700; white-space: nowrap; background: var(--frost);
}
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover { background: var(--frost); }
table.data .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state h4 { color: var(--text); margin-bottom: 6px; }

/* =============================================
   BADGES
   ============================================= */

.badge {
    display: inline-block; font-size: 11px; font-weight: 700;
    padding: 3px 10px; border-radius: 100px;
    text-transform: uppercase; letter-spacing: 0.03em;
    background: var(--border); color: var(--text-muted);
}
.badge-active { background: var(--mint-light); color: #1f9c5c; }
.badge-paused { background: var(--amber-light); color: #b5650f; }
.badge-expired { background: var(--coral-light); color: var(--coral); }

.pill-muted {
    font-size: 12px; color: var(--text-muted); background: var(--frost);
    border: 1px solid var(--border); padding: 2px 9px; border-radius: 100px;
}

/* =============================================
   ALERTS
   ============================================= */

.alert {
    border-radius: 8px; padding: 12px 16px; margin-bottom: 18px;
    font-size: 14px; border: 1px solid transparent;
}
.alert-success { background: var(--mint-light); color: #1f9c5c; border-color: #bfe9d4; }
.alert-error { background: var(--coral-light); color: var(--coral); border-color: #f6c8ca; }
.alert-info { background: var(--rink-light); color: var(--rink-dark); border-color: #c9e8e6; }

/* =============================================
   AUTH PAGES
   ============================================= */

.auth-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(160deg, var(--ink) 0%, var(--rink-dark) 60%, var(--rink) 100%);
    padding: 20px;
}
.auth-card {
    background: var(--white); border-radius: 16px;
    padding: 36px 32px; width: 100%; max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.auth-card .brand-icon {
    height: 46px; width: 46px; border-radius: 12px; background: var(--rink); color: white;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700; font-size: 18px; margin-bottom: 16px;
}
.auth-card h1 { font-size: 20px; }
.auth-card p.lede { color: var(--text-muted); font-size: 13.5px; margin: 4px 0 22px; }
.auth-foot { text-align: center; margin-top: 16px; font-size: 12.5px; color: rgba(255,255,255,0.75); }

/* =============================================
   MISC UTILITIES
   ============================================= */

.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.section-divider { border: none; border-top: 1px solid var(--border); margin: 22px 0; }

.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }

.kv {
    display: flex; justify-content: space-between; padding: 7px 0;
    border-bottom: 1px dashed var(--border); font-size: 13.5px;
}
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--text-muted); }
.kv .v { font-weight: 600; text-align: right; }

.logo-preview { height: 48px; border-radius: 8px; border: 1px solid var(--border); padding: 4px; background: white; }

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

.modal { display: none; position: fixed; inset: 0; z-index: 300; }
.modal.is-open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(16,21,27,0.55); }
.modal-dialog {
    position: relative; max-width: 500px; margin: 5vh auto;
    background: var(--white); border-radius: 14px;
    padding: 26px; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-height: 90vh; overflow-y: auto;
}
.modal-dialog h3 { margin-bottom: 4px; }
.modal-close-row { display: flex; justify-content: flex-end; margin-top: 18px; gap: 10px; }

/* =============================================
   PRINT
   ============================================= */

@media print {
    .no-print { display: none !important; }
    body { background: white; }
}

/* =============================================
   RESPONSIVE — TABLET  (max 1024px)
   ============================================= */

@media (max-width: 1024px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .two-col { grid-template-columns: 1fr; }
    .content { padding: 20px; }
    .topbar { padding: 0 20px; }
}

/* =============================================
   RESPONSIVE — MOBILE SIDEBAR  (max 880px)
   Mobile: sidebar slides in from left as drawer
   ============================================= */

@media (max-width: 880px) {
    /* Sidebar becomes off-canvas drawer */
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }
    .sidebar.is-open {
        transform: translateX(0);
        box-shadow: 4px 0 32px rgba(16,21,27,0.3);
    }
    .sidebar-close-btn { display: flex; }

    /* Overlay becomes active */
    .sidebar-overlay.is-open {
        display: block;
        opacity: 1;
    }

    /* Main fills full width */
    .main { margin-left: 0; }

    /* Show hamburger */
    .hamburger-btn { display: flex; }

    /* Topbar adjustments */
    .topbar { height: 56px; padding: 0 16px; }
    .topbar-right .who:first-child { display: none; }

    .content { padding: 16px; }
    .page-head { margin-bottom: 18px; }
    .page-head-row { flex-direction: column; align-items: flex-start; gap: 10px; }
    .form-grid { grid-template-columns: 1fr; }
}

/* =============================================
   RESPONSIVE — SMALL MOBILE  (max 560px)
   ============================================= */

@media (max-width: 560px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 14px 16px; }
    .stat-card .value { font-size: 24px; }

    .card { padding: 16px; }
    .modal-dialog { margin: 0; border-radius: 14px 14px 0 0; position: fixed; bottom: 0; left: 0; right: 0; max-width: 100%; max-height: 92vh; }

    .btn-row { gap: 6px; }
    .btn { padding: 8px 13px; font-size: 13px; }
    .btn-sm { padding: 6px 10px; font-size: 12px; }

    table.data th, table.data td { padding: 9px 10px; }

    .topbar { gap: 8px; }
    .who { font-size: 12px; }
}

/* =============================================
   RESPONSIVE — STUDENTS FILTER (max 720px)
   ============================================= */

@media (max-width: 720px) {
    .filter-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }
    .filter-grid .search-group {
        grid-column: 1 / -1;
    }
}

/* =============================================
   MOBILE CARD TABLE — cards instead of rows
   ============================================= */

@media (max-width: 640px) {
    .table-wrap.mobile-cards { overflow-x: visible; }
    .table-wrap.mobile-cards table.data { display: block; min-width: unset; }
    .table-wrap.mobile-cards table.data thead { display: none; }
    .table-wrap.mobile-cards table.data tbody { display: flex; flex-direction: column; gap: 10px; }
    .table-wrap.mobile-cards table.data tr {
        display: grid; grid-template-columns: 1fr 1fr;
        background: var(--white); border: 1px solid var(--border);
        border-radius: 10px; padding: 14px; gap: 8px 12px;
    }
    .table-wrap.mobile-cards table.data tr:hover { background: var(--white); }
    .table-wrap.mobile-cards table.data td {
        padding: 0; border-bottom: none;
        font-size: 13.5px; position: relative;
        display: flex; flex-direction: column;
    }
    .table-wrap.mobile-cards table.data td::before {
        content: attr(data-label);
        font-size: 10.5px; font-weight: 700; color: var(--text-muted);
        text-transform: uppercase; letter-spacing: 0.04em;
        margin-bottom: 2px;
    }
    .table-wrap.mobile-cards table.data td:last-child {
        grid-column: 1 / -1;
        flex-direction: row; align-items: center; gap: 6px;
        margin-top: 4px; padding-top: 10px;
        border-top: 1px solid var(--border);
    }
    .table-wrap.mobile-cards table.data td:last-child::before { display: none; }
}
