:root {
    --primary:        #f97316;
    --primary-dark:   #ea580c;
    --primary-light:  #fff7ed;
    --primary-border: #fed7aa;
    --bg:             #f1f5f9;
    --surface:        #ffffff;
    --surface-2:      #f8fafc;
    --border:         #e2e8f0;
    --border-strong:  #cbd5e1;
    --text:           #1e293b;
    --text-muted:     #64748b;
    --text-light:     #94a3b8;
    --green:          #22c55e;
    --green-bg:       #f0fdf4;
    --green-border:   #bbf7d0;
    --green-text:     #16a34a;
    --shadow-sm:      0 1px 2px rgba(0,0,0,0.06);
    --shadow:         0 1px 4px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:      0 4px 12px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
    --radius:         12px;
    --radius-sm:      8px;
}

/* ─── Base ─── */
body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* ─── Navbar ─── */
.navbar {
    background: var(--surface) !important;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding-top: 10px;
    padding-bottom: 10px;
}
.navbar-brand { color: var(--primary) !important; font-size: 1.3rem; font-weight: 800; }
.navbar-nav .nav-link { color: var(--text-muted) !important; font-weight: 500; }
.navbar-nav .nav-link:hover { color: var(--primary) !important; }
.navbar-toggler { border-color: var(--border); }

