﻿/* ═══════════════════════════════════════════════════════════════════════════
   SKILZLY.CSS — Foundation Stylesheet
   ────────────────────────────────────────────────────────────────────────────
   Modern flat design · 8px rounded corners · Comfortable density · Mobile-first
   
   This is the foundation Skilzly stylesheet. It contains:
     1. CSS variables (set per-tenant by master page from TenantBranding)
     2. Reset / base styles
     3. Layout helpers (containers, grids, flex)
     4. Typography
     5. Buttons (.btn variants)
     6. Forms (inputs, selects, checkboxes, labels, validation)
     7. Cards / panels / sections
     8. Tables
     9. Modals
    10. Alerts and badges
    11. Loading states
    12. Utility classes
    13. Mobile responsive breakpoints
   
   PHILOSOPHY:
   - Every brand-coloured rule uses var(--brand-*) — never hardcoded hex
   - Mobile-first: base styles work on phones, larger screens enhance
   - Components are class-based, no IDs in selectors (specificity stays low)
   - 8px grid: spacing values are multiples of 8 (or 4 for fine-grain)
   
   ADDING NEW STYLES:
   When porting a page that needs styles not here, add them in two places:
   - Reusable patterns (used by multiple pages) → into this file, organised
     into the section it fits
   - Page-specific one-offs → in a <style> block on the page itself
   
   Last updated: 2026-04 (initial Skilzly multi-tenant build)
   ═══════════════════════════════════════════════════════════════════════════ */


/* ═════ 1. CSS VARIABLES ════════════════════════════════════════════════════
   These are FALLBACK values. The master page renders the actual tenant
   values from TenantBranding into a more-specific :root block in the page
   <head>, which overrides these. If anything ever falls through to these
   defaults, it's because the master page didn't load — which means
   something's wrong upstream.
   ═══════════════════════════════════════════════════════════════════════ */
:root {
    /* Brand (overridden per tenant) */
    --brand-primary: #2B7FBF;
    --brand-primary-hover: #1F5F8F;
    --brand-primary-light: #E3F2FD;
    --brand-secondary: #5BB9E5;
    --brand-text-on-primary: #FFFFFF;
    --brand-primary-rgb: 43, 127, 191;
    /* Status (universal, never per-tenant) */
    --status-success: #16A34A;
    --status-success-light: #DCFCE7;
    --status-error: #DC2626;
    --status-error-light: #FEE2E2;
    --status-warning: #D97706;
    --status-warning-light: #FEF3C7;
    --status-info: #2563EB;
    --status-info-light: #DBEAFE;
    /* Neutrals (Tailwind-style scale, 50-900) */
    --neutral-50: #FAFAFA;
    --neutral-100: #F4F4F5;
    --neutral-200: #E4E4E7;
    --neutral-300: #D4D4D8;
    --neutral-400: #A1A1AA;
    --neutral-500: #71717A;
    --neutral-600: #52525B;
    --neutral-700: #3F3F46;
    --neutral-800: #27272A;
    --neutral-900: #18181B;
    /* Surfaces */
    --bg-page: var(--neutral-50);
    --bg-card: #FFFFFF;
    --bg-input: #FFFFFF;
    --bg-overlay: rgba(0, 0, 0, 0.5);
    /* Text */
    --text-primary: var(--neutral-900);
    --text-secondary: var(--neutral-600);
    --text-muted: var(--neutral-500);
    --text-inverse: #FFFFFF;
    /* Borders */
    --border-subtle: var(--neutral-200);
    --border-default: var(--neutral-300);
    --border-strong: var(--neutral-400);
    /* Spacing scale (8px grid, 4px finegrain) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;
    --space-20: 80px;
    /* Border radius */
    --radius-sm: 4px;
    --radius: 8px; /* Default — use this everywhere unless reason not to */
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
    --text-xs: 12px;
    --text-sm: 14px;
    --text-base: 16px;
    --text-lg: 18px;
    --text-xl: 20px;
    --text-2xl: 24px;
    --text-3xl: 30px;
    --text-4xl: 36px;
    --text-5xl: 48px;
    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;
    --weight-normal: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition: 200ms ease;
    --transition-slow: 300ms ease;
    /* Z-index scale */
    --z-base: 0;
    --z-dropdown: 1000;
    --z-sticky: 1100;
    --z-overlay: 1200;
    --z-modal: 1300;
    --z-popover: 1400;
    --z-toast: 1500;
}


