/* ============================================================
   app.css – Control de Tiempos · Planta
   ============================================================ */

/* ===================== CUSTOM PROPERTIES ===================== */

:root,
[data-theme="light"] {

  /* — Fondos — */
  --color-bg:                #f4f3f3;   /* gris muy claro, casi blanco */
  --color-surface:           #ffffff;
  --color-surface-2:         #fafafa;
  --color-surface-offset:    #eeecec;

  /* — Bordes — */
  --color-divider:           #e2dede;
  --color-border:            #d4d0d0;

  /* — Texto — */
  --color-text:              #1c1a1a;   /* negro carrocería */
  --color-text-muted:        #686464;
  --color-text-faint:        #b3afaf;

  /* — Primario: rojo Cubicaje (el "4" del camión) — */
  --color-primary:           #c4262a;
  --color-primary-hover:     #9d1e21;
  --color-primary-highlight: #fdecea;

  /* — ETT (Morado) — */
  --color-ett:               #8e24aa;
  --color-ett-highlight:     #f3e5f5;

  /* — Éxito — */
  --color-success:           #2e7d32;
  --color-success-hover:     #1b5e20;
  --color-success-highlight: #e8f5e9;

  /* — Error/Peligro (burdeos oscuro para no confundir con primario) — */
  --color-error:             #7b1c1c;
  --color-error-highlight:   #fce8e8;

  /* — Advertencia — */
  --color-warning:           #b35a00;
  --color-warning-highlight: #fef3e2;

  /* — Radios de borde — */
  --radius-sm:   .375rem;
  --radius-md:   .5rem;
  --radius-lg:   .75rem;
  --radius-xl:   1rem;
  --radius-full: 9999px;

  /* — Animaciones — */
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* — Sombras — */
  --shadow-sm: 0 1px 2px rgba(28, 26, 26, 0.07);
  --shadow-md: 0 4px 12px rgba(28, 26, 26, 0.10);
  --shadow-lg: 0 12px 32px rgba(28, 26, 26, 0.14);

  /* — Tipografía fluida — */
  --text-xs:   clamp(0.75rem,  .7rem  + .25vw, .875rem);
  --text-sm:   clamp(0.875rem, .8rem  + .35vw,  1rem);
  --text-base: clamp(1rem,     .95rem + .25vw,  1.125rem);
  --text-lg:   clamp(1.125rem, 1rem   + .75vw,  1.5rem);
  --text-xl:   clamp(1.5rem,   1.2rem + 1.25vw, 2.25rem);

  /* — Espaciado — */
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;

  /* — Fuente: Montserrat (fuente oficial Cubicaje) — */
  --font-body: 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
}

[data-theme="dark"] {

  /* — Fondos: NEGRO de los camiones Cubicaje — */
  --color-bg:                #0c0c0c;   /* negro carrocería */
  --color-surface:           #131313;   /* negro ligeramente elevado */
  --color-surface-2:         #1a1a1a;
  --color-surface-offset:    #202020;

  /* — Bordes — */
  --color-divider:           #2c2828;
  --color-border:            #383434;

  /* — Texto: BLANCO de los letreros — */
  --color-text:              #f0edec;   /* blanco letras camión */
  --color-text-muted:        #8a8585;
  --color-text-faint:        #4a4646;

  /* — Primario: ROJO del "4" sobre negro — */
  --color-primary:           #e03c40;   /* más brillante para contrastar sobre negro */
  --color-primary-hover:     #c42628;
  --color-primary-highlight: #2a1515;   /* tinte rojo oscuro muy sutil */

  /* — ETT (Morado) — */
  --color-ett:               #ce93d8;
  --color-ett-highlight:     #28102d;

  /* — Éxito — */
  --color-success:           #4caf50;
  --color-success-hover:     #388e3c;
  --color-success-highlight: #142014;

  /* — Error (carmesí claro para leer sobre negro) — */
  --color-error:             #e07070;
  --color-error-highlight:   #2a1212;

  /* — Advertencia — */
  --color-warning:           #e08c40;
  --color-warning-highlight: #2a1a08;

  /* — Sombras: muy profundas sobre negro — */
  --shadow-sm: 0 1px 3px  rgba(0, 0, 0, 0.55);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.65);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.80);
}


