/* ============================================================
   DANZA CONTROL - Main Stylesheet
   ============================================================ */

:root {
  --sidebar-width: 240px;
  --sidebar-collapsed: 60px;
  --sidebar-bg: #1a0533;
  --sidebar-text: rgba(255,255,255,.75);
  --sidebar-active: rgba(255,255,255,.15);
  --sidebar-hover: rgba(255,255,255,.08);
}

/* ── Layout ── */
body { background: #f4f6fb; font-size: 0.875rem; }

.sidebar {
  width: var(--sidebar-width);
  height: calc(100vh - 56px);
  background: var(--sidebar-bg);
  position: fixed;
  top: 56px; left: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width .25s ease;
  z-index: 1030;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.2) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 2px; }

.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .sidebar-section-title { display: none; }

.main-content {
  margin-left: var(--sidebar-width);
  min-height: calc(100vh - 56px);
  transition: margin-left .25s ease;
  /* Permite que el flex-item se encoja para que el scroll lo manejen los
     contenedores internos (.table-responsive) y no toda la página. */
  min-width: 0;
  max-width: 100%;
}

/* Evita el scroll horizontal de toda la página: cualquier contenido ancho
   (tablas, etc.) debe desbordarse dentro de su propio contenedor. */
html, body { max-width: 100%; overflow-x: hidden; }
.wrapper { max-width: 100vw; overflow-x: hidden; }

.main-content.expanded { margin-left: var(--sidebar-collapsed); }

/* ── Sidebar links ── */
.sidebar-inner { padding: 8px 0 24px; }

.sidebar-nav .sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 0;
  transition: background .15s, color .15s;
  white-space: nowrap;
  font-size: .85rem;
}