/* ═════ 2. RESET & BASE ════════════════════════════════════════════════════ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background: var(--bg-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

img, svg, video {
    display: block;
    max-width: 100%;
    height: auto;
}

a {
    color: var(--brand-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

    a:hover {
        color: var(--brand-primary-hover);
    }

    a:focus-visible {
        outline: 2px solid var(--brand-primary);
        outline-offset: 2px;
        border-radius: var(--radius-sm);
    }

button {
    font-family: inherit;
    cursor: pointer;
}

input, textarea, select {
    font-family: inherit;
    font-size: inherit;
}


/* ═════ 3. LAYOUT HELPERS ══════════════════════════════════════════════════ */
.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--space-4);
}

.container-sm {
    max-width: 640px;
}

.container-md {
    max-width: 768px;
}

.container-lg {
    max-width: 1024px;
}

.container-xl {
    max-width: 1280px;
}

.container-2xl {
    max-width: 1536px;
}

.row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
}

.row-sm {
    gap: var(--space-2);
}

.row-lg {
    gap: var(--space-6);
}

.stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.stack-sm {
    gap: var(--space-2);
}

.stack-lg {
    gap: var(--space-6);
}

.grid {
    display: grid;
    gap: var(--space-4);
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.flex-end {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}


/* ═════ 4. TYPOGRAPHY ══════════════════════════════════════════════════════ */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--weight-semibold);
    line-height: var(--leading-tight);
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

h1 {
    font-size: var(--text-4xl);
}

h2 {
    font-size: var(--text-3xl);
}

h3 {
    font-size: var(--text-2xl);
}

h4 {
    font-size: var(--text-xl);
}

h5 {
    font-size: var(--text-lg);
}

h6 {
    font-size: var(--text-base);
}

p {
    color: var(--text-primary);
}

.text-xs {
    font-size: var(--text-xs);
}

.text-sm {
    font-size: var(--text-sm);
}

.text-base {
    font-size: var(--text-base);
}

.text-lg {
    font-size: var(--text-lg);
}

.text-xl {
    font-size: var(--text-xl);
}

.text-2xl {
    font-size: var(--text-2xl);
}

.text-primary {
    color: var(--text-primary);
}

.text-secondary {
    color: var(--text-secondary);
}

.text-muted {
    color: var(--text-muted);
}

.text-inverse {
    color: var(--text-inverse);
}

.text-brand {
    color: var(--brand-primary);
}

.text-success {
    color: var(--status-success);
}

.text-error {
    color: var(--status-error);
}

.text-warning {
    color: var(--status-warning);
}

.font-normal {
    font-weight: var(--weight-normal);
}

.font-medium {
    font-weight: var(--weight-medium);
}

.font-semibold {
    font-weight: var(--weight-semibold);
}

.font-bold {
    font-weight: var(--weight-bold);
}

.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* ═════ 5. BUTTONS ═════════════════════════════════════════════════════════
   Base class: .btn
   Variants:   .btn-primary, .btn-secondary, .btn-outline, .btn-ghost,
               .btn-danger, .btn-success
   Sizes:      .btn-sm, .btn-lg
   Modifiers:  .btn-block (full width), .btn-icon (icon-only square)
   ═══════════════════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 10px 20px;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    line-height: 1.25;
    text-align: center;
    text-decoration: none;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
    white-space: nowrap;
    min-height: 40px;
}

    .btn:hover {
        background: var(--neutral-50);
        border-color: var(--border-strong);
    }

    .btn:active {
        transform: translateY(1px);
    }

    .btn:focus-visible {
        outline: 2px solid var(--brand-primary);
        outline-offset: 2px;
    }

    .btn:disabled,
    .btn[disabled] {
        opacity: 0.5;
        cursor: not-allowed;
        pointer-events: none;
    }