/* ─── Cards ─── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-header {
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0 !important;
    font-weight: 600;
}

/* ─── Buttons ─── */
.btn { border-radius: var(--radius-sm); font-weight: 600; padding: 9px 18px; }
.btn-lg { padding: 13px 24px; font-size: 1rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-outline-warning { color: var(--primary-dark); border-color: var(--primary); }
.btn-outline-warning:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-outline-secondary { color: var(--text-muted); border-color: var(--border-strong); }
.btn-outline-secondary:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-outline-danger { color: #ef4444; border-color: #fca5a5; }
.btn-outline-danger:hover { background: #fef2f2; color: #dc2626; border-color: #ef4444; }
.btn-danger { background: #ef4444; border-color: #ef4444; color: #fff; }

/* ─── Forms ─── */
.form-control, .form-select {
    background: var(--surface);
    border: 1.5px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 15px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-select:focus {
    background: var(--surface);
    border-color: var(--primary);
    color: var(--text);
    box-shadow: 0 0 0 3px rgba(249,115,22,0.15);
}
.form-control::placeholder { color: var(--text-light); }
.form-control-sm { padding: 7px 10px; font-size: 14px; }
.form-label { font-weight: 600; color: var(--text); margin-bottom: 6px; }

/* ─── Badges ─── */
.badge-modality {
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid var(--primary-border);
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 20px;
    padding: 3px 10px;
}
.free-badge {
    background: var(--green-bg);
    color: var(--green-text);
    border: 1px solid var(--green-border);
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 20px;
    padding: 3px 10px;
}

/* ─── Alerts ─── */
.alert-success { background: var(--green-bg); border-color: var(--green-border); color: var(--green-text); }
.alert-danger { background: #fef2f2; border-color: #fca5a5; color: #b91c1c; }
.alert-warning { background: var(--primary-light); border-color: var(--primary-border); color: var(--primary-dark); }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }

/* ─── Calendar ─── */
.calendar-grid {
    display: grid;
    grid-template-columns: 52px repeat(7, 1fr);
    gap: 3px;
}
.calendar-grid .day-header {
    background: var(--primary);
    color: #fff;
    padding: 8px 4px;
    text-align: center;
    font-size: 0.68rem;
    font-weight: 700;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.calendar-grid .week-label {
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 6px;
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}
.calendar-cell {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px;
    min-height: 62px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.calendar-cell:hover { border-color: var(--primary); background: var(--primary-light); }
.calendar-cell .workout-badge {
    background: var(--green-bg);
    color: var(--green-text);
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 0.65rem;
    font-weight: 700;
    border: 1px solid var(--green-border);
    line-height: 1.4;
}
.calendar-cell .add-btn {
    color: var(--text-light);
    font-size: 1.1rem;
    text-align: center;
    margin-top: auto;
}
.calendar-cell:hover .add-btn { color: var(--primary); }

/* ─── Exercise rows (edit modal) ─── */
.exercise-row {
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 10px;
}
.exercise-row .exercise-name {
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
    font-size: 0.95rem;
}
.set-number {
    width: 28px;
    height: 28px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

/* ─── Personal card (legacy, used on search.php/profile pages) ─── */
.personal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow);
}
.personal-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.personal-card .card-img { height: 200px; object-fit: cover; }

/* ─── Stat cards ─── */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    box-shadow: var(--shadow);
}
.stat-card .stat-value { font-size: 2rem; font-weight: 800; color: var(--primary); line-height: 1.2; }
.stat-card .stat-label { font-size: 0.82rem; color: var(--text-muted); margin-top: 4px; }

/* ─── Sidebar ─── */
.sidebar {
    background: var(--surface);
    min-height: calc(100vh - 56px);
    border-right: 1px solid var(--border);
    padding: 12px 0;
}
.sidebar .nav-link {
    color: var(--text-muted);
    padding: 11px 20px;
    border-radius: 0;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.sidebar .nav-link:hover, .sidebar .nav-link.active {
    color: var(--primary);
    background: var(--primary-light);
    border-right: 3px solid var(--primary);
}
.sidebar .nav-link i { width: 20px; }

/* ─── Progress bar ─── */
.progress { background: var(--border); border-radius: 4px; height: 8px; }
.progress-bar { background: var(--primary); }

/* ─── Table ─── */
.table { color: var(--text); }
.table > :not(caption) > * > * { background: transparent; border-color: var(--border); }
.table thead th {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 10px 12px;
}
.table tbody tr:hover { background: var(--surface-2); }
.table tbody td { padding: 12px; vertical-align: middle; }

/* ─── Modal ─── */
.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal-header {
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 16px 20px;
}
.modal-footer {
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    padding: 14px 20px;
}
.modal-body { padding: 20px; }
.modal-title { font-weight: 700; color: var(--text); }
.btn-close { filter: none; opacity: 0.5; }
.btn-close:hover { opacity: 1; }

/* ─── Exercise Card (view & workout pages) ─── */
.ex-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}
.ex-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.ex-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    color: var(--primary);
}

/* Sets table header */
.sets-header {
    display: grid;
    padding: 9px 16px;
    background: var(--surface-2);
    font-size: 0.67rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    text-align: center;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.sets-header.with-check { grid-template-columns: 52px 1fr 1fr 52px; }
.sets-header.no-check   { grid-template-columns: 52px 1fr 1fr; }

/* Individual set row */
.set-row {
    display: grid;
    padding: 13px 16px;
    align-items: center;
    text-align: center;
    border-top: 1px solid var(--border);
    transition: background 0.15s;
    color: var(--text);
}
.set-row.with-check { grid-template-columns: 52px 1fr 1fr 52px; cursor: pointer; user-select: none; }
.set-row.no-check   { grid-template-columns: 52px 1fr 1fr; }
.set-row.with-check:hover { background: var(--primary-light); }
.set-row.done { background: var(--green-bg) !important; }
.set-row.done .set-bubble { background: var(--green) !important; }
.set-row.done .set-check-circle {
    background: var(--green) !important;
    border-color: var(--green) !important;
}
.set-row.done .set-check-circle i { opacity: 1 !important; color: #fff; }
.set-row.done .set-value { color: var(--green-text); }

/* Set number bubble */
.set-bubble {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    margin: 0 auto;
    color: #fff;
    transition: background 0.2s;
    flex-shrink: 0;
}

/* Set values (reps / weight) */
.set-value { font-weight: 700; font-size: 1rem; color: var(--text); }

/* Done circle indicator */
.set-check-circle {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border-strong);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    font-size: 0.65rem;
    transition: all 0.2s;
    color: transparent;
}
.set-check-circle i { opacity: 0; transition: opacity 0.15s; color: #fff; }

/* Aerobic stats inside card */
.aerobic-stats { display: flex; gap: 12px; padding: 16px; }
.aerobic-stat-box {
    flex: 1;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 12px;
    text-align: center;
}
.aerobic-stat-box .stat-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-weight: 700;
}
.aerobic-stat-box .stat-val { font-size: 1.5rem; font-weight: 800; color: var(--text); }

/* Workout progress bar (student) */
.workout-progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.workout-progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.35s ease;
}

/* ─── Onboarding Wizard ─── */
.wizard-steps {
    display: flex;
    margin-bottom: 2rem;
}
.wiz-step-dot {
    flex: 1;
    text-align: center;
    position: relative;
}
.wiz-step-dot .dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    background: var(--border);
    color: var(--text-muted);
    transition: background 0.3s, color 0.3s;
    position: relative;
    z-index: 1;
}
.wiz-step-dot.active .dot,
.wiz-step-dot.done .dot {
    background: var(--primary);
    color: #fff;
}
.wiz-step-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.wiz-step-dot.active .wiz-step-label,
.wiz-step-dot.done .wiz-step-label {
    color: var(--primary);
}
.wiz-step-dot::before,
.wiz-step-dot::after {
    content: '';
    position: absolute;
    top: 17px;
    height: 2px;
    background: var(--border);
    width: 50%;
    transition: background 0.3s;
}
.wiz-step-dot::before { left: 0; }
.wiz-step-dot::after  { right: 0; }
.wiz-step-dot:first-child::before { display: none; }
.wiz-step-dot:last-child::after   { display: none; }
.wiz-step-dot.done::after { background: var(--primary); }

/* Modality cards */
.mod-card-wrap {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.mod-card input[type=radio] { display: none; }
.mod-card label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 12px;
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    text-align: center;
    font-weight: 600;
    color: var(--text);
    user-select: none;
}
.mod-card label:hover { border-color: var(--primary); }
.mod-card input:checked + label {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}
.mod-card .mod-icon { font-size: 2rem; line-height: 1; }

/* Type cards */
.type-card-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.type-card input[type=radio] { display: none; }
.type-card label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    font-weight: 600;
    color: var(--text);
    user-select: none;
}
.type-card label:hover { border-color: var(--primary); }
.type-card input:checked + label {
    border-color: var(--primary);
    background: var(--primary-light);
}

/* ─── Specialty checkboxes ─── */
.specialty-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}
.spec-card {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: .85rem;
    font-weight: 500;
    color: var(--text);
    transition: border-color .15s, background .15s;
    user-select: none;
}
.spec-card:hover { border-color: var(--primary); }
.spec-card input[type=checkbox] { accent-color: var(--primary); width: 15px; height: 15px; flex-shrink: 0; }
.spec-card:has(input:checked) { border-color: var(--primary); background: var(--primary-light); }

/* ─── Service area tag ─── */
.area-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 500;
}
.area-tag .remove-area { cursor: pointer; color: var(--text-muted); }
.area-tag .remove-area:hover { color: #ef4444; }

/* ─── Utility ─── */
.text-primary-custom { color: var(--primary); }
.bg-surface { background: var(--surface); }

/* ─── Mobile ─── */
@media (max-width: 576px) {
    body { font-size: 14px; }

    .container { padding-left: 14px; padding-right: 14px; }

    /* Exercise cards */
    .ex-card-header { padding: 12px 14px; }
    .sets-header { padding: 8px 14px; }
    .set-row { padding: 13px 14px; }
    .aerobic-stats { padding: 14px; gap: 10px; }
    .aerobic-stat-box { padding: 14px 10px; }
    .aerobic-stat-box .stat-val { font-size: 1.3rem; }

    /* Full-width buttons on mobile */
    .btn-mobile-full { width: 100% !important; }

    /* Calendar horizontal scroll on mobile */
    .calendar-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 8px; }
    .calendar-wrapper .calendar-grid { min-width: 560px; }

    /* Modal full-screen on mobile */
    .modal-dialog { margin: 0; max-width: 100%; }
    .modal-dialog .modal-content { border-radius: 0; min-height: 100vh; }

    /* Stat cards */
    .stat-card { padding: 14px; }
    .stat-card .stat-value { font-size: 1.6rem; }

    /* Sidebar becomes horizontal on mobile */
    .sidebar { min-height: auto; border-right: none; border-bottom: 1px solid var(--border); padding: 8px 0; }

    /* Touch targets */
    .set-row.with-check { padding: 15px 14px; }
    .set-bubble, .set-check-circle { width: 34px; height: 34px; }
}