/* ===================== RESET ===================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-bg);
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
}

/* Forzar fondo y resetear márgenes de SharePoint al cambiar de tema */
body, 
#s4-workspace, 
#contentRow, 
#contentBox, 
.SPCanvas, 
.CanvasComponent, 
.SPCanvas-canvas, 
.sp-AppIFrame,
#spPageCanvas {
  background-color: var(--color-bg) !important;
  transition: background-color var(--transition-interactive);
}

/* Ocultar márgenes de layout en SharePoint clásico/moderno */
#s4-workspace {
  margin: 0 !important;
  padding: 0 !important;
  height: 100vh !important;
  overflow: auto !important;
}
#contentBox {
  margin: 0 !important;
  padding: 0 !important;
  min-width: 100% !important;
}
#contentRow {
  padding: 0 !important;
  margin: 0 !important;
}
.ms-core-sideNavBox-removeLeftMargin {
  display: none !important;
}
#titleAreaBox {
  display: none !important;
}

input, button, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
table  { border-collapse: collapse; width: 100%; }


/* ===================== APP SHELL ===================== */

.app {
  display: none;
  grid-template-columns: 240px 1fr;
  grid-template-rows: auto 1fr;
  height: 100vh;
}
.app.active { display: grid; }


/* ===================== LOGIN ===================== */

.login-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: var(--color-bg);
}

.login-box {
  background: var(--color-surface);
  padding: var(--space-6);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--color-border);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  justify-content: center;
}
.login-logo svg       { color: var(--color-primary); }
.login-logo-text      { font-size: var(--text-base); font-weight: 700; color: var(--color-text); }
.login-logo-sub       { font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 400; }

.login-error {
  color: var(--color-error);
  font-size: var(--text-xs);
  margin-top: var(--space-3);
  text-align: center;
  display: none;
}


/* ===================== SIDEBAR ===================== */

.sidebar {
  grid-row: 1 / -1;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
}

.sidebar-logo {
  padding: var(--space-5);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-logo-title {
  font-weight: 700;
  color: var(--color-primary);
  font-size: var(--text-base);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.sidebar-user {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 400;
  padding: var(--space-2) 0 0;
}

.sidebar-nav {
  padding: var(--space-4) var(--space-3);
  flex: 1;
}

.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--color-border);
}


/* ===================== TOPBAR ===================== */

.topbar {
  grid-column: 2;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-6);
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.topbar-title {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--color-text);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.topbar-clock {
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
  background: var(--color-surface-offset);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
}


/* ===================== MAIN ===================== */

.main {
  grid-column: 2;
  grid-row: 2;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  padding: var(--space-6);
  position: relative;
}


/* ===================== NAVIGATION ===================== */

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-weight: 500;
  width: 100%;
  text-align: left;
  margin-bottom: 2px;
  font-size: var(--text-xs);
  transition: background var(--transition-interactive), color var(--transition-interactive);
}
.nav-item:hover  { background: var(--color-surface-offset); color: var(--color-text); }
.nav-item.active { background: var(--color-primary-highlight); color: var(--color-primary); font-weight: 600; }

.nav-icon { width: 16px; height: 16px; opacity: .7; }

.nav-badge {
  background: var(--color-error);
  color: #fff;
  border-radius: var(--radius-full);
  padding: 0 6px;
  font-size: 9.5px;
  font-weight: 400;
  margin-left: 4px;
}


/* ===================== BUTTONS ===================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: 600;
  border: 1px solid transparent;
  transition: all var(--transition-interactive);
  white-space: nowrap;
}

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }

.btn-success { background: var(--color-success); color: #fff; }
.btn-success:hover { background: var(--color-success-hover); }

.btn-danger { background: var(--color-error); color: #fff; }

.btn-ghost {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text-muted);
}
.btn-ghost:hover { background: var(--color-surface-offset); color: var(--color-text); }

/* Botón de ancho completo */
.btn-block {
  width: 100%;
  justify-content: center;
  padding: var(--space-3) var(--space-4);
}


