/* ═══════════════════════════════════════════════════════════════════════
   GYM APP — Global Stylesheet · Design System "Gymflow" (prototipos)
   Bootstrap 5.3 (color mode dark) + tokens del prototipo encima.
   Tema oscuro plano-funcional premium (ref. Linear + Apple Fitness).
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Tokens del prototipo ────────────────────────────────────────────── */
:root {
    --bg-0: #0B0F14;   /* canvas */
    --bg-1: #131820;   /* panel / sidebar / cards */
    --bg-2: #1C232E;   /* hover / superficie destacada */
    --bg-3: #232c38;   /* superficie elevada */
    --border: #232B37;     /* border-1 (sutil) */
    --border-2: #2D3645;   /* border-2 (controles) */

    --text-1: #E8ECF1;
    --text-2: #98A2B3;
    --text-3: #7C8D9F;

    --primary: #34D27A;
    --primary-dark: #28b86a;
    --primary-rgb: 52, 210, 122;
    --accent: #4D8BFF;
    --warning: #F5B544;
    --danger: #F25E5E;
    --info: #4FD0E0;
    --purple: #B888FF;

    --sidebar-width: 248px;
    --sidebar-collapsed-width: 72px;
    --topbar-height: 60px;

    --kpi-blue: var(--accent);
    --kpi-green: var(--primary);
    --kpi-orange: var(--warning);
    --kpi-purple: var(--purple);
    --kpi-red: var(--danger);

    --radius-card: 14px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.35);
    --shadow-md: 0 6px 24px rgba(0,0,0,.40);
    --transition: .18s ease;
}

/* ── Bootstrap dark: remapear a la paleta del prototipo ──────────────── */
[data-bs-theme="dark"] {
    --bs-body-bg: var(--bg-0);
    --bs-body-color: var(--text-1);
    --bs-body-color-rgb: 232, 236, 241;
    --bs-emphasis-color: #ffffff;
    --bs-secondary-color: var(--text-2);
    --bs-secondary-bg: var(--bg-1);
    --bs-tertiary-bg: var(--bg-2);
    --bs-tertiary-color: var(--text-3);
    --bs-border-color: var(--border);
    --bs-border-color-translucent: rgba(255,255,255,.08);

    --bs-primary: var(--primary);
    --bs-primary-rgb: var(--primary-rgb);
    --bs-link-color: var(--primary);
    --bs-link-color-rgb: var(--primary-rgb);
    --bs-link-hover-color: var(--primary-dark);

    --bs-card-bg: var(--bg-1);
    --bs-card-cap-bg: var(--bg-1);
    --bs-card-border-color: var(--bg-2);
    --bs-border-radius: .5rem;
    --bs-border-radius-sm: .375rem;
    --bs-border-radius-lg: .75rem;
    --bs-modal-bg: var(--bg-1);
    --bs-dropdown-bg: var(--bg-1);
    --bs-dropdown-border-color: var(--border);
    --bs-dropdown-link-hover-bg: var(--bg-2);
    --bs-offcanvas-bg: var(--bg-1);
    --bs-list-group-bg: var(--bg-1);
    --bs-list-group-border-color: var(--border);
    --bs-list-group-action-hover-bg: var(--bg-2);
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-1);
    --bs-tooltip-bg: var(--bg-2);
}