.btn-primary {
    background: var(--brand-primary);
    color: var(--brand-text-on-primary);
    border-color: var(--brand-primary);
}

    .btn-primary:hover {
        background: var(--brand-primary-hover);
        border-color: var(--brand-primary-hover);
        color: var(--brand-text-on-primary);
    }

.btn-secondary {
    background: var(--brand-primary-light);
    color: var(--brand-primary);
    border-color: transparent;
}

    .btn-secondary:hover {
        background: var(--brand-primary-light);
        color: var(--brand-primary-hover);
        filter: brightness(0.95);
    }

.btn-outline {
    background: transparent;
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}

    .btn-outline:hover {
        background: var(--brand-primary-light);
        color: var(--brand-primary-hover);
        border-color: var(--brand-primary-hover);
    }

.btn-ghost {
    background: transparent;
    color: var(--text-primary);
    border-color: transparent;
}

    .btn-ghost:hover {
        background: var(--neutral-100);
        border-color: transparent;
    }

.btn-danger {
    background: var(--status-error);
    color: var(--text-inverse);
    border-color: var(--status-error);
}

    .btn-danger:hover {
        filter: brightness(0.92);
        color: var(--text-inverse);
    }

.btn-success {
    background: var(--status-success);
    color: var(--text-inverse);
    border-color: var(--status-success);
}

    .btn-success:hover {
        filter: brightness(0.92);
        color: var(--text-inverse);
    }

.btn-sm {
    padding: 6px 12px;
    font-size: var(--text-xs);
    min-height: 32px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: var(--text-base);
    min-height: 48px;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    padding: 0;
    width: 40px;
    height: 40px;
    min-height: 40px;
}

    .btn-icon.btn-sm {
        width: 32px;
        height: 32px;
        min-height: 32px;
    }

    .btn-icon.btn-lg {
        width: 48px;
        height: 48px;
        min-height: 48px;
    }


/* ═════ 6. FORMS ═══════════════════════════════════════════════════════════
   .form-group     — wraps label + input + helper/error text
   .form-label     — label
   .form-input     — text input, textarea, select
   .form-helper    — small grey text below
   .form-error     — small red text below (also reddens the input)
   .form-checkbox  — checkbox + label combined
   .form-radio     — radio + label combined
   ═══════════════════════════════════════════════════════════════════════ */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.form-label {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
}

    .form-label .required {
        color: var(--status-error);
        margin-left: 2px;
    }

.form-input,
input[type="text"].form-input,
input[type="email"].form-input,
input[type="password"].form-input,
input[type="number"].form-input,
input[type="tel"].form-input,
input[type="url"].form-input,
input[type="search"].form-input,
input[type="date"].form-input,
input[type="time"].form-input,
input[type="datetime-local"].form-input,
textarea.form-input,
select.form-input {
    display: block;
    width: 100%;
    padding: 10px 12px;
    font-size: var(--text-sm);
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    min-height: 40px;
}

    .form-input::placeholder {
        color: var(--text-muted);
    }

    .form-input:hover:not(:disabled) {
        border-color: var(--border-strong);
    }

    .form-input:focus {
        outline: none;
        border-color: var(--brand-primary);
        box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.15);
    }

    .form-input:disabled {
        background: var(--neutral-100);
        color: var(--text-muted);
        cursor: not-allowed;
    }

textarea.form-input {
    min-height: 96px;
    resize: vertical;
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2371717A' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-helper {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.form-error {
    font-size: var(--text-xs);
    color: var(--status-error);
}