/* ===================== VIEWS ===================== */

.view        { display: none; }
.view.active { display: block; }

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-3);
}
.view-header h2 { font-size: var(--text-base); font-weight: 700; }

/* Descripción informativa bajo el título de una vista */
.view-description {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}


/* ===================== SHIFT CONTROLS ===================== */

.shift-controls {
  display: flex;
  gap: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  margin-bottom: var(--space-6);
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.shift-info { flex: 1; }

.shift-title {
  font-size: var(--text-sm);
  font-weight: 700;
  margin-bottom: 4px;
}

.shift-status {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.turno-timer-display {
  font-size: var(--text-xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-primary);
}


/* ===================== DRAG & DROP BOARD ===================== */

.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.process-col {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  min-height: 120px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.process-col-header {
  padding: var(--space-3);
  background: var(--color-surface-offset);
  font-size: var(--text-xs);
  font-weight: 700;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
}
.process-col-body {
  padding: var(--space-2);
  min-height: 80px;
  flex: 1;
  transition: background 0.2s;
}
.process-col-body.drag-over { background: var(--color-primary-highlight); }


/* ===================== SPECIAL ZONES ===================== */

.special-zones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.zone-box {
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
}
.zone-box h3 {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
  font-weight: 600;
}

/* Zona de descanso (☕) */
.zone-box--break {
  border-color: var(--color-primary);
  border-style: dashed;
}
.zone-box--break h3 { color: var(--color-primary); }

/* Zona de absentismo */
.zone-box--absentismo { margin-bottom: var(--space-4); }
.zone-box--absentismo h3 { color: var(--color-error); }

.pool-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  min-height: 48px;
}
.pool-chips.drag-over {
  background: var(--color-primary-highlight);
  border-radius: var(--radius-lg);
}


/* ===================== OPERATOR CHIPS ===================== */

.operator-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-2);
  cursor: grab;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-interactive), transform var(--transition-interactive);
}
.operator-chip:hover  { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.operator-chip:active { cursor: grabbing; transform: scale(0.97); }

/* Clase añadida automáticamente por SortableJS al mover un elemento */
.sortable-ghost {
  opacity: 0.4;
  background: var(--color-primary-highlight);
  border: 1px dashed var(--color-primary);
}

.chip-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-primary-highlight);
  color: var(--color-primary);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.operator-chip--ett .chip-avatar {
  background: var(--color-ett-highlight);
  color: var(--color-ett);
}

.chip-info    { flex: 1; min-width: 0; }
.chip-name    { font-size: 10px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-ett     { font-size: 9px; color: var(--color-text-faint); }

.chip-timer {
  font-size: 9.5px;
  font-weight: 400;
  background: var(--color-primary);
  color: #fff;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}
.chip-timer.paused { background: var(--color-warning); }


/* ===================== CARDS ===================== */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  margin-bottom: var(--space-5);
}
/* Card sin padding interno (tabla a borde completo) */
.card--flush { padding: 0; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
  gap: var(--space-3);
}
.card-title { font-size: var(--text-sm); font-weight: 700; color: var(--color-text); }


/* ===================== TABLES ===================== */

.table { width: 100%; text-align: left; font-size: var(--text-xs); }

.table th {
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-offset);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
  white-space: nowrap;
}
.table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td      { background: var(--color-surface-offset); }

/* Celda de acciones con botones en fila */
.actions-cell {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}


/* ===================== FORMS ===================== */

.filters-row {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: var(--space-4);
}
.filters-row .form-input,
.filters-row .form-select { width: auto; min-width: 160px; }

.search-input { min-width: 220px; }

.form-group { margin-bottom: var(--space-4); }

.form-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.form-input,
.form-select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  transition: border-color var(--transition-interactive), box-shadow var(--transition-interactive);
}
.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-highlight);
}