/* ── Base ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 15px;
    background: var(--bg-0);
    color: var(--text-1);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.mono, code, kbd, .font-mono, .text-mono {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}

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

/* ── Utilidades fijas de Bootstrap que NO son theme-aware ────────────── */
/* Las vistas usan bg-white / bg-light / text-dark con tema claro en mente. */
.bg-white        { background-color: var(--bg-1) !important; }
.bg-light        { background-color: var(--bg-2) !important; }
.bg-body         { background-color: var(--bg-0) !important; }
.text-dark       { color: var(--text-1) !important; }
.text-muted      { color: #B0BBC8 !important; }
.border          { border-color: var(--border) !important; }
.table-light,
.table > thead.table-light th,
.table-light > th, .table-light > td { background-color: var(--bg-2) !important; color: var(--text-2) !important; }

/* Subtles re-afinados para fondo oscuro (translúcidos, funcionan bien) */
.bg-success-subtle  { background-color: rgba(52,210,122,.14) !important; }
.bg-danger-subtle   { background-color: rgba(242,94,94,.16) !important; }
.bg-warning-subtle  { background-color: rgba(245,181,68,.16) !important; }
.bg-info-subtle     { background-color: rgba(79,208,224,.16) !important; }
.bg-primary-subtle  { background-color: rgba(52,210,122,.14) !important; }
.bg-secondary-subtle{ background-color: rgba(152,162,179,.14) !important; }
.text-primary-emphasis, .text-primary { color: var(--primary) !important; }
.text-success { color: #5fe3a0 !important; }
.text-info    { color: var(--info) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger  { color: #ff8585 !important; }
/* Bootstrap deja .text-secondary y .btn-outline-secondary en #6c757d fijo
   (~3.8:1 sobre bg-1, falla WCAG AA); se remapean a los tokens del tema. */
.text-secondary { color: var(--text-2) !important; }
.btn-outline-secondary {
    --bs-btn-color: var(--text-2);
    --bs-btn-border-color: var(--border-2);
    --bs-btn-hover-bg: var(--bg-2);
    --bs-btn-hover-border-color: var(--border-2);
    --bs-btn-hover-color: var(--text-1);
    --bs-btn-active-bg: var(--bg-2);
    --bs-btn-active-border-color: var(--border-2);
    --bs-btn-active-color: var(--text-1);
}

/* ── Botones (primario verde) ────────────────────────────────────────── */
.btn { border-radius: 8px; font-weight: 500; }
.btn-sm { border-radius: 7px; }
.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: #2BB668;
    --bs-btn-hover-border-color: #2BB668;
    --bs-btn-active-bg: #2BB668;
    --bs-btn-color: var(--bg-0);
    --bs-btn-hover-color: var(--bg-0);
    --bs-btn-active-color: var(--bg-0);
    font-weight: 600;
}
.btn-outline-primary {
    --bs-btn-color: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary);
    --bs-btn-hover-border-color: var(--primary);
    --bs-btn-hover-color: #08130c;
}
.btn-light {
    --bs-btn-bg: var(--bg-2);
    --bs-btn-border-color: var(--border);
    --bs-btn-color: var(--text-1);
    --bs-btn-hover-bg: var(--bg-3);
    --bs-btn-hover-border-color: var(--border);
    --bs-btn-hover-color: var(--text-1);
}

/* ── Cards ───────────────────────────────────────────────────────────── */
.card {
    border-radius: var(--radius-card) !important;
    background-color: var(--bg-1);
    border: 1px solid var(--bg-2);
}
.card-header { background-color: var(--bg-1); border-bottom-color: var(--bg-2); border-radius: var(--radius-card) var(--radius-card) 0 0 !important; }
.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.shadow, .shadow-md { box-shadow: var(--shadow-md) !important; }

/* Inputs (sobre bg-2 como en el prototipo) */
.form-control, .form-select {
    background-color: var(--bg-2);
    border-color: var(--border-2);
    color: var(--text-1);
}
.form-control:focus, .form-select:focus {
    background-color: var(--bg-2);
    border-color: var(--primary);
    box-shadow: 0 0 0 .2rem rgba(var(--primary-rgb), .15);
    color: var(--text-1);
}
.form-control::placeholder { color: var(--text-3); }
:focus-visible {
    outline: 3px solid rgba(var(--primary-rgb), .35);
    outline-offset: 2px;
}
button:focus-visible, .btn:focus-visible, a:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible,
.form-control:focus-visible, .form-select:focus-visible {
    outline: 3px solid rgba(var(--primary-rgb), .45);
    outline-offset: 2px;
}
.form-check-input { background-color: var(--bg-2); border-color: var(--border-2); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.input-group-text { background-color: var(--bg-3); border-color: var(--border-2); color: var(--text-2); }

/* Tablas */
.table > :not(caption) > * > th,
.table > :not(caption) > * > td { vertical-align: middle; border-color: var(--border); }
.table thead th {
    font-size: .74rem; font-weight: 600; letter-spacing: .4px;
    text-transform: uppercase; color: var(--text-2);
}
.table-hover > tbody > tr:hover > * { background-color: var(--bg-2); }

/* Tabs */
.nav-tabs { border-bottom-color: var(--border); }
.nav-tabs .nav-link { color: var(--text-2); border: none; }
.nav-tabs .nav-link:hover { color: var(--text-1); border:none; }
.nav-tabs .nav-link.active {
    color: var(--primary); background: transparent;
    border-bottom: 2px solid var(--primary);
}

/* ── Layout shell ────────────────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg-1);
    border-right: 1px solid var(--border);
    color: var(--text-2);
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 1030;
    transition: width var(--transition), transform var(--transition);
    overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed-width); }

/* Sidebar plegado: ocultar texto (no está en span) y centrar iconos */
.sidebar.collapsed .sidebar-nav-link,
.sidebar.collapsed .sidebar-brand { justify-content: center; gap: 0; font-size: 0; padding-left: 0; padding-right: 0; }
.sidebar.collapsed .sidebar-nav-link i { font-size: 1.1rem; width: auto; }
.sidebar.collapsed .sidebar-brand i { font-size: 1.2rem; }
.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .sidebar-user-info,
.sidebar.collapsed .sidebar-nav-section,
.sidebar.collapsed .sidebar-section,
.sidebar.collapsed .sidebar-divider { display: none; }
.sidebar.collapsed .sidebar-user { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar.collapsed .sidebar-nav-link.active { box-shadow: none; }

.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 20px; text-decoration: none; color: var(--text-1);
    font-weight: 700; font-size: 1.1rem; letter-spacing: .2px;
    border-bottom: 1px solid var(--border);
    min-height: var(--topbar-height); white-space: nowrap; overflow: hidden;
}
.sidebar-brand i { color: var(--primary); }

.sidebar-brand-icon {
    width: 34px; height: 34px; border-radius: 9px;
    background: var(--primary); color: #08130c;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; flex-shrink: 0;
}
.sidebar-brand-text { transition: opacity var(--transition); }
.sidebar.collapsed .sidebar-brand-text { opacity: 0; pointer-events: none; }

.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 20px; border-bottom: 1px solid var(--border);
    overflow: hidden; white-space: nowrap;
}
.sidebar-user-avatar, .sidebar-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(var(--primary-rgb), .18);
    border: 1px solid rgba(var(--primary-rgb), .4);
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; color: var(--primary); flex-shrink: 0; overflow: hidden;
}
.sidebar-user-avatar img, .sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user-info { overflow: hidden; transition: opacity var(--transition); }
.sidebar.collapsed .sidebar-user-info { opacity: 0; pointer-events: none; }
.sidebar-user-name { font-size: .85rem; font-weight: 600; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: .7rem; color: var(--text-3); }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 0; list-style: none; margin: 0; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 2px; }