.form-input.is-invalid,
.form-group.has-error .form-input {
    border-color: var(--status-error);
}

    .form-input.is-invalid:focus,
    .form-group.has-error .form-input:focus {
        box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
    }

.form-checkbox,
.form-radio {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    user-select: none;
    font-size: var(--text-sm);
}

    .form-checkbox input[type="checkbox"],
    .form-radio input[type="radio"] {
        width: 18px;
        height: 18px;
        accent-color: var(--brand-primary);
        cursor: pointer;
    }

/* Inline form layouts */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-4);
}


/* ═════ 7. CARDS / PANELS ══════════════════════════════════════════════════ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast);
}

.card-elevated {
    box-shadow: var(--shadow);
}

    .card-elevated:hover {
        box-shadow: var(--shadow-md);
    }

.card-header {
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}

    .card-header h2,
    .card-header h3 {
        margin: 0;
    }

.card-footer {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
}

.section {
    padding: var(--space-8) 0;
}

.section-header {
    text-align: center;
    margin-bottom: var(--space-8);
}

.section-title {
    font-size: var(--text-3xl);
    margin-bottom: var(--space-2);
}

.section-subtitle {
    color: var(--text-secondary);
    font-size: var(--text-lg);
}


/* ═════ 8. TABLES ══════════════════════════════════════════════════════════ */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
    border: 1px solid var(--border-subtle);
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    font-size: var(--text-sm);
}

    .table th,
    .table td {
        padding: var(--space-3) var(--space-4);
        text-align: left;
        border-bottom: 1px solid var(--border-subtle);
    }

    .table th {
        background: var(--neutral-50);
        font-weight: var(--weight-semibold);
        color: var(--text-secondary);
        font-size: var(--text-xs);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        white-space: nowrap;
    }

    .table tr:last-child td {
        border-bottom: none;
    }

    .table tbody tr:hover {
        background: var(--neutral-50);
    }


/* ═════ 9. MODALS ══════════════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: var(--z-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    animation: fadeIn var(--transition) both;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 560px;
    width: 100%;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    z-index: var(--z-modal);
    animation: slideUp var(--transition) both;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
    font-size: var(--text-xl);
    font-weight: var(--weight-semibold);
}

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border-subtle);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
}

    .modal-close:hover {
        background: var(--neutral-100);
        color: var(--text-primary);
    }


/* ═════ 10. ALERTS & BADGES ════════════════════════════════════════════════ */
.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    border-left: 4px solid;
    font-size: var(--text-sm);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

.alert-info {
    background: var(--status-info-light);
    border-left-color: var(--status-info);
    color: #1E3A8A;
}

.alert-success {
    background: var(--status-success-light);
    border-left-color: var(--status-success);
    color: #14532D;
}

.alert-warning {
    background: var(--status-warning-light);
    border-left-color: var(--status-warning);
    color: #78350F;
}

.alert-error {
    background: var(--status-error-light);
    border-left-color: var(--status-error);
    color: #7F1D1D;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    line-height: 1.5;
    background: var(--neutral-200);
    color: var(--text-secondary);
}

.badge-brand {
    background: var(--brand-primary-light);
    color: var(--brand-primary);
}

.badge-success {
    background: var(--status-success-light);
    color: #14532D;
}

.badge-error {
    background: var(--status-error-light);
    color: #7F1D1D;
}

.badge-warning {
    background: var(--status-warning-light);
    color: #78350F;
}


/* ═════ 11. LOADING STATES ═════════════════════════════════════════════════ */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--neutral-200);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: var(--z-overlay);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: var(--space-4);
}

    .loading-overlay.is-active {
        display: flex;
    }

    .loading-overlay .loading-text {
        color: var(--text-secondary);
        font-size: var(--text-sm);
    }

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ═════ 12. UTILITIES ══════════════════════════════════════════════════════ */
.hidden {
    display: none !important;
}

