/* ============================================================
   TRAINLY — Design System · Dark Premium
   app.css — Global tokens, reset, utilities
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Sora:wght@600;700;800&display=swap');

/* ── CSS Custom Properties ─────────────────────────────────── */
:root {
    /* Background scale */
    --bg-primary:    #0A0A0F;
    --bg-secondary:  #111118;
    --bg-elevated:   #1A1A24;
    --bg-card:       #14141C;
    --bg-border:     #2A2A3A;
    --bg-hover:      #1E1E2E;

    /* Accent — Verde-lima fitness */
    --accent:        #C8F400;
    --accent-hover:  #B0D900;
    --accent-muted:  #C8F40018;
    --accent-text:   #0A0A0F;

    /* White-label overrides (default = accent) */
    --color-primary:       var(--accent);
    --color-primary-muted: var(--accent-muted);
    --color-primary-hover: var(--accent-hover);
    --color-secondary:     var(--bg-secondary);

    /* Text scale */
    --text-primary:    #F0F0F8;
    --text-secondary:  #8888A8;
    --text-muted:      #55556A;
    --text-inverse:    #0A0A0F;

    /* Semantic colors */
    --success:   #00C896;
    --warning:   #F5A623;
    --danger:    #FF4D6A;
    --info:      #4D9FFF;
    --success-muted: #00C89618;
    --warning-muted: #F5A62318;
    --danger-muted:  #FF4D6A18;

    /* Typography */
    --font-heading: 'Sora', sans-serif;
    --font-body:    'Inter', sans-serif;

    /* Type scale */
    --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:  1.875rem;
    --text-4xl:  2.25rem;
    --text-5xl:  3rem;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* Border radius */
    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  14px;
    --radius-xl:  20px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
    --shadow-md:  0 4px 16px rgba(0,0,0,0.5);
    --shadow-lg:  0 8px 32px rgba(0,0,0,0.6);
    --shadow-accent: 0 0 20px rgba(200,244,0,0.15);

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

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

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

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

img, video { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ── Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    line-height: 1.2;
    color: var(--text-primary);
}

h1 { font-size: var(--text-4xl); font-weight: 800; }
h2 { font-size: var(--text-3xl); font-weight: 700; }
h3 { font-size: var(--text-2xl); font-weight: 600; }
h4 { font-size: var(--text-xl);  font-weight: 600; }
h5 { font-size: var(--text-lg);  font-weight: 600; }

p { color: var(--text-secondary); line-height: 1.7; }

/* ── Card ───────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    transition: border-color var(--transition-fast);
}
.card:hover { border-color: #3A3A4A; }
.card-title { font-size: var(--text-lg); font-weight: 600; margin-bottom: var(--space-4); color: var(--text-primary); }

/* ── Stat Card ──────────────────────────────────────────────── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--color-primary);
    opacity: 0;
    transition: opacity var(--transition-base);
}
.stat-card:hover { border-color: var(--color-primary); transform: translateY(-2px); }
.stat-card:hover::before { opacity: 1; }
.stat-card-icon {
    width: 40px; height: 40px;
    background: var(--color-primary-muted);
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
}
.stat-card-value { font-family: var(--font-heading); font-size: var(--text-3xl); font-weight: 700; color: var(--text-primary); }
.stat-card-label { font-size: var(--text-sm); color: var(--text-muted); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 600;
    font-family: var(--font-body);
    transition: all var(--transition-fast);
    cursor: pointer;
    border: none;
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--text-inverse);
}
.btn-primary:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-accent);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--bg-border);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: #3A3A4A; }

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

.btn-danger {
    background: var(--danger-muted);
    color: var(--danger);
    border: 1px solid transparent;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 6px 14px; font-size: var(--text-xs); }
.btn-lg { padding: 14px 28px; font-size: var(--text-base); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: var(--space-2); }
.form-label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
}
.form-control {
    background: var(--bg-elevated);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 10px 14px;
    font-size: var(--text-sm);
    font-family: var(--font-body);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    width: 100%;
    outline: none;
}
.form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-muted);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled { opacity: 0.5; cursor: not-allowed; }
textarea.form-control { resize: vertical; min-height: 100px; }

.form-error { font-size: var(--text-xs); color: var(--danger); }
.form-help  { font-size: var(--text-xs); color: var(--text-muted); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
}
.badge-success { background: var(--success-muted); color: var(--success); }
.badge-warning { background: var(--warning-muted); color: var(--warning); }
.badge-danger  { background: var(--danger-muted);  color: var(--danger);  }
.badge-muted   { background: var(--bg-elevated);   color: var(--text-muted); }
.badge-accent  { background: var(--accent-muted);  color: var(--accent);  }

/* ── Avatar ─────────────────────────────────────────────────── */
.avatar {
    width: 40px; height: 40px;
    border-radius: var(--radius-full);
    background: var(--color-primary-muted);
    border: 2px solid var(--color-primary);
    display: flex; align-items: center; justify-content: center;
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--color-primary);
    flex-shrink: 0;
    overflow: hidden;
}
.avatar-sm { width: 32px; height: 32px; font-size: 10px; }
.avatar-lg { width: 56px; height: 56px; font-size: var(--text-base); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ── Table ──────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-lg); }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}
.table th {
    padding: 12px 16px;
    text-align: left;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--bg-border);
    white-space: nowrap;
}
.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--bg-border);
    color: var(--text-secondary);
    vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--transition-fast); }