.sidebar-nav .sidebar-link i { font-size: 1.1rem; min-width: 20px; text-align: center; }
.sidebar-nav .sidebar-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav .sidebar-link.active { background: var(--sidebar-active); color: #fff; border-left: 3px solid var(--bs-primary); }

.sidebar-section-title {
  color: rgba(255,255,255,.35);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 16px 16px 4px;
  font-weight: 700;
}

/* ── Cards ── */
.card { border: none; box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06); border-radius: 12px; }
.card-header { background: #fff; border-bottom: 1px solid #f0f0f0; border-radius: 12px 12px 0 0 !important; }

/* ── Stats cards ── */
.stat-card { border-radius: 16px; padding: 20px; color: #fff; }
.stat-card .stat-icon { width: 48px; height: 48px; background: rgba(255,255,255,.2); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: .8rem; opacity: .85; margin-top: 2px; }

/* ── Badges / Status ── */
.status-badge { font-size: 11px; padding: 3px 8px; border-radius: 20px; font-weight: 600; letter-spacing: .3px; }

/* ── Avatar ── */
.avatar-circle { border-radius: 50%; object-fit: cover; }

/* ── Section stepper (registration) ── */
.step-wizard { display: flex; align-items: center; gap: 0; margin-bottom: 2rem; }
.step-wizard .sw-step { display: flex; flex-direction: column; align-items: center; flex: 1; }
.step-wizard .sw-step .sw-number {
  width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; border: 2px solid #dee2e6; background: #fff; color: #aaa; transition: all .3s;
}
.step-wizard .sw-step.active .sw-number { background: var(--bs-primary); border-color: var(--bs-primary); color: #fff; }
.step-wizard .sw-step.done .sw-number { background: #198754; border-color: #198754; color: #fff; }
.step-wizard .sw-step .sw-label { font-size: 11px; margin-top: 4px; color: #888; }
.step-wizard .sw-step.active .sw-label, .step-wizard .sw-step.done .sw-label { color: #333; font-weight: 600; }
.step-wizard .sw-connector { flex: 1; height: 2px; background: #dee2e6; margin-bottom: 20px; }
.step-wizard .sw-connector.done { background: #198754; }

/* ── Photo upload ── */
.photo-upload-area {
  border: 2px dashed #ccc; border-radius: 12px; padding: 24px; text-align: center; cursor: pointer;
  transition: border-color .2s, background .2s;
}
.photo-upload-area:hover { border-color: var(--bs-primary); background: rgba(111,66,193,.04); }
.photo-upload-area.has-photo { border-style: solid; border-color: #198754; }
.photo-preview { max-width: 180px; max-height: 180px; border-radius: 50%; object-fit: cover; border: 3px solid #dee2e6; display: none; }

/* ── Face detection status ── */
.face-status { font-size: .8rem; padding: 6px 12px; border-radius: 20px; display: inline-flex; align-items: center; gap: 6px; }
.face-status.checking  { background: #fff3cd; color: #664d03; }
.face-status.ok        { background: #d1e7dd; color: #0a3622; }
.face-status.error     { background: #f8d7da; color: #58151c; }

/* ── Form sections ── */
.section-panel { display: none; }
.section-panel.active { display: block; }

/* ── Tables ── */
.table-hover > tbody > tr:hover { background: rgba(111,66,193,.04); }

/* ── Attendance grid ── */
.attendance-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.attendance-card { border: 1px solid #e9ecef; border-radius: 10px; padding: 12px; cursor: pointer; transition: all .15s; }
.attendance-card.present { border-color: #198754; background: #d1e7dd; }
.attendance-card.absent  { border-color: #dee2e6; background: #fff; }
/* La "ausencia justificada" solo aplica/visualiza cuando el miembro está ausente */
.attendance-card.present .justify-wrap { display: none; }
.attendance-card.absent  .justify-wrap { display: block; }

/* ── Uniform item cards ── */
.uniform-item { border: 1px solid #e9ecef; border-radius: 10px; padding: 14px; transition: all .15s; }
.uniform-item.has { border-color: #198754; background: #d1e7dd; }
.uniform-item.no  { border-color: #dee2e6; background: #fff; }

/* ── Service card ── */
.service-card { border-radius: 12px; overflow: hidden; }
.service-card .service-header { padding: 14px 16px; color: #fff; }

/* ── Form builder ── */
.form-field-row { border: 1px solid #e9ecef; border-radius: 10px; padding: 14px; margin-bottom: 10px; background: #fff; }
.form-field-row:hover { border-color: var(--bs-primary); }
.drag-handle { cursor: grab; color: #aaa; }

/* ── Priority badges ── */
.priority-baja   { background: #d1e7dd; color: #0a3622; }
.priority-media  { background: #fff3cd; color: #664d03; }
.priority-alta   { background: #f8d7da; color: #58151c; }

/* ── Percentage bar ── */
.pct-bar { height: 6px; border-radius: 3px; background: #e9ecef; overflow: hidden; }
.pct-bar-fill { height: 100%; border-radius: 3px; transition: width .4s ease; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-width); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* ============================================================
   Responsive — ajustes para móvil/tablet
   ============================================================ */
@media (max-width: 575.98px) {
  body { font-size: 0.84rem; }
  h4.fw-bold { font-size: 1.1rem; }
  h5 { font-size: 1rem; }

  /* Cabeceras de página (título + botón) que envuelvan en pantallas chicas */
  .main-content > .d-flex.justify-content-between,
  .card-header.d-flex.justify-content-between {
    flex-wrap: wrap;
    gap: .5rem;
  }

  /* Stats compactas */
  .stat-card { padding: 14px; }
  .stat-card .stat-value { font-size: 1.4rem; }
  .stat-card .stat-label { font-size: .72rem; }
  .stat-card .stat-icon { width: 40px; height: 40px; font-size: 1.1rem; }

  .card-body { padding: 0.9rem; }

  /* Modales a pantalla casi completa */
  .modal-dialog { margin: .5rem; }
  .modal-lg { max-width: 100%; }

  /* Grids de asistencia/uniformes en una columna */
  .attendance-grid { grid-template-columns: 1fr; }

  /* Botones de acción que no se corten */
  .btn { white-space: nowrap; }

  /* Tablas un poco más compactas */
  .table { font-size: .8rem; }
  .table td, .table th { padding: .45rem .4rem; }
}

@media (max-width: 991.98px) {
  /* Asegurar scroll horizontal en cualquier tabla ancha */
  .table-responsive { -webkit-overflow-scrolling: touch; }
}

/* ============================================================
   Tablas apiladas en móvil — cada fila se vuelve una tarjeta
   "Etiqueta: valor" para no requerir scroll horizontal.
   ============================================================ */
@media (max-width: 767.98px) {
  table.table-stack { border: 0; }
  table.table-stack thead { display: none; }                /* ocultar cabecera */
  table.table-stack,
  table.table-stack tbody,
  table.table-stack tr,
  table.table-stack td { display: block; width: 100%; }

  table.table-stack tr {
    border: 1px solid #e9ecef;
    border-radius: 12px;
    margin-bottom: 12px;
    padding: 6px 12px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
  }

  table.table-stack td {
    border: none !important;
    padding: .5rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    text-align: right;
    min-height: 0;
  }

  /* Etiqueta de la columna a la izquierda */
  table.table-stack td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #6c757d;
    text-align: left;
    flex: 0 0 40%;
    white-space: nowrap;
  }

  /* Celdas sin encabezado (acciones): contenido alineado a la derecha, sin etiqueta */
  table.table-stack td[data-label=""]::before { content: ""; flex: 0; }
  table.table-stack td[data-label=""] { justify-content: flex-end; }

  /* Separador entre filas/celdas */
  table.table-stack td + td { border-top: 1px solid #f4f4f6 !important; }

  /* Quitar hover de fila (ya no aplica como tabla) */
  table.table-stack.table-hover > tbody > tr:hover { background: #fff; }

  /* Que el contenido de la celda no se desborde */
  table.table-stack td > * { max-width: 100%; }
}
