/* ==========================================================================
    Gloucester Maths Academy Design System — main.css
    Dark-themed UI with brand-aligned blue and gold accents
    ========================================================================== */

/* --- CSS Custom Properties --- */
:root {
    /* Colors - Dark Theme */
    --bg-primary: #0b1422;
    --bg-secondary: #111d2f;
    --bg-card: rgba(18, 29, 46, 0.72);
    --bg-card-solid: #152238;
    --bg-glass: rgba(255, 255, 255, 0.04);
    --bg-glass-hover: rgba(255, 255, 255, 0.08);
    --bg-input: rgba(255, 255, 255, 0.06);

    /* Accent Colors */
    --accent-primary: #0f4c97;
    --accent-secondary: #ad853b;
    --accent-gradient: linear-gradient(135deg, #0f4c97 0%, #2c67b0 100%);
    --accent-green: #00b894;
    --accent-green-light: #00e6b0;
    --accent-red: #ff6b6b;
    --accent-orange: #fdcb6e;
    --accent-blue: #74b9ff;

    /* Text */
    --text-primary: #eef3fb;
    --text-secondary: #b9c4d6;
    --text-muted: #8d9ab3;
    --text-accent: #2c67b0;

    /* Borders */
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glass: rgba(255, 255, 255, 0.12);

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(15, 76, 151, 0.22);

    /* Typography */
    --font-display: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 2rem;
    --text-4xl: 2.5rem;
    --text-5xl: 3.5rem;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 64px;
    --max-width: 1200px;

    /* Readability */
    --measure: 68ch;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
    font-size: 16px;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.65;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    -webkit-text-fill-color: currentColor;
}
a:hover { color: var(--accent-secondary); }

a,
button,
[role='button'],
input[type='button'],
input[type='submit'],
input[type='reset'],
summary {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

button,
input[type='button'],
input[type='submit'],
input[type='reset'] {
    -webkit-appearance: none;
    appearance: none;
    background-clip: padding-box;
}

a:active,
button:active,
[role='button']:active,
input[type='button']:active,
input[type='submit']:active,
input[type='reset']:active {
    -webkit-text-fill-color: currentColor;
}

img { max-width: 100%; height: auto; }

.brand-logo-surface {
    background: rgba(6, 12, 30, 0.52);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    box-shadow: none;
    padding: 5px 12px;
}

.brand-logo-surface img {
    display: block;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: 0.01em;
}

p {
    max-width: var(--measure);
}

/* --- Utility Classes --- */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent-primary); }

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.hidden { display: none !important; }

/* --- Glassmorphism Card --- */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}
.card:hover {
    border-color: rgba(15, 76, 151, 0.35);
    box-shadow: var(--shadow-glow);
}
.card-lg { padding: var(--space-xl); }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 10px 24px;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform var(--transition-base), background-color var(--transition-base), border-color var(--transition-base), color var(--transition-base), box-shadow var(--transition-base);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
    min-height: 40px;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-fill-color: currentColor;
}

button,
.btn {
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: translateY(0);
}

.btn-primary:active {
    background: #1a5aa7;
    color: #fff;
}

