/* ============================================================
   CORRIENDO — estilos específicos (usa variables de guadayre-shared-style.css)
   ============================================================ */

html, body { overflow-x: hidden; }
#screen-app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; background: var(--app-bg); }

/* ── Tabs ── */
.tab-content { display: none; flex-direction: column; padding: 20px 24px; gap: 20px; }
.tab-content.active { display: flex; flex: 1; }
.tab-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.tab-header h2 { font-size: 22px; font-weight: 800; letter-spacing: .3px; color: var(--gd-blue); }
.tab-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Resumen: tiles ── */
.tiles-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 14px; }

/* ── Récords ── */
.records-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap: 14px; }
.record-card { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 12px; padding: 16px 18px; }
.record-card .record-label { font-size: 12px; color: var(--app-muted); text-transform: uppercase; letter-spacing: .5px; }
.record-card .record-value { font-size: 24px; font-weight: 800; color: var(--gd-blue); margin-top: 4px; white-space: nowrap; }
.record-card .record-sub { font-size: 13px; color: var(--app-text); margin-top: 4px; }

/* ── Gráficas ── */
.chart-box { display: flex; align-items: center; justify-content: center; min-height: 220px; }
.chart-legend { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.chart-legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--app-text); }
.chart-legend-swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.chart-donut-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.chart-donut-total { font-size: 20px; font-weight: 800; color: var(--gd-blue); }
.chart-donut-total-label { font-size: 11px; color: var(--app-muted); text-transform: uppercase; letter-spacing: .5px; }

/* Mini gráficas (donut + barras) que acompañan a cada tabla agrupada */
.mini-charts-row { display: flex; gap: 16px; flex-wrap: wrap; }
.mini-chart-box { flex: 1; min-width: 200px; display: flex; align-items: center; justify-content: center; min-height: 150px; background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 10px; padding: 12px; overflow-x: auto; }

/* Botón "mostrar más" para tablas largas */
.mostrar-mas-wrap { display: flex; justify-content: center; margin-top: 10px; }
.btn-mostrar-mas { background: var(--gd-blue-soft); color: var(--gd-blue); border: 1px solid rgba(0,102,255,0.3);
  padding: 8px 18px; border-radius: 20px; font-weight: 600; font-size: 13px; cursor: pointer; font-family: var(--font-ui); }
.btn-mostrar-mas:hover { background: rgba(0,102,255,0.18); }

/* ── Config subtabs (catálogos) ── */
.config-subtabs { display: flex; gap: 4px; border-bottom: 2px solid var(--app-border); flex-wrap: wrap; }
.config-subtab { background: transparent; border: none; color: var(--app-muted);
  padding: 10px 16px; cursor: pointer; font-size: 15px; font-weight: 600;
  font-family: var(--font-ui); border-bottom: 3px solid transparent; margin-bottom: -2px; transition: all .2s; }
.config-subtab:hover  { color: var(--gd-blue); }
.config-subtab.active { color: var(--gd-blue); border-bottom-color: var(--gd-blue); }
.cfg-panel        { display: none; padding-top: 20px; }
.cfg-panel.active { display: block; }