.sidebar-nav-section, .sidebar-section {
    padding: 14px 20px 6px; font-size: .62rem; font-weight: 700;
    letter-spacing: 1px; text-transform: uppercase; color: var(--text-3);
    white-space: nowrap; overflow: hidden;
}
.sidebar.collapsed .sidebar-nav-section, .sidebar.collapsed .sidebar-section { opacity: 0; }

.sidebar-nav-link, .sidebar-link {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 20px; color: var(--text-2); text-decoration: none;
    font-size: .86rem; font-weight: 500; transition: background var(--transition), color var(--transition);
    white-space: nowrap; overflow: hidden; position: relative;
}
.sidebar-nav-link i, .sidebar-link i { font-size: 1.05rem; width: 22px; text-align: center; flex-shrink: 0; }
.sidebar-nav-link:hover, .sidebar-link:hover { background: var(--bg-2); color: var(--text-1); }
.sidebar-nav-link.active, .sidebar-link.active {
    background: rgba(var(--primary-rgb), .12); color: var(--primary);
    box-shadow: inset 3px 0 0 var(--primary);
}
.sidebar-nav-link.active i, .sidebar-link.active i { color: var(--primary); }
.sidebar-divider { height: 1px; background: var(--border); margin: 8px 16px; list-style: none; }
.sidebar-nav-logout { color: var(--danger); }

/* ── Main content ────────────────────────────────────────────────────── */
.main-content, .main-wrapper {
    flex: 1; margin-left: var(--sidebar-width);
    display: flex; flex-direction: column; min-height: 100vh;
    transition: margin-left var(--transition);
}
.main-content.collapsed, .main-wrapper.collapsed { margin-left: var(--sidebar-collapsed-width); }

/* ── Topbar ──────────────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-height); background: var(--bg-1);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 20px; gap: 12px;
    position: sticky; top: 0; z-index: 1020;
}
.topbar-toggle {
    background: none; border: none; padding: 6px 8px; border-radius: 8px;
    cursor: pointer; color: var(--text-2); font-size: 1.25rem; line-height: 1;
    transition: background var(--transition), color var(--transition);
}
.topbar-toggle:hover { background: var(--bg-2); color: var(--text-1); }
.topbar-time, .topbar-clock { font-size: .8rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.topbar-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: rgba(var(--primary-rgb), .14);
    display: flex; align-items: center; justify-content: center;
    font-size: .9rem; color: var(--primary); overflow: hidden;
}
.topbar-avatar img { width: 100%; height: 100%; object-fit: cover; }
.breadcrumb { --bs-breadcrumb-divider-color: var(--text-3); margin: 0; }
.breadcrumb-item.active { color: var(--text-1); }
.breadcrumb a { color: var(--text-2); }

/* ── Page content ────────────────────────────────────────────────────── */
.page-content { flex: 1; padding: 26px 26px 88px; }
.page-title { font-weight: 700; color: var(--text-1); letter-spacing: -.01em; }
.page-subtitle { color: var(--text-2); }
.page-footer { padding: 14px 26px; color: var(--text-3); }