/* Label para checkbox (sin uppercase, peso normal) */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}


/* ===================== BADGES ===================== */

.badge {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge.pending  { background: var(--color-warning-highlight); color: var(--color-warning); }
.badge.approved { background: var(--color-success-highlight); color: var(--color-success); }
.badge.rejected { background: var(--color-error-highlight);   color: var(--color-error); }


/* ===================== MODALS ===================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  z-index: 999;
  transition: opacity 0.2s;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--color-surface-2);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 500px;
  padding: var(--space-6);
  transform: translateY(12px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal h3 {
  font-size: var(--text-sm);
  font-weight: 700;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

/* Subtítulo informativo dentro del modal */
.modal-subtitle {
  font-size: var(--text-xs);
  margin-bottom: var(--space-4);
  color: var(--color-text-muted);
}

/* Fila de botones al pie del modal */
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-4);
}


/* ===================== NOTIFICATIONS (TOAST) ===================== */

.notifications-panel {
  position: absolute;
  top: var(--space-6);
  right: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 50;
  pointer-events: none;
}

.toast {
  background: var(--color-surface);
  border-left: 4px solid var(--color-primary);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-xs);
  max-width: 320px;
  animation: slideIn 0.3s ease;
  pointer-events: all;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}


/* ===================== THEME TOGGLE ===================== */

.theme-toggle {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  transition: all var(--transition-interactive);
}
.theme-toggle:hover { background: var(--color-surface-offset); color: var(--color-text); }


/* ===================== CALENDARIO ===================== */

.calendar-filter {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.calendar-popup {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  z-index: 200;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-4);
  min-width: 272px;
  animation: slideIn 0.15s ease;
}

/* Alinear al borde derecho si el filtro está al final de la fila */
.calendar-filter--right .calendar-popup {
  left: auto;
  right: 0;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.cal-title {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text);
}

.cal-nav {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition-interactive);
}
.cal-nav:hover { background: var(--color-surface-offset); color: var(--color-text); }

/* Grid 7 columnas */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-day-name {
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--color-text-faint);
  text-transform: uppercase;
  padding: var(--space-1) 0 var(--space-2);
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-interactive), color var(--transition-interactive);
  user-select: none;
  position: relative;
}
.cal-day:hover:not(.cal-day--empty):not(.cal-day--selected):not(.cal-day--range-start):not(.cal-day--range-end) {
  background: var(--color-surface-offset);
}

.cal-day--empty { cursor: default; pointer-events: none; }

.cal-day--today {
  color: var(--color-primary);
  font-weight: 700;
}
.cal-day--today::after {
  content: '';
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-primary);
}

/* Selección única */
.cal-day--selected {
  background: var(--color-primary) !important;
  color: #fff !important;
  font-weight: 700;
}
.cal-day--selected::after { display: none; }

/* Rango: inicio y fin */
.cal-day--range-start,
.cal-day--range-end {
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
  z-index: 1;
}
.cal-day--range-start::after,
.cal-day--range-end::after { display: none; }

/* Días dentro del rango */
.cal-day--in-range {
  background: var(--color-primary-highlight);
  color: var(--color-primary);
  border-radius: 0;
}