.table tbody tr:hover { background: var(--bg-hover); }

/* ── Alert / Toast ───────────────────────────────────────────── */
.alert {
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    border-left: 3px solid;
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
}
.alert-success { background: var(--success-muted); border-color: var(--success); color: var(--success); }
.alert-warning { background: var(--warning-muted); border-color: var(--warning); color: var(--warning); }
.alert-danger  { background: var(--danger-muted);  border-color: var(--danger);  color: var(--danger);  }
.alert-info    { background: #4D9FFF18;             border-color: var(--info);    color: var(--info);    }

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: var(--space-16) var(--space-8);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
}
.empty-state-icon { font-size: 3rem; opacity: 0.4; }
.empty-state-title { font-size: var(--text-xl); font-weight: 600; }
.empty-state-desc  { font-size: var(--text-sm); color: var(--text-muted); max-width: 360px; }

/* ── Color picker preview ───────────────────────────────────── */
.color-preview {
    width: 28px; height: 28px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--bg-border);
    cursor: pointer;
}

/* ── Divider ────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--bg-border); margin: var(--space-6) 0; }

/* ── Section header ─────────────────────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
    gap: var(--space-4);
    flex-wrap: wrap;
}
.section-title { font-size: var(--text-2xl); font-weight: 700; }
.section-desc  { font-size: var(--text-sm); color: var(--text-muted); margin-top: var(--space-1); }

/* ── Grid utilities ─────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }

@media (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px)  { .grid-3, .grid-4 { grid-template-columns: 1fr; } }
@media (max-width: 640px)  { .grid-2 { grid-template-columns: 1fr; } }

/* ── Flex utilities ─────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.flex-1 { flex: 1; }

/* ── Spacing utilities ──────────────────────────────────────── */
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

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

/* ── Selection ──────────────────────────────────────────────── */
::selection { background: var(--color-primary-muted); color: var(--text-primary); }

/* ── Validation (ASP.NET) ────────────────────────────────────── */
.field-validation-error { font-size: var(--text-xs); color: var(--danger); display: block; margin-top: 4px; }
.validation-summary-errors { background: var(--danger-muted); border-left: 3px solid var(--danger); padding: var(--space-4); border-radius: var(--radius-md); margin-bottom: var(--space-4); }
.validation-summary-errors ul { list-style: none; }
.validation-summary-errors li { font-size: var(--text-sm); color: var(--danger); }
.input-validation-error { border-color: var(--danger) !important; }

/* ── Mobile-First Responsive ───────────────────────────────── */
@media (max-width: 640px) {
    /* Prevent iOS zoom on input focus (requires 16px minimum) */
    .form-control, select.form-control, textarea.form-control {
        font-size: 16px;
    }

    /* Larger touch targets */
    .btn { padding: 12px 20px; min-height: 44px; }
    .btn-sm { padding: 8px 16px; min-height: 36px; }
    .btn-lg { padding: 14px 24px; }

    /* Headings */
    h1 { font-size: var(--text-2xl); }
    h2 { font-size: var(--text-xl); }
    h3 { font-size: var(--text-lg); }

    /* Grid collapses */
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

    /* Tables horizontal scroll */
    .table-wrapper { -webkit-overflow-scrolling: touch; }

    /* Section headers */
    .section-header { flex-direction: column; align-items: flex-start; }
    
    /* Stat cards */
    .stat-card-value { font-size: var(--text-2xl); }

    /* Admin nav scroll */
    .admin-nav { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
    .admin-nav-link { white-space: nowrap; flex-shrink: 0; }

    /* Responsive Table - Stack columns on mobile */
    .table.responsive-table {
        display: block;
        width: 100%;
    }
    .table.responsive-table thead {
        display: none;
    }
    .table.responsive-table tbody {
        display: block;
        width: 100%;
    }
    .table.responsive-table tr {
        display: block;
        width: 100%;
        background: var(--bg-card);
        border: 1px solid var(--bg-border);
        border-radius: var(--radius-lg);
        padding: var(--space-4);
        margin-bottom: var(--space-4);
        box-sizing: border-box;
    }
    .table.responsive-table tr:hover {
        background: var(--bg-hover) !important;
    }
    .table.responsive-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: var(--space-2) 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        font-size: var(--text-sm);
        text-align: right;
        min-height: 36px;
    }
    .table.responsive-table td:last-child {
        border-bottom: none;
        padding-bottom: 0;
        margin-top: var(--space-2);
    }
    .table.responsive-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        text-align: left;
        margin-right: var(--space-4);
        font-size: var(--text-xs);
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }
    .table.responsive-table td[colspan] {
        display: block;
        text-align: center;
        border-bottom: none;
        padding: var(--space-4) 0;
    }
    .table.responsive-table td[colspan]::before {
        display: none;
    }
}

/* Safe area for notch devices (iPhone X+) */
@supports (padding: env(safe-area-inset-bottom)) {
    .bottom-nav { padding-bottom: env(safe-area-inset-bottom); }
    .student-layout { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
}