@media (max-width: 768px) {
    .modal-dialog.modal-xl { max-width: calc(100vw - 24px); margin: 12px auto; }
}

/* ─── Student Mobile Bottom Nav ─────────────────────────────────── */
.student-body { padding-bottom: 64px; }

.student-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: var(--surface);
    border-top: 1.5px solid var(--border);
    display: flex;
    z-index: 999;
    box-shadow: 0 -4px 20px rgba(0,0,0,.07);
}
.sbn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: .6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    transition: color .15s;
    position: relative;
}
.sbn-item i { font-size: 1.15rem; line-height: 1; }
.sbn-item.active { color: var(--primary); }
.sbn-item.active::after {
    content: '';
    position: absolute;
    top: 0; left: 25%; right: 25%;
    height: 2.5px;
    background: var(--primary);
    border-radius: 0 0 4px 4px;
}
.sbn-item:hover { color: var(--primary-dark); }
.sbn-item.sbn-logout { color: #94a3b8; }

@media (min-width: 992px) {
    .student-bottom-nav { display: none !important; }
    .student-body { padding-bottom: 0; }
}

/* ─── Sticky Workout Footer ─────────────────────────────────────── */
.workout-sticky-footer {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    border-top: 1.5px solid var(--border);
    padding: 12px 16px;
    z-index: 100;
    box-shadow: 0 -6px 20px rgba(0,0,0,.08);
}

/* ─── Progress Tabs ──────────────────────────────────────────────── */
.student-tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
}
.student-tabs::-webkit-scrollbar { display: none; }
.student-tab {
    padding: 10px 20px;
    font-size: .88rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: none;
    white-space: nowrap;
    position: relative;
    bottom: -2px;
    border-bottom: 3px solid transparent;
    transition: color .15s;
    flex-shrink: 0;
}
.student-tab:hover { color: var(--text); }
.student-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.student-tab-pane { display: none; }
.student-tab-pane.active { display: block; }