/* Bordes redondeados solo en los extremos del rango */
.cal-day--range-start { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.cal-day--range-end   { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.cal-day--range-start.cal-day--range-end { border-radius: var(--radius-md); } /* mismo día */

/* Pie del calendario */
.cal-footer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.cal-hint {
  flex: 1;
  font-size: 10px;
  color: var(--color-text-muted);
}

/* Botón de activación del calendario */
.cal-trigger-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ===================== ACCESSIBILITY ===================== */

/* Foco visible personalizado (reemplaza el outline por defecto del navegador) */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Elemento solo visible para lectores de pantalla */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* ===================== FECHA EN TOPBAR ===================== */

.topbar-date {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.topbar-separator {
  color: var(--color-text-faint);
  font-size: var(--text-xs);
}

/* Reducir gap en topbar-right para que quede compacto */
.topbar-right { gap: var(--space-3); }


/* ===================== ESTADO PENDIENTE EN REGISTROS ===================== */

/* Fila con solicitud pendiente */
.row--pending td {
  background: var(--color-warning-highlight) !important;
}
[data-theme="dark"] .row--pending td {
  background: color-mix(in srgb, var(--color-warning-highlight) 40%, transparent) !important;
}

/* Badge de estado pendiente (distinto al badge normal .pending) */
.badge--pending {
  background: var(--color-warning-highlight);
  color:      var(--color-warning);
  padding:    2px 8px;
  border-radius: var(--radius-full);
  font-size:  9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}


/* ===================== MODAL DE INFORMACIÓN ===================== */

.modal-info-body {
  margin-bottom: var(--space-4);
}

.info-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-divider);
  font-size: var(--text-xs);
}
.info-row:last-child { border-bottom: none; }

.info-label {
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: 9px;
  min-width: 130px;
  flex-shrink: 0;
}


/* ===================== PAGINACIÓN ===================== */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-divider);
}

.pagination-info {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.pagination .btn[disabled] {
  opacity: .35;
  pointer-events: none;
}


/* ===================== TURNO AUTOMÁTICO: PANEL ===================== */

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 21px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-interactive);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 15px;
  height: 15px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition-interactive);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.toggle-switch input:checked + .toggle-slider            { background: var(--color-primary); }
.toggle-switch input:checked + .toggle-slider::before    { transform: translateX(17px); }
.toggle-switch input:disabled + .toggle-slider           { opacity: .45; cursor: not-allowed; }

/* Fila de horario (inicio / fin) */
.sched-times {
  display: flex;
  gap: var(--space-6);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}
.sched-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 180px;
}
.sched-field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.sched-field .form-input {
  width: 130px;
  font-variant-numeric: tabular-nums;
  font-size: var(--text-base);
  font-weight: 600;
}
.sched-field .form-input:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* Timeline visual */
.sched-timeline {
  margin-bottom: var(--space-5);
}
.tl-bar {
  position: relative;
  height: 32px;
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  overflow: hidden;
}
/* Segmentos de trabajo (verde) */
.tl-work {
  position: absolute;
  top: 6px;
  height: 20px;
  background: var(--color-success);
  opacity: .85;
  border-radius: var(--radius-sm);
  transition: width .3s, left .3s;
}
/* Segmentos de pausa (ámbar) */
.tl-break {
  position: absolute;
  top: 6px;
  height: 20px;
  background: var(--color-warning);
  opacity: .85;
  border-radius: var(--radius-sm);
  transition: width .3s, left .3s;
}
/* Línea de hora actual */
.tl-now {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--color-text);
  opacity: .5;
  z-index: 2;
}
.tl-now::after {
  content: '▼';
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  color: var(--color-text);
  opacity: .7;
}
/* Marcas de hora */
.tl-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid var(--color-border);
  pointer-events: none;
}
.tl-tick span {
  position: absolute;
  bottom: 1px;
  left: 2px;
  font-size: 8px;
  color: var(--color-text-faint);
  white-space: nowrap;
}
/* Leyenda */
.tl-legend {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.tl-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.tl-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.tl-legend-dot--work  { background: var(--color-primary); }
.tl-legend-dot--break { background: var(--color-warning); }
.tl-legend-dot--now   { background: var(--color-text); opacity: .5; }

/* Cabecera de pausas */
.sched-breaks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

/* Lista de pausas */
.sched-breaks-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.break-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}
.break-row-sep {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}


/* ===================== ANALÍTICA: FILA TOTAL ===================== */

.analytics-total-row td {
  background: var(--color-surface-offset) !important;
  border-top: 2px solid var(--color-border);
  font-weight: 600;
}


/* ===================== ANALÍTICA: KPI CARDS ===================== */

.analytics-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.analytics-kpi-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-interactive), transform var(--transition-interactive);
}