/* ── KPI Cards ───────────────────────────────────────────────────────── */
.kpi-card {
    background: var(--bg-1); border: 1px solid var(--border);
    border-radius: var(--radius-card); padding: 18px;
    display: flex; align-items: center; gap: 16px;
    position: relative; overflow: hidden;
    transition: transform var(--transition), border-color var(--transition);
}
.kpi-card:hover { transform: translateY(-2px); border-color: rgba(var(--primary-rgb), .4); }
.kpi-card::before { content: ''; position: absolute; top: 0; left: 0; width: 3px; height: 100%; }
.kpi-blue::before { background: var(--accent); }
.kpi-green::before { background: var(--primary); }
.kpi-orange::before { background: var(--warning); }
.kpi-purple::before { background: var(--purple); }
.kpi-red::before { background: var(--danger); }
.kpi-icon { width: 46px; height: 46px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 1.35rem; flex-shrink: 0; }
.kpi-blue .kpi-icon { background: rgba(77,139,255,.14); color: var(--accent); }
.kpi-green .kpi-icon { background: rgba(52,210,122,.14); color: var(--primary); }
.kpi-orange .kpi-icon { background: rgba(245,181,68,.14); color: var(--warning); }
.kpi-purple .kpi-icon { background: rgba(184,136,255,.14); color: var(--purple); }
.kpi-red .kpi-icon { background: rgba(242,94,94,.14); color: var(--danger); }
.kpi-value { font-size: 1.7rem; font-weight: 700; line-height: 1; color: var(--text-1); font-variant-numeric: tabular-nums; }
.kpi-label { font-size: .76rem; color: var(--text-2); margin-top: 3px; }
.kpi-link { position: absolute; inset: 0; z-index: 1; }

/* ── Componentes de cliente (dashboard) ──────────────────────────────── */
.ejercicio-list { display: flex; flex-direction: column; gap: 10px; }
.ejercicio-item { display: flex; align-items: center; gap: 12px; background: var(--bg-2); border-radius: 10px; padding: 10px 14px; transition: background var(--transition); }
.ejercicio-item.completado { background: rgba(52,210,122,.08); opacity: .7; }
.ejercicio-item.completado .fw-semibold { text-decoration: line-through; color: var(--text-2); }
.ejercicio-num { width: 24px; height: 24px; border-radius: 50%; background: rgba(var(--primary-rgb), .14); color: var(--primary); font-size: .75rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ejercicio-gif-wrap { position: relative; width: 56px; height: 56px; border-radius: 8px; overflow: hidden; flex-shrink: 0; background: var(--bg-3); }
.ejercicio-gif { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.ejercicio-info { min-width: 0; }

.medida-box { background: var(--bg-2); border-radius: 8px; padding: 10px 6px; }
.medida-val { font-size: 1.1rem; font-weight: 700; color: var(--text-1); }
.medida-lbl { font-size: .68rem; color: var(--text-2); }

/* ── Exercise cards ──────────────────────────────────────────────────── */
.ej-card { border-radius: var(--radius-card) !important; overflow: hidden; transition: transform var(--transition), border-color var(--transition); border: 1px solid var(--border); }
.ej-card:hover { transform: translateY(-3px); border-color: rgba(var(--primary-rgb), .4); }
.ej-card-media { position: relative; width: 100%; padding-top: 75%; background: var(--bg-2); overflow: hidden; }
.ej-card-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ej-card-placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg-2); color: var(--text-3); }
.ej-card-badge-gif { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: .6rem; font-weight: 700; padding: 2px 6px; border-radius: 4px; letter-spacing: .5px; }

/* ── Badges / pills ──────────────────────────────────────────────────── */
.badge { font-weight: 600; }