.btn-secondary:active {
    background: var(--bg-glass-hover);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.btn-success:active {
    filter: brightness(0.96);
    color: #fff;
}

.btn-danger:active {
    background: var(--accent-red);
    color: #fff;
}

.btn-ghost:active {
    background: var(--bg-glass);
    color: var(--text-primary);
}

button.form-select:active,
.nav-toggle:active,
.sidebar-toggle:active,
.filter-chip:active,
.claim-toggle:active {
    background: var(--bg-glass-hover);
    border-color: var(--accent-primary);
    color: var(--text-primary);
    -webkit-text-fill-color: currentColor;
}

.show-all-btn,
.claim-toggle {
    -webkit-tap-highlight-color: transparent;
    -webkit-text-fill-color: currentColor;
}

.show-all-btn:active {
    background: var(--bg-glass-hover);
    border-color: var(--accent-primary);
    color: var(--text-primary);
    -webkit-text-fill-color: currentColor;
}

.btn-primary {
    background: var(--accent-primary);
    color: #fff;
    box-shadow: 0 4px 18px rgba(15, 76, 151, 0.35);
}
.btn-primary:hover {
    transform: translateY(-2px);
    background: #1a5aa7;
    box-shadow: 0 8px 28px rgba(15, 76, 151, 0.48);
    color: #fff;
}

.btn-secondary {
    background: var(--bg-glass);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
}
.btn-secondary:hover {
    background: var(--bg-glass-hover);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.btn-success {
    background: linear-gradient(135deg, #00b894 0%, #00cec9 100%);
    color: #fff;
}
.btn-success:hover { transform: translateY(-2px); color: #fff; }

.btn-danger {
    background: rgba(255, 107, 107, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(255, 107, 107, 0.3);
}
.btn-danger:hover {
    background: var(--accent-red);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
}
.btn-ghost:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.btn:hover:active {
    transform: translateY(0);
}

.btn:disabled,
.btn[aria-disabled='true'],
button:disabled,
button[aria-disabled='true'],
[role='button'][aria-disabled='true'] {
    background: var(--bg-glass);
    border-color: var(--border-glass);
    color: var(--text-secondary);
    opacity: 0.9;
    cursor: wait;
    box-shadow: none;
    transform: none;
    -webkit-text-fill-color: var(--text-secondary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: var(--text-xs);
    min-height: 32px;
}

.btn-lg {
    padding: 14px 32px;
    font-size: var(--text-base);
    border-radius: var(--radius-lg);
    min-height: 46px;
}

/* --- Form Elements --- */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(15, 76, 151, 0.18);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a0a0c0' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.form-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

/* --- Status Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    font-size: var(--text-xs);
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-paid {
    background: rgba(0, 184, 148, 0.15);
    color: var(--accent-green);
    border: 1px solid rgba(0, 184, 148, 0.3);
}
.badge-pending {
    background: rgba(253, 203, 110, 0.15);
    color: var(--accent-orange);
    border: 1px solid rgba(253, 203, 110, 0.3);
}
.badge-failed {
    background: rgba(255, 107, 107, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(255, 107, 107, 0.3);
}
.badge-scheduled {
    background: rgba(116, 185, 255, 0.15);
    color: var(--accent-blue);
    border: 1px solid rgba(116, 185, 255, 0.3);
}
.badge-completed {
    background: rgba(0, 184, 148, 0.15);
    color: var(--accent-green);
    border: 1px solid rgba(0, 184, 148, 0.3);
}
.badge-cancelled {
    background: rgba(255, 107, 107, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(255, 107, 107, 0.3);
}

/* --- Tables --- */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-glass);
}

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

.data-table th {
    padding: 13px 16px;
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.data-table td {
    padding: 14px 16px;
    font-size: var(--text-sm);
    line-height: 1.5;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: var(--bg-glass);
}

/* --- Flash Messages --- */
.flash-messages {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    max-width: 400px;
}

.flash-msg {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    animation: flashIn 0.4s ease;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
}

.flash-msg.success {
    background: rgba(0, 184, 148, 0.15);
    color: var(--accent-green);
    border-color: rgba(0, 184, 148, 0.3);
}
.flash-msg.error {
    background: rgba(255, 107, 107, 0.15);
    color: var(--accent-red);
    border-color: rgba(255, 107, 107, 0.3);
}
.flash-msg.warning {
    background: rgba(253, 203, 110, 0.15);
    color: var(--accent-orange);
    border-color: rgba(253, 203, 110, 0.3);
}
.flash-msg.rate_limit {
    background: rgba(253, 203, 110, 0.15);
    color: var(--accent-orange);
    border-color: rgba(253, 203, 110, 0.3);
}
.flash-msg.info {
    background: rgba(116, 185, 255, 0.15);
    color: var(--accent-blue);
    border-color: rgba(116, 185, 255, 0.3);
}

@keyframes flashIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

/* --- Modal --- */
body.modal-open {
    overflow: hidden;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
}
.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    transform: scale(0.95) translateY(10px);
    transition: transform var(--transition-base);
}
.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}
.modal-title {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 700;
}
.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-size: var(--text-lg);
    transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.modal-close:hover {
    background: var(--accent-red);
    color: #fff;
    border-color: var(--accent-red);
}
.modal-close:active {
    background: var(--accent-red);
    color: #fff;
    border-color: var(--accent-red);
}

/* --- SVG icon helpers for section/page titles, filters, stat icons --- */
.section-title svg,
.page-title svg {
    flex-shrink: 0;
}
.filter-chip svg {
    vertical-align: -2px;
}
.stat-icon {
    margin-bottom: var(--space-sm);
}
.stat-icon svg {
    width: 28px;
    height: 28px;
}
.contact-icon svg {
    width: 24px;
    height: 24px;
}

/* --- Mobile: hide non-essential table columns --- */
@media (max-width: 768px) {
    .hide-mobile {
        display: none;
    }
}

/* --- Disable hover transforms on touch devices --- */
@media (hover: none) {
    .feature-card:hover {
        transform: none;
    }
    .testimonial-card:hover {
        transform: none;
    }
    .card:hover {
        border-color: var(--border-glass);
        box-shadow: none;
    }
    .session-item:hover {
        border-color: var(--border-glass);
        box-shadow: none;
    }
    .btn-primary:hover {
        transform: none;
    }
    .btn-success:hover {
        transform: none;
    }
}

/* --- Stat Cards --- */
.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-gradient);
}
.stat-card .stat-icon {
    font-size: 28px;
    margin-bottom: var(--space-sm);
}
.stat-card .stat-value {
    font-family: var(--font-display);
    font-size: var(--text-3xl);
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: var(--space-xs);
}
.stat-card .stat-label {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.stat-card.green::before {
    background: linear-gradient(135deg, #00b894, #00cec9);
}
.stat-card.orange::before {
    background: linear-gradient(135deg, #fdcb6e, #f39c12);
}
.stat-card.blue::before {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
}

/* --- Empty State --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-3xl) var(--space-lg);
    color: var(--text-muted);
}
.empty-state-icon {
    margin-bottom: var(--space-md);
    opacity: 0.5;
    line-height: 1;
}
.empty-state-icon svg {
    width: 48px;
    height: 48px;
}
.empty-state-title {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}
.empty-state p,
.empty-state .text-muted {
    max-width: none;
    width: 100%;
    text-align: center;
}

/* --- Page Header --- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-xl);
    flex-wrap: wrap;
    gap: var(--space-md);
}
.page-title {
    font-family: var(--font-display);
    font-size: clamp(1.45rem, 2vw, 1.9rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.01em;
}
.page-subtitle {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-top: 6px;
    line-height: 1.55;
}

/* --- Keyboard Accessibility --- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.btn:focus-visible,
.filter-chip:focus-visible,
.dash-nav a:focus-visible,
.pub-nav-links a:focus-visible {
    outline: 3px solid rgba(173, 133, 59, 0.85);
    outline-offset: 2px;
    border-radius: 8px;
}

.nav-toggle:focus-visible,
.modal-close:focus-visible,
.sidebar-toggle:focus-visible {
    outline: 3px solid rgba(173, 133, 59, 0.85);
    outline-offset: 2px;
}

a:focus:not(:focus-visible),
button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible),
[role='button']:focus:not(:focus-visible) {
    outline: none;
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    :root {
        --text-5xl: 2.5rem;
        --text-4xl: 2rem;
        --text-3xl: 1.5rem;
    }

    .container {
        padding: 0 var(--space-md);
    }

    .flash-messages {
        left: var(--space-md);
        right: var(--space-md);
        top: var(--space-md);
    }

    .form-grid-2 {
        grid-template-columns: 1fr;
    }

    .btn-sm {
        min-height: 44px;
    }

    .modal {
        width: calc(100% - (2 * var(--space-md)));
        padding: var(--space-lg);
        max-height: 90vh;
    }
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-glass); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Selection --- */
::selection { background: rgba(15, 76, 151, 0.35); }