.config-card { background: var(--app-surface); border: 1px solid var(--app-border);
  border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.config-card h3 { font-size: 18px; font-weight: 700; letter-spacing: .3px;
  color: var(--app-text); border-bottom: 1px solid var(--app-border); padding-bottom: 10px; }

/* ── Formularios ── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(200px,1fr)); gap: 12px; }
.fg-field { display: flex; flex-direction: column; gap: 5px; }
.fg-field.fg-wide { grid-column: 1 / -1; }
.fg-field label { font-size: 12px; color: var(--app-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.fg-field input, .fg-field select, .fg-field textarea { background: #fff; border: 1px solid var(--app-border);
  border-radius: 6px; color: var(--app-text); padding: 9px 12px; font-size: 15px; font-family: var(--font-ui); }
.fg-field input:focus, .fg-field select:focus, .fg-field textarea:focus { outline: none; border-color: var(--gd-blue); }
.fg-field input::placeholder, .fg-field textarea::placeholder { color: var(--app-muted); }
.fg-field textarea { resize: vertical; }

.tiempo-inputs { display: flex; align-items: center; gap: 6px; }
.tiempo-inputs input { width: 100%; min-width: 0; text-align: center; }
.tiempo-inputs span { color: var(--app-muted); font-weight: 700; }

.entity-form { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 8px; padding: 16px; margin-top: 12px; display: flex; flex-direction: column; gap: 12px; }
.entity-form h4 { font-size: 13px; color: var(--app-muted); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.entity-form-actions { display: flex; gap: 8px; }

.entity-lista { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.entity-item  { display: flex; align-items: center; gap: 10px; background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 6px; padding: 10px 12px; }
.ei-info   { flex: 1; min-width: 0; }
.ei-nombre { font-size: 14px; font-weight: 700; color: var(--app-text); }
.ei-sub    { font-size: 12px; color: var(--app-muted); margin-top: 1px; }
.ei-actions { display: flex; gap: 6px; flex-shrink: 0; }
.badge-tipo { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .3px; background: var(--gd-blue-soft); color: var(--gd-blue); margin-right: 6px; }
.entity-lista-sep { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--app-muted); padding: 10px 4px 2px; }

/* Interruptor deslizante (activar/desactivar zapatilla) */
.switch { position: relative; display: inline-block; width: 38px; height: 21px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: #ccc; transition: .2s; border-radius: 22px; cursor: pointer; }
.switch .slider::before { content: ""; position: absolute; height: 15px; width: 15px; left: 3px; bottom: 3px;
  background: #fff; transition: .2s; border-radius: 50%; }
.switch input:checked + .slider { background: var(--gd-blue); }
.switch input:checked + .slider::before { transform: translateX(17px); }

/* ── Filtros ── */
.filtros-bar { display: flex; gap: 10px; flex-wrap: wrap; }
.filtros-bar input, .filtros-bar select { background: #fff; border: 1px solid var(--app-border);
  border-radius: 6px; color: var(--app-text); padding: 9px 12px; font-size: 14px; font-family: var(--font-ui); }
.filtros-bar input { flex: 1; min-width: 220px; }
.filtros-bar input:focus, .filtros-bar select:focus { outline: none; border-color: var(--gd-blue); }

/* ── Tablas ── */
.table-wrap { overflow-x: auto; border: 1px solid var(--app-border); border-radius: 10px; }
.table-wrap table { min-width: 640px; }
.vacio { color: var(--app-muted); font-size: 14px; padding: 24px; text-align: center; }

/* Anchos consistentes entre las tablas Por año / Por mes / Por semana (7 columnas: incluye desnivel) */
.table-grupo { table-layout: fixed; width: 100%; }
.table-grupo th:nth-child(1), .table-grupo td:nth-child(1) { width: 18%; }
.table-grupo th:nth-child(2), .table-grupo td:nth-child(2) { width: 12%; }
.table-grupo th:nth-child(3), .table-grupo td:nth-child(3) { width: 16%; }
.table-grupo th:nth-child(4), .table-grupo td:nth-child(4) { width: 16%; }
.table-grupo th:nth-child(5), .table-grupo td:nth-child(5) { width: 14%; }
.table-grupo th:nth-child(6), .table-grupo td:nth-child(6) { width: 14%; }
.table-grupo th:nth-child(7), .table-grupo td:nth-child(7) { width: 10%; }
.table-grupo th { cursor: pointer; user-select: none; white-space: nowrap; }
.table-grupo th:hover { color: var(--gd-blue); }
.table-grupo th .sort-arrow { margin-left: 4px; opacity: .5; }
.table-grupo th.sorted .sort-arrow { opacity: 1; color: var(--gd-blue); }
.table-grupo td:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Variante para tablas con nombres largos (Lugar, Evento, Zapatilla) */
.table-grupo-ancha th:nth-child(1), .table-grupo-ancha td:nth-child(1) { width: 26%; }
.table-grupo-ancha th:nth-child(2), .table-grupo-ancha td:nth-child(2) { width: 10%; }
.table-grupo-ancha th:nth-child(3), .table-grupo-ancha td:nth-child(3) { width: 14%; }
.table-grupo-ancha th:nth-child(4), .table-grupo-ancha td:nth-child(4) { width: 14%; }
.table-grupo-ancha th:nth-child(5), .table-grupo-ancha td:nth-child(5) { width: 14%; }
.table-grupo-ancha th:nth-child(6), .table-grupo-ancha td:nth-child(6) { width: 12%; }
.table-grupo-ancha th:nth-child(7), .table-grupo-ancha td:nth-child(7) { width: 10%; }

/* Cabecera ordenable reutilizable (tabla de Entrenamientos) */
#tabla-registros th { cursor: pointer; user-select: none; white-space: nowrap; }
#tabla-registros th:hover { color: var(--gd-blue); }
#tabla-registros th .sort-arrow { margin-left: 4px; opacity: .5; }
#tabla-registros th.sorted .sort-arrow { opacity: 1; color: var(--gd-blue); }
#tabla-registros th.no-sort { cursor: default; }

/* Filas de entrenamientos que corresponden a una competición */
tr.fila-competicion { background: rgba(0,102,255,0.055); }
tr.fila-competicion:hover { background: var(--gd-blue-soft); }

/* Iconos de acción (edición / borrado) */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; }
.icon-btn svg { display: block; }

/* ── Responsive ── */
@media (min-width: 769px) {
  .config-subtab { font-size: 17px; }
  .tab-header h2 { font-size: 24px; }
  .btn-danger, .btn-edit { font-size: 14px; }
  .fg-field label { font-size: 13px; }
  .fg-field input, .fg-field select, .fg-field textarea { font-size: 16px; }
  .ei-nombre { font-size: 16px; }
  .ei-sub    { font-size: 13px; }
}

@media (max-width: 768px) {
  .tab-content { padding: 16px 12px; overflow-x: hidden; }
  .config-subtabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .form-grid { grid-template-columns: 1fr; }
  .config-card { min-width: 0; overflow: hidden; }
  .entity-item { flex-wrap: wrap; }
}