/* ── Alerts ──────────────────────────────────────────────────────────── */
.alert { border-radius: 10px; border: 1px solid transparent; }
.alert-success { background: rgba(52,210,122,.12); color: #7ce6ac; border-color: rgba(52,210,122,.25); }
.alert-danger  { background: rgba(242,94,94,.12); color: #ff9b9b; border-color: rgba(242,94,94,.25); }
.alert-warning { background: rgba(245,181,68,.12); color: #f3c87a; border-color: rgba(245,181,68,.25); }
.alert-info    { background: rgba(79,208,224,.12); color: #8fe3ee; border-color: rgba(79,208,224,.25); }
.alert-primary { background: rgba(52,210,122,.12); color: #7ce6ac; border-color: rgba(52,210,122,.25); }
.alert-secondary { background: var(--bg-2); color: var(--text-2); border-color: var(--border); }

/* ── Auth (layout de dos paneles) ────────────────────────────────────── */
.auth-body { background: var(--bg-0); }
.auth-shell { display: flex; min-height: 100vh; }
.auth-hero {
    flex: 1 1 0; padding: 40px 48px;
    display: flex; flex-direction: column; justify-content: space-between;
    background:
        radial-gradient(700px 360px at 18% 12%, rgba(52,210,122,.18), transparent 60%),
        radial-gradient(620px 420px at 92% 100%, rgba(77,139,255,.12), transparent 55%),
        var(--bg-1);
    border-right: 1px solid var(--border);
    overflow: hidden;
}
.auth-hero-top { display: flex; align-items: center; gap: 10px; }
.auth-hero-logo { width: 40px; height: 40px; border-radius: 11px; background: var(--primary); color: var(--bg-0); display: grid; place-items: center; font-size: 1.3rem; }
.auth-hero-name { font-weight: 700; font-size: 1.1rem; }
.auth-hero-body h1 { font-size: clamp(2rem, 3.4vw, 3rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.08; margin: 0 0 14px; }
.auth-hero-body p { color: var(--text-2); font-size: 1.02rem; max-width: 420px; line-height: 1.6; margin: 0; }
.auth-hero-feats { list-style: none; padding: 0; margin: 26px 0 0; display: flex; flex-direction: column; gap: 12px; }
.auth-hero-feats li { color: var(--text-1); font-size: .95rem; display: flex; align-items: center; gap: 10px; }
.auth-hero-feats i { color: var(--primary); font-size: 1.15rem; }
.auth-hero-foot { color: var(--text-3); font-size: .8rem; }

.auth-panel { width: 480px; max-width: 100%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; padding: 32px 28px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-brand-mini { text-align: center; margin-bottom: 22px; }
.auth-logo, .auth-logo-icon { width: 54px; height: 54px; border-radius: 14px; background: var(--primary); display: grid; place-items: center; font-size: 1.55rem; color: var(--bg-0); margin: 0 auto 10px; }
.auth-app-name { font-weight: 700; font-size: 1.25rem; color: var(--text-1); }
.auth-tagline { color: var(--text-3); font-size: .82rem; margin: 2px 0 0; }
.auth-form-title h4 { color: var(--text-1); font-weight: 700; }

/* Inputs de auth: superficie única (sin parche de dos tonos) */
.auth-card .input-group-text { background: var(--bg-2); border-color: var(--border-2); color: var(--text-2); }
.auth-card .form-control, .auth-card .form-select { background: var(--bg-2); border-color: var(--border-2); }
.auth-card .form-label { font-weight: 600; color: var(--text-2); font-size: .85rem; }

.pass-strength-bar { height: 4px; background: var(--bg-2); border-radius: 2px; overflow: hidden; }
.pass-strength-fill { height: 100%; border-radius: 2px; transition: width .3s ease, background .3s ease; width: 0; }

@media (max-width: 860px) {
    .auth-hero { display: none; }
    .auth-panel { flex: 1; width: 100%; }
}
@media (min-width: 861px) {
    .auth-brand-mini { display: none; }
}

/* ── DataTables ──────────────────────────────────────────────────────── */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select { background: var(--bg-0); border: 1px solid var(--border); color: var(--text-1); border-radius: 8px; padding: 4px 10px; }
table.dataTable thead th { border-bottom: 1px solid var(--border) !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current { background: var(--primary) !important; color: #08130c !important; border-color: var(--primary) !important; border-radius: 6px; }
.dataTables_wrapper .dataTables_paginate .paginate_button { color: var(--text-2) !important; }

/* Spinner overlay */
.spinner-overlay { position: fixed; inset: 0; background: rgba(11,15,20,.7); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.min-width-0, .min-w-0 { min-width: 0; }

/* ─────────────────────────────────────────────────────────────────────
   RESPONSIVE
   ───────────────────────────────────────────────────────────────────── */

/* Tab bar inferior (móvil) — se inyecta en el layout para clientes */
.mobile-tabbar { display: none; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.mobile-open { transform: translateX(0); width: var(--sidebar-width); }
    .sidebar-overlay, .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 1029; }
    .sidebar-overlay.show, .sidebar-backdrop.show { display: block; }
    .main-content, .main-content.collapsed, .main-wrapper, .main-wrapper.collapsed { margin-left: 0; }
    .page-content { padding: 18px 14px 92px; }

    /* Tab bar inferior visible en móvil */
    .mobile-tabbar {
        display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1035;
        background: var(--bg-1); border-top: 1px solid var(--border);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    }
    .mobile-tabbar a {
        flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
        padding: 4px 0; color: var(--text-2); font-size: .62rem; text-decoration: none; font-weight: 500;
    }
    .mobile-tabbar a i { font-size: 1.25rem; }
    .mobile-tabbar a.active { color: var(--primary); }
}

/* ── Skeleton loading (placeholders animados para paneles AJAX) ───────── */
.skeleton {
    background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 37%, var(--bg-2) 63%);
    background-size: 400% 100%;
    animation: skeleton-shimmer 1.3s ease-in-out infinite;
    border-radius: 6px;
}
.skeleton-line   { height: 10px; margin: 6px 0; }
.skeleton-circle { border-radius: 50%; }
.skeleton-panel { display: grid; gap: 12px; }
.skeleton-panel .skeleton-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.skeleton-panel .skeleton-item:last-child { border-bottom-color: transparent; }
.skeleton-panel .skeleton-title { width: 50%; height: 14px; margin-bottom: 10px; }
.skeleton-panel .skeleton-row { width: 100%; height: 10px; }
.cal-grid.loading { position: relative; }
.cal-grid.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(255,255,255,.04) 15%, rgba(255,255,255,.08) 50%, rgba(255,255,255,.04) 85%);
    pointer-events: none;
    animation: skeleton-shimmer 1.3s ease-in-out infinite;
}
.cal-grid.loading .cal-cell { background: rgba(255,255,255,.02); }
.cal-grid.loading .cal-event { visibility: hidden; }
@keyframes skeleton-shimmer {
    0%   { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

@media (max-width: 575.98px) {
    .auth-card { padding: 26px 18px; }
    .kpi-value { font-size: 1.4rem; }
    .page-content { padding: 14px 12px 92px; }
    /* Tablas anchas: permitir scroll horizontal suave */
    .table-responsive { -webkit-overflow-scrolling: touch; }
    h2.page-title, .page-title { font-size: 1.35rem; }
}

/* ═══ Utilidades CSP (docs/adr/0004) ══════════════════════════════════════
 * Reemplazan los style="..." de las vistas: la CSP sin 'unsafe-inline' los bloquea.
 * Lo que depende de un dato (barras de progreso, colores) va por data-ancho / data-alto / data-fondo (app.js).
 * fz-NNN = NNN/100 rem; sq-N = cuadrado de N px; w-N = N % (como w-25 de Bootstrap); wpx/maxw/minw/maxh/h-Npx en px. */
.fz-60 { font-size: .6rem; }   .fz-62 { font-size: .62rem; }  .fz-65 { font-size: .65rem; }
.fz-68 { font-size: .68rem; }  .fz-70 { font-size: .7rem; }   .fz-72 { font-size: .72rem; }
.fz-75 { font-size: .75rem; }  .fz-80 { font-size: .8rem; }   .fz-85 { font-size: .85rem; }
.fz-100 { font-size: 1rem; }   .fz-150 { font-size: 1.5rem; } .fz-160 { font-size: 1.6rem; }
.fz-200 { font-size: 2rem; }   .fz-260 { font-size: 2.6rem; } .fz-300 { font-size: 3rem; }
.ls-wide { letter-spacing: .08em; }

.sq-8 { width: 8px; height: 8px; }      .sq-9 { width: 9px; height: 9px; }
.sq-32 { width: 32px; height: 32px; }   .sq-34 { width: 34px; height: 34px; }   .sq-36 { width: 36px; height: 36px; }
.sq-38 { width: 38px; height: 38px; }   .sq-40 { width: 40px; height: 40px; }   .sq-42 { width: 42px; height: 42px; }
.sq-44 { width: 44px; height: 44px; }   .sq-46 { width: 46px; height: 46px; }   .sq-48 { width: 48px; height: 48px; }
.sq-54 { width: 54px; height: 54px; }   .sq-56 { width: 56px; height: 56px; }   .sq-64 { width: 64px; height: 64px; }
.sq-72 { width: 72px; height: 72px; }   .sq-88 { width: 88px; height: 88px; }   .sq-120 { width: 120px; height: 120px; }
.skeleton-avatar-32 { width: 32px; height: 32px; flex-shrink: 0; }
.skeleton-avatar-36 { width: 36px; height: 36px; flex-shrink: 0; }

.w-10 { width: 10%; } .w-12 { width: 12%; } .w-14 { width: 14%; } .w-15 { width: 15%; } .w-18 { width: 18%; }
.w-20 { width: 20%; } .w-30 { width: 30%; } .w-32 { width: 32%; } .w-38 { width: 38%; } .w-40 { width: 40%; }
.w-42 { width: 42%; } .w-45 { width: 45%; } .w-55 { width: 55%; } .w-60 { width: 60%; } .w-65 { width: 65%; }
.w-70 { width: 70%; } .w-80 { width: 80%; } .w-90 { width: 90%; }
.wpx-30 { width: 30px; } .wpx-40 { width: 40px; } .wpx-70 { width: 70px; } .wpx-80 { width: 80px; }
.wpx-90 { width: 90px; } .wpx-110 { width: 110px; } .wpx-150 { width: 150px; } .wpx-180 { width: 180px; }
.w-3rem { width: 3rem; } .w-1-2rem { width: 1.2rem; }
.maxw-90 { max-width: 90px; } .maxw-110 { max-width: 110px; } .maxw-140 { max-width: 140px; }
.maxw-380 { max-width: 380px; } .maxw-420 { max-width: 420px; } .maxw-480 { max-width: 480px; } .maxw-78p { max-width: 78%; }
.minw-160 { min-width: 160px; } .minw-520 { min-width: 520px; } .minw-560 { min-width: 560px; }
.maxh-200 { max-height: 200px; } .maxh-320 { max-height: 320px; } .maxh-340 { max-height: 340px; }
.maxh-360 { max-height: 360px; } .maxh-400 { max-height: 400px; }
.h-5px { height: 5px; } .h-6px { height: 6px; } .h-7px { height: 7px; } .h-8px { height: 8px; } .h-10px { height: 10px; }
.h-11px { height: 11px; } .h-12px { height: 12px; } .h-14px { height: 14px; }
.h-120px { height: 120px; } .h-160px { height: 160px; } .h-260px { height: 260px; }
.mt-2px { margin-top: 2px; } .mt-8px { margin-top: 8px; } .mt-10px { margin-top: 10px; }
.top-80 { top: 80px; }

.grid-center { display: grid; place-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.cursor-pointer { cursor: pointer; }
.cursor-grab { cursor: grab; }
.object-cover { object-fit: cover; }
.object-contain { object-fit: contain; }
.rounded-6 { border-radius: 6px; }
.rounded-9 { border-radius: 9px; }
.rounded-16 { border-radius: 16px; }
.pre-wrap { white-space: pre-wrap; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bg-2 { background: var(--bg-2); }
.bg-0 { background: var(--bg-0); }
.text-1 { color: var(--text-1); }
.text-3 { color: var(--text-3); }
.border-theme { border-color: var(--border) !important; }
.outline-primary { outline: 1px solid var(--primary); }
.outline-primary-2 { outline: 1.5px solid var(--primary); }
.opacity-35 { opacity: .35; }
.form-switch .form-check-input.switch-lg { width: 2.6em; height: 1.4em; }

/* Retención por cohorte (reportes/avanzado): heat-N = N×10 % de la cohorte que entrenó ese mes. */
.tabla-cohortes td[class*="heat-"] { border-radius: 4px; color: var(--text-1); }
.tabla-cohortes td.heat-vacio { background: var(--bg-2); color: var(--text-3); }
.tabla-cohortes td.heat-0 { background: rgba(52, 210, 122, .08); }
.tabla-cohortes td.heat-1 { background: rgba(52, 210, 122, .1); }
.tabla-cohortes td.heat-2 { background: rgba(52, 210, 122, .2); }
.tabla-cohortes td.heat-3 { background: rgba(52, 210, 122, .3); }
.tabla-cohortes td.heat-4 { background: rgba(52, 210, 122, .4); }
.tabla-cohortes td.heat-5 { background: rgba(52, 210, 122, .5); }
.tabla-cohortes td.heat-6 { background: rgba(52, 210, 122, .6); color: #08130c; }
.tabla-cohortes td.heat-7 { background: rgba(52, 210, 122, .7); color: #08130c; }
.tabla-cohortes td.heat-8 { background: rgba(52, 210, 122, .8); color: #08130c; }
.tabla-cohortes td.heat-9 { background: rgba(52, 210, 122, .9); color: #08130c; }
.tabla-cohortes td.heat-10 { background: rgb(52, 210, 122); color: #08130c; }
.mx-auto-block { display: block; margin-inline: auto; }
.punto { width: 8px; height: 8px; padding: 0; border-radius: 50%; }

/* Layout principal: campana de notificaciones */
.notif-badge { font-size: .6rem; }
.notif-menu { width: 340px; max-width: 92vw; }
.notif-lista { max-height: 360px; overflow-y: auto; }
.notif-icono { width: 36px; height: 36px; display: grid; place-items: center; }
.notif-fecha { font-size: .68rem; }

/* Estado vacío (partials/empty.php) */
.empty-icono { font-size: 2.6rem; opacity: .35; }
.empty-msg { max-width: 380px; margin-inline: auto; }

/* Layouts públicos (public.php, publico.php) */
.pub-body { background: var(--bg-0); min-height: 100vh; }
.pub-nav { border-bottom: 1px solid rgba(255,255,255,.06); }
.pub-wrap { max-width: 1000px; margin: 0 auto; padding: 0 16px; }
.pub-footer { border-top: 1px solid rgba(255,255,255,.06); }
.pub-logo { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: var(--primary); color: var(--bg-0); }
.lang-switch .btn { min-width: 2.5rem; }

/* Rutinas: insignias de IA */
.badge-ia { background: rgba(111,66,193,.1); color: #6f42c1; }
.badge-ia-solid { background: #6f42c1; color: #fff; }

/* Biblioteca: miniatura de la tarjeta */
.biblio-media { height: 120px; background: var(--bg-2); border-radius: .5rem .5rem 0 0; display: grid; place-items: center; overflow: hidden; }

/* Progreso: tracker en vivo (antes un <style> en la vista) */
.serie-done .form-control, .serie-done .form-select { background: rgba(52,210,122,.10); }
.serie-done { background: rgba(52,210,122,.07); }
.table-success-subtle { --bs-table-bg: rgba(52,210,122,.07); }
.rest-overlay { position: fixed; inset: 0; z-index: 1080; display: none; background: rgba(11,15,20,.92); align-items: center; justify-content: center; }
.rest-overlay.show { display: flex; }
.rest-box { color: #E8ECF1; width: min(92vw, 360px); }
.rest-count { font-size: 64px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.rpe-picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.rpe-btn { border: 1px solid #2a3540; background: #1C232E; color: #E8ECF1; border-radius: 8px; padding: 10px 0; font-weight: 600; cursor: pointer; }
.rpe-btn:hover { border-color: #34D27A; }
.rpe-btn.act { background: #34D27A; color: #0B0F14; border-color: #34D27A; }
.uv-esqueleto { width: 180px; height: 10px; display: inline-block; vertical-align: middle; }

/* Progreso: fotos */
.foto-progreso { aspect-ratio: 3 / 4; object-fit: cover; }
.foto-pie { background: rgba(0,0,0,.5); font-size: .65rem; border-radius: 0 0 .375rem .375rem; }

/* Avatares con iniciales (clientes, entrenadores, perfil) */
.ini-32 { width: 32px; height: 32px; font-size: .75rem; font-weight: 600; }
.ini-36 { width: 36px; height: 36px; font-size: .8rem; font-weight: 700; }
.ini-38 { width: 38px; height: 38px; font-size: .85rem; font-weight: 600; }
.ini-48 { width: 48px; height: 48px; font-size: 1rem; font-weight: 700; }
.ini-72 { width: 72px; height: 72px; font-size: 1.6rem; font-weight: 700; }
.ini-88 { width: 88px; height: 88px; font-size: 2rem; font-weight: 700; }

/* Agenda: calendario semanal (antes un <style> en la vista) */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 1rem; }
.cal-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: .5rem; background: var(--bg-1); }
.cal-grid { display: grid; grid-template-columns: 56px repeat(7, minmax(120px, 1fr)); min-width: 860px; }
.cal-head { position: sticky; top: 0; z-index: 2; background: var(--bg-2); border-bottom: 1px solid var(--border); padding: 8px 6px; text-align: center; font-size: .8rem; font-weight: 600; color: var(--text-1); }
.cal-head.today { background: rgba(52,210,122,.14); color: var(--primary); }
.cal-head .dnum { font-size: 1.1rem; font-weight: 700; }
.cal-corner { position: sticky; top: 0; z-index: 2; background: var(--bg-2); border-bottom: 1px solid var(--border); }
.cal-hour { font-size: .72rem; color: var(--text-3); text-align: right; padding: 4px 6px; border-top: 1px solid var(--border); }
.cal-cell { border-top: 1px solid var(--border); border-left: 1px solid rgba(255,255,255,.03); min-height: 52px; padding: 3px; cursor: pointer; }
.cal-cell:hover { background: var(--bg-2); }
.cal-cell.today-col { background: rgba(52,210,122,.05); }
.cal-event { border-radius: 6px; padding: 4px 6px; margin-bottom: 3px; font-size: .72rem; color: #fff; cursor: pointer; line-height: 1.2; }
.cal-event .ev-time { font-weight: 600; opacity: .9; display: block; }
.ev-confirmada { background: var(--primary); color: #08130c; }
.ev-sin_confirmar { background: var(--warning); color: #241a05; }
.ev-completada { background: var(--text-3); }
.ev-cancelada { background: var(--danger); text-decoration: line-through; opacity: .85; }

/* Mensajes: chat (antes un <style> en la vista) */
.chat-wrap { display: flex; height: calc(100vh - 220px); min-height: 420px; border: 1px solid var(--border); border-radius: .6rem; overflow: hidden; background: var(--bg-1); }
.chat-list { width: 300px; border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.chat-list-head { padding: 12px; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: center; }
.chat-threads { overflow-y: auto; flex: 1; }
.thread { display: flex; gap: 10px; padding: 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.thread:hover { background: var(--bg-2); }
.thread.act { background: rgba(52,210,122,.12); }
.thread-av { width: 42px; height: 42px; border-radius: 50%; background: var(--bg-3); display: grid; place-items: center; color: var(--text-2); flex-shrink: 0; font-weight: 600; }
.thread-main { min-width: 0; flex: 1; }
.thread-name { font-weight: 600; font-size: .88rem; color: var(--text-1); }
.thread-prev { color: var(--text-2); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-badge { background: var(--primary); color: #08130c; border-radius: 999px; font-size: .66rem; padding: 1px 7px; align-self: center; font-weight: 700; }
.chat-conv { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-conv-head { padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; background: var(--bg-0); display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 72%; padding: 8px 12px; border-radius: 14px; font-size: .86rem; line-height: 1.35; word-wrap: break-word; }
.bubble small { display: block; font-size: .62rem; opacity: .7; margin-top: 3px; }
.b-mio { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.b-otro { align-self: flex-start; background: var(--bg-2); border: 1px solid var(--border); color: var(--text-1); border-bottom-left-radius: 4px; }
.chat-composer { padding: 10px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.chat-empty { flex: 1; display: grid; place-items: center; color: var(--text-3); text-align: center; padding: 20px; }
.skeleton-centro { margin-left: auto; margin-right: auto; }
@media (max-width: 768px) { .chat-list { width: 128px; } .thread-av { display: none; } .chat-wrap { height: calc(100vh - 180px); } }

/* Asistente IA: variante del chat */
.chat-ia .chat-list { width: 280px; }
.chat-ia .thread-av { width: 38px; height: 38px; font-weight: normal; }
.chat-ia .thread-name { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-ia .thread-prev { font-size: .76rem; }
.chat-ia .bubble { max-width: 78%; padding: 9px 13px; line-height: 1.4; }
.bubble-esqueleto { background: var(--bg-2) !important; border: 1px solid var(--border); }
@media (max-width: 768px) { .chat-ia .chat-list { width: 120px; } }

/* Notificaciones */
.notif-punto { width: 9px; height: 9px; padding: 0; }

/* Suscripción */
.paywall-icono { width: 64px; height: 64px; place-items: center; border-radius: 16px; background: rgba(245,181,68,.15); color: var(--warning); }