.analytics-kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.analytics-kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.analytics-kpi-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.analytics-kpi-value {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

/* Valor de proceso: permite 2 líneas con truncado */
.analytics-kpi-value--proc {
  font-size: var(--text-xs);
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
  flex-wrap: unset;
}

.analytics-kpi-label {
  font-size: 10px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
}

.analytics-trend {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-full);
}
.analytics-trend.up   { background: var(--color-success-highlight); color: var(--color-success); }
.analytics-trend.down { background: var(--color-error-highlight);   color: var(--color-error); }


/* ===================== ANALÍTICA: TABLA ORDENABLE ===================== */

.analytics-th-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background var(--transition-interactive);
}
.analytics-th-sortable:hover { background: var(--color-surface-2); }

.sort-arrow {
  display: inline-block;
  font-size: 10px;
  color: var(--color-primary);
  margin-left: 3px;
  width: 10px;
}

.analytics-proc-badge {
  display: inline-block;
}

/* Celda barra de distribución */
.analytics-bar-cell {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 120px;
}

.analytics-inline-bar {
  flex: 1;
  height: 8px;
  background: var(--color-surface-offset);
  border-radius: var(--radius-full);
  overflow: hidden;
  min-width: 60px;
}

.analytics-inline-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.analytics-bar-pct {
  font-size: 10px;
  color: var(--color-text-muted);
  white-space: nowrap;
  min-width: 36px;
  text-align: right;
}


/* ===================== ANALÍTICA: GRÁFICO DE BARRAS DIARIO ===================== */

.analytics-bar-chart-wrap {
  padding: 0 var(--space-4) var(--space-4);
}

.analytics-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  height: 200px;
  padding-bottom: var(--space-5);
  position: relative;
}

/* Cada columna de día */
.analytics-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  position: relative;
}
.analytics-bar-col.weekend { opacity: 0.55; }
.analytics-bar-col.today .analytics-bar-label {
  color: var(--color-primary);
  font-weight: 700;
}

/* Valor numérico encima de la barra */
.analytics-bar-value {
  font-size: 9px;
  color: var(--color-text-muted);
  font-weight: 600;
  white-space: nowrap;
  min-height: 14px;
  text-align: center;
}

/* Contenedor de ambas barras (altura fija definida por JS via style=) */
.analytics-bar-stack {
  width: 100%;
  max-width: 52px;
  position: relative; /* necesario para posicionar abs las barras hija */
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

/* Barra semana anterior (fantasma, posición absoluta desde abajo) */
.analytics-bar-prev {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: height 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Barra semana actual (encima, posición relativa - se apila al flex) */
.analytics-bar-fill {
  position: absolute;
  bottom: 0;
  left: 8%;
  right: 8%;
  background: var(--color-primary);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: height 0.45s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: visible;
}
.analytics-bar-fill.today {
  background: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-highlight);
}

/* Flecha de tendencia dentro de la barra */
.analytics-bar-trend {
  position: absolute;
  top: -16px;
  font-size: 9px;
  font-weight: 700;
}
.analytics-bar-trend.up   { color: var(--color-success); }
.analytics-bar-trend.down { color: var(--color-error); }

/* Label de día debajo */
.analytics-bar-label {
  font-size: 10px;
  color: var(--color-text-muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Leyenda del gráfico */
.analytics-bar-legend {
  display: flex;
  gap: var(--space-5);
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-divider);
}
.analytics-bar-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 11px;
  color: var(--color-text-muted);
}
.analytics-bar-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.analytics-bar-legend-dot.current { background: var(--color-primary); }
.analytics-bar-legend-dot.prev    { background: var(--color-border); }

/* Botones de período activos */
.analytics-bar-period-btn.active {
  background: var(--color-primary-highlight);
  color: var(--color-primary);
  border-color: var(--color-primary);
}



/* ===================== GRÁFICOS DE DONA ===================== */

/* Grid de 4 tarjetas */
.pie-charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-5);
  padding: 0 var(--space-5) var(--space-5);
}

