/* Estética inspirada en la app de reservas de AimHarder: blanco, azul #2490f4,
   horas en azul oscuro y bloques de clase grises con borde de color a la izquierda. */
:root {
  --blue: #2490f4; --blue-dark: #1a7ad6; --navy: #084b8a; --green: #5cb85c; --red: #f44848;
  --orange: #f0ad4e; --text: #333; --muted: #888; --line: #ddd; --block: #f2f2f2; --bg: #fff;
  --sidebar: #fafafa;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 70px; }
body { margin: 0; font: 14px/1.5 "Open Sans", "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; color: #222; }
h2 { font-size: 16px; font-weight: 600; margin: 0; color: #222; }
p { margin: 0 0 8px; }

/* Barra superior y menú lateral */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center;
  height: 56px; padding: 0 20px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; letter-spacing: .5px; color: #222; font-size: 17px; display: flex; align-items: center; gap: 6px; }
.brand:hover { text-decoration: none; }
.brand-mark { background: var(--blue); color: #fff; border-radius: 4px; padding: 1px 6px; font-size: 13px; }
.layout { display: grid; grid-template-columns: 210px 1fr; min-height: calc(100vh - 56px); }
.layout-public { grid-template-columns: 1fr; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--line); padding: 16px 0; }
.sidebar a { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: #555; font-weight: 600; border-left: 3px solid transparent; }
.sidebar a:hover { background: #f0f0f0; text-decoration: none; }
.sidebar a.active { color: var(--blue); border-left-color: var(--blue); background: #fff; }
.ico { width: 20px; text-align: center; }
main { padding: 20px 28px 60px; max-width: 1600px; width: 100%; }

/* Botones */
.btn { display: inline-flex; align-items: center; gap: 4px; font: inherit; font-weight: 600; padding: 7px 14px;
  border-radius: 5px; border: 1px solid transparent; cursor: pointer; background: #fff; color: var(--text); line-height: 1.3; }
.btn:hover { text-decoration: none; filter: brightness(.96); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); filter: none; }
.btn-outline { border-color: var(--blue); color: var(--blue); }
.btn-danger { background: var(--red); color: #fff; }
.btn-link { background: none; color: var(--blue); padding: 0; border: 0; }
.btn-outline-danger { border-color: var(--red); color: var(--red); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
form.inline { display: inline; margin: 0; }

/* Cabecera de página y acciones */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Pestañas de vista */
.plan-in-use { margin: -4px 0 14px; color: #555; font-size: 13.5px; }
.plan-in-use strong { color: var(--navy); }
.view-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.view-tabs a { padding: 8px 16px; color: #555; font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.view-tabs a:hover { text-decoration: none; color: var(--blue); }
.view-tabs a.active { color: var(--blue); border-bottom-color: var(--blue); }

/* Barra de días: no seleccionados transparentes, seleccionado en azul */
.daybar { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.daybar a { display: flex; flex-direction: column; align-items: center; padding: 8px 0; border-radius: 4px; line-height: 1.25;
  background: transparent; color: var(--navy); border: 1px solid #d6e6f8; }
.daybar a:hover { text-decoration: none; background: #eef6ff; }
.daybar a.selected { background: var(--blue); color: #fff; border-color: var(--blue); }
.daybar .dow { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.daybar .dnum { font-size: 20px; font-weight: 700; }
.daybar .dcount { font-size: 11px; opacity: .8; }
.sep { border: 0; border-top: 2px solid #e6e6e6; margin: 16px 0 20px; }

/* Días y bloques de clase: rejilla que aprovecha todo el ancho */
.days-list { display: flex; flex-direction: column; gap: 16px; margin-bottom: 22px; }
.card { border: 1px solid var(--line); border-radius: 4px; padding: 14px; background: #fff; display: flex; flex-direction: column; }
.card .add-form { margin-top: auto; padding-top: 8px; }
/* Clases del box agrupadas por hora */
.hour-group { display: grid; grid-template-columns: 80px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid #eee; }
.hour-label { color: var(--navy); font-weight: 700; font-size: 17px; padding-top: 8px; }
.hour-classes .clase:last-child { margin-bottom: 0; }
.clase.mine { background: #eef6ff; }

/* Vista semanal tipo calendario */
.cal-wrap { overflow-x: auto; margin-bottom: 8px; }
.cal { display: grid; grid-template-columns: 64px repeat(6, minmax(140px, 1fr)); min-width: 900px; border-top: 1px solid var(--line); }
.cal-day { display: flex; flex-direction: column; padding: 10px 8px 8px; color: #333; border-bottom: 1px solid var(--line); }
.cal-day:hover { text-decoration: none; background: #f6faff; }
.cal-day .dow { font-size: 12px; letter-spacing: 1px; color: #555; }
.cal-day .dnum { font-size: 28px; font-weight: 400; line-height: 1.1; }
.cal-hour { font-weight: 700; font-size: 13px; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.cal-cell { padding: 6px 4px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.cal-clase { position: relative; background: var(--c); color: var(--ct, #fff); border-radius: 2px; padding: 8px 26px 8px 10px; min-height: 58px; }
.cal-clase.warn { outline: 3px solid #f0ad4e; outline-offset: -3px; }
.cal-time { display: block; font-size: 12px; opacity: .9; font-weight: 600; }
.cal-name { display: block; font-weight: 700; text-transform: uppercase; font-size: 13px; line-height: 1.25; }
.cal-flag { display: inline-block; margin-top: 4px; font-size: 11px; font-weight: 700; background: #fff; color: #a94442; border-radius: 3px; padding: 0 5px; }
.cal-del { position: absolute; top: 4px; right: 4px; margin: 0; }
.cal-del button { border: 0; background: rgba(255,255,255,.35); color: var(--ct, #fff); border-radius: 3px; cursor: pointer; font-size: 11px; padding: 1px 5px; }
.cal-del button:hover { background: rgba(0,0,0,.25); }
.bottom { margin-top: 22px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding-bottom: 6px; margin-bottom: 8px; border-bottom: 2px solid var(--blue); }
.clase { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--block); border: 1px solid #ccc; border-left: 5px solid var(--c, var(--blue)); border-radius: 2px;
  padding: 10px 12px; margin-bottom: 6px; }
.clase-main { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; flex: 1; min-width: 0; }
.clase .tag { white-space: normal; }
.clase-hora { color: var(--navy); font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.clase-nombre { font-size: 16px; font-weight: 600; color: #222; }
.clase-alts { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding-top: 4px; border-top: 1px dashed #ccc; }
.c0 { --c: #e03131; } .c1 { --c: #2490f4; } .c2 { --c: #2f9e44; } .c3 { --c: #f08c00; }
.c4 { --c: #7048e8; } .c5 { --c: #0c8599; } .c6 { --c: #d6336c; } .c7 { --c: #5c940d; }

/* ===== Colores por tipo de clase =====
   --c: color de la clase (borde y fondo en la vista semanal) · --ct: color del texto encima de --c */
.k-crossfit     { --c: #00B2D7; --ct: #fff; }
.k-halterofilia { --c: #7797B3; --ct: #fff; }
.k-endurance    { --c: #808AC1; --ct: #fff; }      /* cualquier clase con "endurance" */
.k-hybrid       { --c: #A691AB; --ct: #fff; }      /* T-Hybrid */
.k-gimnasticos  { --c: #B9DCE3; --ct: #17343b; }
.k-open         { --c: #482A5A; --ct: #fff; }      /* cualquier clase con "open" */
.k-iniciacion   { --c: #19315F; --ct: #fff; }
.k-funcional    { --c: #E289B2; --ct: #3a0f22; }   /* cualquier clase con "funcional" */
.k-otra         { --c: #9F1957; --ct: #fff; }      /* cualquier otra clase */
.empty { color: var(--muted); font-style: italic; padding: 8px 2px; margin: 0; }
.add-form { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.add-form input[type=text], .add-form input[type=email] { flex: 1; min-width: 140px; }
.time-pick { display: inline-flex; align-items: center; gap: 2px; }
.time-pick .colon { font-weight: 700; color: var(--navy); }
.name-pick { display: flex; gap: 6px; flex: 1; min-width: 200px; }
.name-pick select { flex: 1; min-width: 140px; }
.name-pick .name-custom { flex: 1; min-width: 160px; }
.name-pick.js:not(.other) .name-custom { display: none; }
.popover { position: relative; }
.pop-box label.check { gap: 6px; font-weight: 600; }
.pop-box { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 300px; display: flex; flex-direction: column;
  gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.12); }
.steps { padding-left: 18px; margin: 0 0 10px; } .steps li { margin-bottom: 6px; word-break: break-all; }
.pending { margin-top: 8px; }
.alt-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* Etiquetas */
.tag { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 3px; margin-left: 4px; white-space: nowrap; }
.tag-ok { background: #dff0d8; color: #3c763d; }
.tag-err { background: #f2dede; color: #a94442; }
.tag-off { background: #eee; color: #777; }
.tag-info { background: #d9edf7; color: #31708f; }

/* Formularios */
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
label.check { flex-direction: row; align-items: center; font-weight: 400; }
.label { font-weight: 600; font-size: 13px; }
input, select { font: inherit; padding: 7px 10px; border: 1px solid #ccc; border-radius: 4px; background: #fff; color: var(--text); min-width: 0; }
input:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(36,144,244,.2); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row, .two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.two-cols { align-items: start; }

/* Paneles */
.panel { border: 1px solid var(--line); border-radius: 4px; padding: 18px; margin-bottom: 18px; background: #fff; }
.panel h2 { margin-bottom: 12px; }
.narrow { max-width: 420px; margin: 40px auto; }
.narrow-left { max-width: 640px; }
.plan-list { list-style: none; padding: 0; margin: 14px 0 0; }
.plan-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid #eee; flex-wrap: wrap; }
.plan-list .plan-name { flex: 1; }

/* Resultado del domingo */
.result-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.result-date { font-weight: 600; }
.tag.big { font-size: 13px; padding: 3px 10px; }
.result-list { list-style: none; padding: 0; margin: 0; }
.result-list li { display: grid; grid-template-columns: 26px 78px 50px 1fr; align-items: center; gap: 6px; padding: 8px 6px; border-bottom: 1px solid #eee; }
.result-list .res-icon { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; color: #fff; }
.result-list li.ok .res-icon { background: var(--green); }
.result-list li.ko .res-icon { background: var(--red); }
.res-day { color: #555; } .res-time { color: var(--navy); font-weight: 700; } .res-name { font-weight: 600; }
.res-reason { grid-column: 2 / -1; color: #a94442; font-size: 12.5px; }
.older { margin-top: 10px; border-top: 0; }
.older-list { list-style: none; padding: 0; margin: 6px 0 0; }
.older-list li { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.plan-name { font-weight: 600; }
.plan-days { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.mini { font-size: 12.5px; background: var(--block); border-left: 3px solid var(--c, var(--blue)); padding: 2px 6px; margin-top: 3px; }

/* Avisos flotantes (no desplazan la página) */
.toasts { position: fixed; top: 66px; right: 20px; z-index: 150; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast { margin: 0; box-shadow: 0 4px 14px rgba(0,0,0,.12); cursor: pointer; transition: opacity .4s; }
.toast.hide { opacity: 0; }

/* Avisos */
.alert { padding: 10px 14px; border-radius: 4px; margin-bottom: 14px; border: 1px solid; }
.alert p:last-child { margin-bottom: 0; }
.alert-ok { background: #dff0d8; border-color: #d0e9c6; color: #3c763d; }
.alert-error { background: #f2dede; border-color: #ebcccc; color: #a94442; }
.alert-info { background: #d9edf7; border-color: #bcdff1; color: #31708f; }
.alert-warn { background: #fcf8e3; border-color: #faf2cc; color: #8a6d3b; }
.secret { font-size: 18px; background: #fff; padding: 4px 10px; border: 1px dashed #c9b77e; border-radius: 4px; user-select: all; }

/* Tabla admin */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; background: var(--block); font-weight: 600; }
th, td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.row-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.inline-details { border: 0; padding: 0; }
.inline-details summary { list-style: none; display: inline-flex; }
.inline-details summary::-webkit-details-marker { display: none; }
.inline-details[open] form { margin-top: 6px; }

/* Historial */
details { border-top: 1px solid var(--line); padding: 8px 0; }
summary { cursor: pointer; }
pre { white-space: pre-wrap; word-break: break-word; font-size: 12.5px; background: var(--block); padding: 10px; border-radius: 3px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* Móvil: el menú lateral pasa a barra horizontal */
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: flex; overflow-x: auto; padding: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar a { border-left: 0; border-bottom: 3px solid transparent; padding: 10px 12px; white-space: nowrap; }
  .sidebar a.active { border-bottom-color: var(--blue); }
  main { padding: 14px 12px 50px; }
  .hour-group { grid-template-columns: 56px 1fr; }
  .daybar { gap: 3px; } .daybar .dcount { display: none; }
  .toasts { left: 12px; right: 12px; max-width: none; }
  .pop-box { right: auto; left: 0; width: min(300px, calc(100vw - 30px)); }
  .row, .two-cols { grid-template-columns: 1fr; }
  .plan-days { grid-template-columns: repeat(2, 1fr); }
  .plan-row { grid-template-columns: 1fr; }
}

/* ---------- Login centrado y pantallas sin sesión ---------- */
.layout-public main { display: flex; align-items: center; justify-content: center; max-width: none;
  min-height: calc(100vh - 56px); padding: 24px 16px; }
.auth-box { width: 100%; max-width: 420px; margin: 0; box-shadow: 0 6px 24px rgba(0,0,0,.06); }
.auth-links { margin: 4px 0 6px; }

/* ---------- Ventana obligatoria de contraseña ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(15, 30, 50, .55);
  display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 8px; width: 100%; max-width: 420px; padding: 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.modal h1 { margin-bottom: 6px; }

/* ---------- Vista diaria con las clases del box ---------- */
.box-day .hour-group:first-of-type { padding-top: 0; }
.unlisted { border: 1px dashed #e0b252; background: #fffbf0; border-radius: 4px; padding: 10px 12px; margin-bottom: 14px; }
.manual-add { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 10px; }
.manual-add summary { color: var(--blue); font-weight: 600; }
.manual-add .add-form { margin-top: 10px; }
.no-creds { margin: 8px 0 0; }
.admin-only { border-style: dashed; }

/* ---------- Ficha de usuario (administración) ---------- */
.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.details dt { color: var(--muted); font-weight: 600; font-size: 13px; }
.details dd { margin: 0; }

/* ---------- Renombrar planificación (lápiz) ---------- */
.plan-in-use { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rename { display: inline-block; vertical-align: middle; }
.rename .pop-box { left: 0; right: auto; font-size: 14px; font-weight: 400; }
.icon-btn { cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 4px; line-height: 1.2; }
.icon-btn:hover { background: #eef6ff; }

/* ---------- Pantallas de alta (pasos) ---------- */
.steps-mark { margin: 0 0 4px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.advanced summary { color: var(--blue); cursor: pointer; }
.advanced[open] { display: flex; flex-direction: column; gap: 10px; }