.invisible {
    visibility: hidden;
}

/* Margins */
.mt-0 {
    margin-top: 0;
}

.mb-0 {
    margin-bottom: 0;
}

.mt-1 {
    margin-top: var(--space-1);
}

.mb-1 {
    margin-bottom: var(--space-1);
}

.mt-2 {
    margin-top: var(--space-2);
}

.mb-2 {
    margin-bottom: var(--space-2);
}

.mt-3 {
    margin-top: var(--space-3);
}

.mb-3 {
    margin-bottom: var(--space-3);
}

.mt-4 {
    margin-top: var(--space-4);
}

.mb-4 {
    margin-bottom: var(--space-4);
}

.mt-6 {
    margin-top: var(--space-6);
}

.mb-6 {
    margin-bottom: var(--space-6);
}

.mt-8 {
    margin-top: var(--space-8);
}

.mb-8 {
    margin-bottom: var(--space-8);
}

/* Padding */
.p-0 {
    padding: 0;
}

.p-2 {
    padding: var(--space-2);
}

.p-4 {
    padding: var(--space-4);
}

.p-6 {
    padding: var(--space-6);
}

.p-8 {
    padding: var(--space-8);
}

/* Display */
.block {
    display: block;
}

.inline {
    display: inline;
}

.inline-block {
    display: inline-block;
}

.flex {
    display: flex;
}

.inline-flex {
    display: inline-flex;
}

.grid-d {
    display: grid;
}

/* Width */
.w-full {
    width: 100%;
}

.w-auto {
    width: auto;
}

.max-w-sm {
    max-width: 24rem;
}

.max-w-md {
    max-width: 28rem;
}

.max-w-lg {
    max-width: 32rem;
}

.max-w-xl {
    max-width: 36rem;
}

.max-w-2xl {
    max-width: 42rem;
}


/* ═════ 13. RESPONSIVE — MOBILE FIRST ══════════════════════════════════════
   Base styles above are mobile (≤640px width). Breakpoints below ENHANCE
   for larger screens. Always test on a real phone before declaring "done".
   
   Breakpoints:
     sm:  640px   (large phones / portrait tablets)
     md:  768px   (tablets / small laptops)
     lg:  1024px  (laptops)
     xl:  1280px  (desktops)
     2xl: 1536px  (large desktops)
   ═══════════════════════════════════════════════════════════════════════ */

/* Mobile defaults (no media query needed — below all breakpoints) */
.grid-2, .grid-3, .grid-4 {
    grid-template-columns: minmax(0, 1fr); /* single column on mobile */
}

@media (min-width: 640px) {
    .grid-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sm\:hidden {
        display: none !important;
    }

    .sm\:block {
        display: block;
    }
}

@media (min-width: 768px) {
    h1 {
        font-size: var(--text-5xl);
    }

    h2 {
        font-size: var(--text-4xl);
    }

    .grid-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .container {
        padding: 0 var(--space-6);
    }

    .md\:hidden {
        display: none !important;
    }

    .md\:block {
        display: block;
    }

    .md\:flex {
        display: flex;
    }
}

@media (min-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .lg\:hidden {
        display: none !important;
    }

    .lg\:block {
        display: block;
    }
}

/* Tablet/mobile: tighten card padding to avoid feeling cramped */
@media (max-width: 640px) {
    .card {
        padding: var(--space-4);
    }

    .modal {
        max-width: 100%;
    }

    .btn-lg {
        padding: 12px 20px;
        min-height: 44px;
    }

    .table th, .table td {
        padding: var(--space-2) var(--space-3);
    }
}

/* Print */
@media print {
    .btn, .modal-overlay, .loading-overlay {
        display: none !important;
    }

    body {
        background: white;
    }
}


/* ═════ 14. TRAINING DASHBOARD (td-*) ══════════════════════════════════════
   Component classes for TestDesc.aspx (the learner training dashboard).
   All prefixed td- to avoid collisions with foundation classes.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Wrapper & layout ─────────────────────────────────────────────────── */