/* Tarjeta individual */
.pie-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  transition: box-shadow var(--transition-interactive), transform var(--transition-interactive);
}
.pie-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.pie-card-title {
  font-size: 10px;
  font-weight: 800;
  text-align: center;
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.pie-card-sub {
  font-size: 10px;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: -6px;
}

.pie-chart-wrap {
  line-height: 0;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.15));
}

.pie-empty {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-align: center;
  padding: var(--space-5) 0;
}

/* Leyenda */
.pie-legend {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: var(--space-2);
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-2);
}

.pie-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 10.5px;
}

.pie-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  flex-shrink: 0;
}

.pie-legend-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text-muted);
}

.pie-legend-val {
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}


/* ===================== ZONA ESTRUCTURA ===================== */

.zone-box--estructura {
  border-color: #2e7d32 !important;
  background: rgba(46, 125, 50, 0.06) !important;
}

.zone-box--estructura h3 {
  color: #2e7d32 !important;
}

[data-theme="dark"] .zone-box--estructura {
  border-color: #66bb6a !important;
  background: rgba(102, 187, 106, 0.08) !important;
}

[data-theme="dark"] .zone-box--estructura h3 {
  color: #81c784 !important;
}

/* Contenedor horizontal de zonas inferiores (Absentismo + Estructura) */
.bottom-zones {
  display: flex;
  gap: var(--space-4);
  margin-top: var(--space-4);
  flex-wrap: wrap;
}

.bottom-zones .zone-box {
  flex: 1;
  min-width: 220px;
}


/* ===================== PLANTILLA DE TURNO: CHIPS ===================== */

/* Chip de plantilla: apariencia diferenciada (borde punteado) */
.operator-chip--template {
  border: 2px dashed var(--color-primary) !important;
  opacity: 0.9;
  background: var(--color-surface-offset) !important;
}

.operator-chip--template .chip-avatar {
  background: transparent !important;
  border: 2px solid var(--color-primary);
  color: var(--color-primary);
}

.operator-chip--template.operator-chip--ett {
  border-color: var(--color-ett) !important;
}

.operator-chip--template.operator-chip--ett .chip-avatar {
  border-color: var(--color-ett);
  color: var(--color-ett);
}


/* ===================== MULTI-SELECT DROPDOWN ===================== */

.ms-dropdown {
  position: relative;
  display: inline-block;
  min-width: 160px;
}

.ms-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  user-select: none;
  font-size: var(--text-sm);
}

.ms-chevron {
  flex-shrink: 0;
  transition: transform 0.2s ease;
  opacity: 0.55;
}

.ms-dropdown.ms-open .ms-chevron {
  transform: rotate(180deg);
}

.ms-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 220;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  max-width: 320px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: msSlideIn 0.14s cubic-bezier(0.16, 1, 0.3, 1);
}

.ms-panel.ms-panel--visible {
  display: flex;
}

@keyframes msSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ms-search {
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-divider);
}

.ms-search input {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  font-size: 12px;
  font-family: var(--font-body);
  outline: none;
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.ms-search input:focus {
  border-color: var(--color-primary);
}

.ms-quick-actions {
  display: flex;
  gap: 6px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--color-divider);
}

.ms-quick-actions button {
  font-size: 11px;
  font-family: var(--font-body);
  padding: 3px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-bg);
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-weight: 500;
}

.ms-quick-actions button:hover {
  background: var(--color-primary-highlight);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.ms-options {
  overflow-y: auto;
  max-height: 220px;
  padding: 4px 0;
}

.ms-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 13px;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--color-text);
  transition: background 0.12s;
  line-height: 1.3;
}

.ms-option:hover {
  background: var(--color-primary-highlight);
}

.ms-option input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--color-primary);
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.ms-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms-empty {
  padding: 14px 13px;
  font-size: 12px;
  color: var(--color-text-faint);
  text-align: center;
}

.ms-label-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.ms-trigger.ms-has-selection {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-primary-highlight);
}
