/* GymTracker · web de entrenadores. Mismos colores que el tema "Oscuro"/"Azul" de la app. */
:root {
    --bg: #f4f6fb;
    --card: #ffffff;
    --surface2: #eef1f7;
    --text: #1b2330;
    --text2: #667085;
    --accent: #2f6bff;
    --accent-text: #ffffff;
    --accent-soft: #e3ebff;
    --border: #dfe3ec;
    --success: #12a150;
    --success-soft: #dcf5e7;
    --danger: #e5484d;
    --danger-soft: #fde4e4;
    --gold: #c98a00;
    --gold-soft: #fff3d1;
    --sidebar: #141b2d;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    background: var(--bg);
    color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }

/* ---------- Utilidades ---------- */
.muted { color: var(--text2); }
.small { font-size: .85rem; }
.big { font-size: 1.1rem; }
.bold { font-weight: 600; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.accent { color: var(--accent); }
.danger-text { color: var(--danger) !important; }
.grow { flex: 1; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.row.gap { gap: .6rem; }
.row.tight { gap: .25rem; flex-wrap: nowrap; }
.row.space { justify-content: space-between; gap: .6rem; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; }
.grid-2.top { align-items: start; margin-bottom: 1rem; }
.row-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .8rem; }
ul.plain { list-style: none; padding: 0; margin: .4rem 0; }
ul.plain li { padding: .2rem 0; }

/* ---------- Estructura ---------- */
.center-screen { min-height: 100vh; display: grid; place-items: center; }
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
    background: var(--sidebar);
    color: #cfd6e4;
    display: flex;
    flex-direction: column;
    padding: 1.2rem .8rem;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { font-weight: 700; font-size: 1.15rem; color: #fff; padding: 0 .6rem 1.2rem; }
.brand span { display: block; font-size: .75rem; font-weight: 500; color: #8a96ad; text-transform: uppercase; letter-spacing: .08em; }
.sidebar nav { display: flex; flex-direction: column; gap: .2rem; }
.sidebar nav a { color: #cfd6e4; padding: .6rem .8rem; border-radius: 10px; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.sidebar nav a.active { background: var(--accent); color: #fff; }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: .6rem; }
.sidebar-footer .btn.ghost { color: #cfd6e4; border-color: rgba(255, 255, 255, .15); }
.me { display: flex; gap: .6rem; align-items: center; }
.me .muted { color: #8a96ad; }
.me-name { color: #fff; font-weight: 600; }
.content { padding: 1.6rem 2rem 3rem; min-width: 0; display: flex; flex-direction: column; gap: 1rem; max-width: 1280px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }

@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .content { padding: 1rem; }
}

/* ---------- Acceso ---------- */
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(135deg, #141b2d, #2f4a8f); }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border-radius: 18px; padding: 2rem; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); display: flex; flex-direction: column; gap: .9rem; }

/* ---------- Tarjetas ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "▸ "; color: var(--text2); }
details.card[open] > summary::before { content: "▾ "; }
details.card[open] > summary { margin-bottom: .8rem; }
.history details { padding: .4rem 0; border-top: 1px solid var(--border); }
.history summary { cursor: pointer; }
.routine.archived { opacity: .6; }
.option-block { border-top: 1px solid var(--border); padding: .8rem 0; display: flex; flex-direction: column; gap: .5rem; }
.exercise-block { display: flex; flex-direction: column; gap: .7rem; }
.order { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; }

/* ---------- Formularios ---------- */
label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--text2); font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--text); }
input, select, textarea {
    font: inherit;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .5rem .7rem;
    min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: .6rem; }
@media (max-width: 700px) { .filters { grid-template-columns: 1fr; } }

/* ---------- Botones ---------- */
.btn {
    font: inherit;
    font-weight: 600;
    border-radius: 10px;
    padding: .55rem 1rem;
    border: 1px solid transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    white-space: nowrap;
    text-decoration: none !important;
    background: var(--surface2);
    color: var(--text);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn.ghost:hover:not(:disabled) { background: var(--surface2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { padding: .3rem .65rem; font-size: .85rem; }
.btn.tiny { padding: .1rem .4rem; font-size: .75rem; border: none; }
.btn.wide { width: 100%; }

/* ---------- Avisos ---------- */
.alert, .banner { border-radius: 10px; padding: .7rem .9rem; }
.alert.danger { background: var(--danger-soft); color: #a12227; }
.alert.success { background: var(--success-soft); color: #0b6b35; }
.alert.gold, .banner.gold { background: var(--gold-soft); color: #7a5300; }

/* ---------- Chips y píldoras ---------- */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
    font: inherit;
    font-size: .85rem;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    border-radius: 999px;
    padding: .25rem .7rem;
    cursor: pointer;
}
span.chip { cursor: default; background: var(--surface2); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.chip.ghost { border-style: dashed; color: var(--text2); }
.pill { display: inline-block; font-size: .75rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; background: var(--surface2); color: var(--text2); margin-left: .3rem; }
.pill.success { background: var(--success-soft); color: var(--success); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.gold { background: var(--gold-soft); color: var(--gold); }

/* ---------- Avatar ---------- */
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; object-fit: cover; }
.avatar.small { width: 34px; height: 34px; font-size: .8rem; }
.avatar.big { width: 72px; height: 72px; font-size: 1.4rem; }

/* ---------- Clientes ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; text-align: center; align-content: center; }
.stat { font-size: 1.7rem; font-weight: 700; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.kpi .stat { font-size: 1.4rem; }
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.client-card { display: flex; gap: .8rem; align-items: center; color: inherit; transition: transform .1s, box-shadow .1s; }
.client-card:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 6px 18px rgba(16, 24, 40, .1); }
.arrow { font-size: 1.6rem; color: var(--text2); }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 0 0 .8rem; }
dl.facts dt { color: var(--text2); }
dl.facts dd { margin: 0; font-weight: 600; }

/* ---------- Pestañas ---------- */
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); overflow-x: auto; margin-bottom: .4rem; }
.tab { font: inherit; background: none; border: none; padding: .6rem 1rem; cursor: pointer; color: var(--text2); border-bottom: 3px solid transparent; font-weight: 600; white-space: nowrap; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Tablas ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--card); }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text2); font-weight: 600; padding: .5rem .6rem; border-bottom: 1px solid var(--border); }
.table td { padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table.compact td { padding: .35rem .5rem; }
.table input { width: 100%; padding: .3rem .5rem; }
.table tr.warm td { background: var(--gold-soft); }
.table-scroll { overflow-x: auto; }
.table.sets input[type=number] { max-width: 110px; }
.table.portions th, .table.portions td { text-align: center; }
.table.portions th:first-child, .table.portions td:first-child { text-align: left; }
.table.portions td.filled { background: var(--accent-soft); font-weight: 600; }
.table.portions tr.totals td { font-weight: 700; background: var(--surface2); }
.table.portions.edit td { min-width: 90px; }
.table.portions.edit td:first-child { min-width: 190px; }
.table.portions.edit input[type=number] { width: 70px; text-align: center; }
.meal-name { width: 110px; font-weight: 600; text-align: center; }
.set-badge { font: inherit; width: 34px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); font-weight: 700; cursor: pointer; }
.set-badge.warm { background: var(--gold); border-color: var(--gold); color: #fff; }
.stats-edit { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: .5rem; margin-bottom: .6rem; }
.stats-edit input { flex: 1; }

/* ---------- Gráficas ---------- */
.chart { width: 100%; height: auto; max-height: 240px; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--text2); font-size: 11px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.chart .dot { fill: var(--card); stroke: var(--accent); stroke-width: 2; }
.chart-legend { margin-top: .3rem; }
.chart-legend .up { color: var(--success); }
.chart-legend .down { color: var(--danger); }
.chart-empty { padding: 2rem 0; text-align: center; }

/* ---------- Selector de ejercicios ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 20, 35, .55); display: grid; place-items: center; z-index: 50; padding: 1rem; }
.modal { background: var(--card); border-radius: 18px; padding: 1.2rem; width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column; gap: .7rem; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.modal.wide-modal { max-width: 820px; }
.picker-list { overflow-y: auto; display: flex; flex-direction: column; gap: .3rem; min-height: 200px; }
.picker-item { font: inherit; text-align: left; display: flex; align-items: center; gap: .5rem; padding: .6rem .8rem; border-radius: 10px; border: 1px solid var(--border); background: var(--card); cursor: pointer; color: inherit; }
.picker-item:hover { background: var(--accent-soft); border-color: var(--accent); }

/* ---------- Perfil ---------- */
.preview { position: sticky; top: 1rem; }
.trainer-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .5rem; padding: 1rem; margin-top: .6rem; border-radius: var(--radius); background: var(--surface2); }

/* ---------- Alimentos ---------- */
.food-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; align-items: start; }

/* ---------- Spinner ---------- */
.spinner { width: 36px; height: 36px; border: 4px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 2rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Error de conexión de Blazor */
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: var(--gold-soft); padding: .7rem 1rem; z-index: 100; }

/* ---------- Listas editables ---------- */
.card.flush { padding: 0; overflow: hidden; }
.add-food { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; border-top: 1px dashed var(--border); padding-top: .6rem; margin-top: .6rem; }
.add-food input:first-child { flex: 1; min-width: 140px; }
input.amount { width: 90px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
@media (max-width: 600px) { .row-3 { grid-template-columns: 1fr; } }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface2); }

/* ---------- Calendario ---------- */
.sync-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.calendar-card { overflow-x: auto; }
.week { min-width: 760px; }
.week-head, .week-body { display: grid; grid-template-columns: 56px repeat(7, 1fr); }
.week-head { border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card); z-index: 2; }
.day-head { display: flex; flex-direction: column; align-items: center; padding: .5rem 0; gap: .1rem; }
.day-head.today .bold { background: var(--accent); color: #fff; border-radius: 999px; width: 30px; height: 30px; display: grid; place-items: center; }
.hour-col { display: flex; flex-direction: column; }
.hour-label { height: 48px; font-size: .72rem; color: var(--text2); text-align: right; padding: 0 .4rem; transform: translateY(-.5em); }
.day-col { position: relative; border-left: 1px solid var(--border); }
.day-col.today { background: rgba(47, 107, 255, .03); }
.slot { height: 48px; border-bottom: 1px solid var(--border); cursor: pointer; }
.slot:hover { background: var(--accent-soft); }
.appt {
    position: absolute;
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    padding: .2rem .4rem;
    font-size: .78rem;
    line-height: 1.2;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
    z-index: 1;
}
.appt:hover { filter: brightness(1.08); }
.appt.guest { background: #7c5cff; }
.appt.cancelled { background: var(--surface2); color: var(--text2); text-decoration: line-through; box-shadow: none; opacity: .7; }
.appt-time { font-size: .7rem; opacity: .9; }
.appt-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt-sub { opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Arrastrar citas ---------- */
.drag-hint { padding: .5rem .8rem 0; }
.appt[draggable=true] { cursor: grab; }
.appt.is-dragging { opacity: .35; }
.week.dragging .appt:not(.ghost) { pointer-events: none; } /* para poder soltar encima de otra cita */
.slot { display: flex; flex-direction: column; }
.quarter { flex: 1; }
.quarter:hover { background: var(--accent-soft); }
.appt.ghost { pointer-events: none; background: transparent; border: 2px dashed var(--accent); color: var(--accent); box-shadow: none; z-index: 3; }

/* ===== Revisiones ===== */
.card.soft { background: var(--surface2); box-shadow: none; border: 0; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.gold-text { color: var(--gold); letter-spacing: 1px; }

/* ===== Mensajes ===== */
.chat-card { display: flex; flex-direction: column; gap: .7rem; }
.chat { display: flex; flex-direction: column; gap: .35rem; max-height: 60vh; min-height: 240px; overflow-y: auto; padding: .2rem; }
.chat-day { align-self: center; font-size: .72rem; font-weight: 600; color: var(--text2); background: var(--surface2); border-radius: 999px; padding: .15rem .6rem; margin: .5rem 0 .1rem; }
.bubble { max-width: 75%; padding: .5rem .75rem; border-radius: 14px; line-height: 1.35; overflow-wrap: anywhere; }
.bubble.mine { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 4px; }
.bubble.theirs { align-self: flex-start; background: var(--surface2); border-bottom-left-radius: 4px; }
.bubble-time { font-size: .68rem; opacity: .7; text-align: right; margin-top: .1rem; }
.composer { display: flex; gap: .6rem; align-items: flex-end; }
.composer textarea { flex: 1; }

/* ===== Fotos de las revisiones ===== */
.photos { display: flex; flex-wrap: wrap; gap: .5rem; margin: .3rem 0; }
.photo { position: relative; width: 96px; aspect-ratio: 3 / 4; border: 0; padding: 0; border-radius: 10px; overflow: hidden; background: var(--surface2); cursor: pointer; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-pose { position: absolute; left: 4px; bottom: 4px; font-size: .68rem; font-weight: 700; color: #fff; background: rgba(0, 0, 0, .55); border-radius: 6px; padding: 1px 6px; }
.upload-btn { cursor: pointer; }
.upload-btn input[type=file] { display: none; }
.upload-btn.disabled { opacity: .6; pointer-events: none; }
.viewer { background: var(--card); border-radius: var(--radius); padding: 1rem; max-width: min(92vw, 900px); max-height: 92vh; display: flex; flex-direction: column; gap: .7rem; }
.viewer img { max-width: 100%; max-height: 78vh; object-fit: contain; border-radius: 8px; align-self: center; }