.td-training-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px 48px;
}

.td-reset * {
    box-sizing: border-box;
}

.td-body {
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--bg-page);
}

.td-welcome-title {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
}

/* ── Header row ───────────────────────────────────────────────────────── */
.td-header-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 24px;
}

.td-logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.td-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--brand-primary);
    color: var(--brand-text-on-primary);
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.td-brand-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ── Dashboard stat cards grid ────────────────────────────────────────── */
.td-dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.td-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

    .td-stat-card:hover {
        box-shadow: var(--shadow-md);
    }

.td-avatar-card {
    cursor: pointer;
}

    .td-avatar-card:hover {
        transform: translateY(-2px);
    }

.td-xpoints-card {
    border-top: 3px solid #0d9488;
}

.td-streak-card {
    border-top: 3px solid #ea6c00;
}

.td-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.td-card-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.td-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.td-stat-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

.td-help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--neutral-200);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition-fast);
}

    .td-help-icon:hover {
        background: var(--neutral-300);
    }

/* ── Avatar display (inside avatar stat card) ─────────────────────────── */
.td-avatar-display {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
}

.td-avatar-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
}

.placeholder-text {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.td-avatar-image-container {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.td-avatar-image {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border-subtle);
}

.td-avatar-hover-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
}

.td-avatar-image-container:hover .td-avatar-hover-overlay {
    display: flex;
}

.td-avatar-hover-icons {
    display: flex;
    gap: 12px;
}

.td-avatar-hover-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    transition: background var(--transition-fast);
}

    .td-avatar-hover-icon:hover {
        background: white;
    }

.td-avatar-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.6);
    text-align: center;
    border-radius: 0 0 50px 50px;
    padding: 4px;
}

.td-avatar-text {
    font-size: 10px;
    color: white;
    font-weight: 600;
}

/* ── Insights / Weekly Progress section ───────────────────────────────── */
.td-insights-section {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.td-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.td-weekly-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.td-weekly-stat-card {
    background: var(--neutral-50);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.td-goal-progress-card {
    background: var(--brand-primary-light);
    border-color: rgba(var(--brand-primary-rgb), 0.2);
}

.td-weekly-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    margin-bottom: 4px;
}

.td-weekly-stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.td-weekly-stat-goal {
    font-size: 11px;
    color: var(--text-muted);
}

.td-weekly-stat-month {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Badges card ──────────────────────────────────────────────────────── */
.td-my-badges-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

    .td-my-badges-card h3 {
        font-size: 14px;
        font-weight: 700;
        color: var(--text-primary);
        margin-bottom: 12px;
    }

/* ── Course list wrapper ──────────────────────────────────────────────── */
.td-stat-cardleft {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

/* ── Form row ─────────────────────────────────────────────────────────── */
.td-form-row {
    margin-bottom: 16px;
}

/* ── Monthly Quiz floating button ─────────────────────────────────────── */
.td-monthly-quiz-container {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: var(--z-popover);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.td-quiz-icon-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid #f59e0b;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

    .td-quiz-icon-button:hover {
        transform: scale(1.08);
        box-shadow: var(--shadow-xl);
    }

.td-quiz-badge {
    background: #dc2626;
    color: white;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    letter-spacing: 0.06em;
}

.td-quiz-tooltip {
    position: absolute;
    bottom: 68px;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    display: none;
    line-height: 1.5;
}

.td-monthly-quiz-container:hover .td-quiz-tooltip {
    display: block;
}

/* ── Quiz info card (quizInfoCard) ───────────────────────────────────── */
.td-quiz-info-content {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 360px;
    margin: 0 auto;
    text-align: center;
    box-shadow: var(--shadow-md);
    position: relative;
}

.td-quiz-info-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

    .td-quiz-info-close:hover {
        background: var(--neutral-100);
        color: var(--text-primary);
    }

.td-quiz-info-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #fef9e7;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
}

.td-quiz-info-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.td-quiz-info-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 14px;
    line-height: 1.5;
}

.td-quiz-info-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    text-align: left;
    background: var(--neutral-50);
    border-radius: var(--radius);
    padding: 12px;
}

.td-quiz-info-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 28px;
    background: var(--brand-primary);
    color: var(--brand-text-on-primary);
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast);
}

    .td-quiz-info-button:hover {
        background: var(--brand-primary-hover);
    }

/* ── Avatar creator modal ─────────────────────────────────────────────── */
.td-avatar-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
    padding: 16px;
}

    .td-avatar-modal.open {
        display: flex;
    }

.td-avatar-modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

    .td-avatar-modal-content.generating {
        animation: pulse 1.5s ease-in-out infinite;
    }

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.td-avatar-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

    .td-avatar-modal-header h2 {
        font-size: 16px;
        font-weight: 700;
        color: var(--text-primary);
        margin: 0;
    }

.td-avatar-close {
    background: none;
    border: none;
    font-size: 26px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast), color var(--transition-fast);
}

    .td-avatar-close:hover {
        background: var(--neutral-100);
        color: var(--text-primary);
    }

/* ── Avatar steps ─────────────────────────────────────────────────────── */
.td-avatar-step {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

    .td-avatar-step.active {
        display: block;
    }

    .td-avatar-step h3 {
        font-size: 16px;
        font-weight: 700;
        color: var(--text-primary);
        margin-bottom: 6px;
    }

    .td-avatar-step p {
        font-size: 13px;
        color: var(--text-secondary);
        margin-bottom: 16px;
    }

.td-avatar-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 10px;
}

.td-avatar-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 8px;
    background: var(--neutral-50);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
    text-align: center;
}

    .td-avatar-option:hover {
        border-color: var(--brand-primary);
        background: var(--brand-primary-light);
        transform: translateY(-2px);
    }

    .td-avatar-option.selected {
        border-color: var(--brand-primary);
        background: var(--brand-primary-light);
        box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.15);
    }

.td-option-icon {
    font-size: 28px;
    line-height: 1;
}

.td-option-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

/* ── Avatar modal footer ──────────────────────────────────────────────── */
.td-avatar-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.td-prev-btn {
    padding: 10px 20px;
    background: var(--neutral-100);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast);
}

    .td-prev-btn:hover {
        background: var(--neutral-200);
    }

.td-avatar-btn {
    padding: 10px 24px;
    background: var(--brand-primary);
    color: var(--brand-text-on-primary);
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast);
}

    .td-avatar-btn:hover {
        background: var(--brand-primary-hover);
    }

.td-generate-btn {
    padding: 10px 24px;
    background: var(--brand-primary);
    color: var(--brand-text-on-primary);
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 8px;
}

    .td-generate-btn:hover {
        background: var(--brand-primary-hover);
    }

/* ── Responsive adjustments for td-* ─────────────────────────────────── */
@media (max-width: 768px) {
    .td-dashboard-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .td-weekly-stats {
        grid-template-columns: 1fr;
    }

    .td-avatar-options-grid {
        grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    }

    .td-training-wrapper {
        padding: 16px 12px 40px;
    }

    .td-monthly-quiz-container {
        bottom: 16px;
        right: 16px;
    }
}

@media (max-width: 480px) {
    .td-dashboard-stats {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .td-stat-value {
        font-size: 22px;
    }
}


/* ═════ END OF FOUNDATION SKILZLY.CSS ══════════════════════════════════════
   When porting a page that needs additional patterns:
   - If the pattern is reusable across pages, add to this file
   - If page-specific, add to that page's <style> block
   - Always use var(--brand-*) for brand colours, never hardcoded hex
   ═══════════════════════════════════════════════════════════════════════ */
