/* ═══════════════════════════════════════════════════════════════
   PilotControl — app.css
   Complementa los estilos embebidos en index.php.
   Tokens de layout, componentes de UI y responsive.
   ═══════════════════════════════════════════════════════════════ */

/* ─── Print (conservado del original) ─────────────────────── */
@media print {
  #sidebar, #topbar, #toast-container, #loader, #login-page { display: none !important; }
  #main-content { margin: 0 !important; padding: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
  .pc-card { border: 1px solid #ddd !important; background: #fff !important; }
  .pc-table { font-size: .8rem; }
}

/* ═══════════════════════════════════════════════════════════════
   0. CFG / PARAM TILES — cuadrícula 4 columnas compacta
   ═══════════════════════════════════════════════════════════════ */
.cfg-tile {
  cursor: grab;
  user-select: none;
  padding: .85rem .95rem;
  transition: border-color .18s, transform .18s, box-shadow .18s;
}
.cfg-tile:active { cursor: grabbing; }

/* Fila superior: icono + grip */
.cfg-tile-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: .55rem;
}
.cfg-tile-icon {
  width: 38px; height: 38px;
  border-radius: 9px;
  border: 1px solid transparent;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 1.05rem; /* icon size vía Bootstrap Icons */
}
.cfg-tile-grip {
  color: var(--text-muted);
  opacity: .3;
  font-size: .9rem;
  margin-top: 2px;
}

/* Textos */
.cfg-tile-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .82rem;
  line-height: 1.25;
  margin-bottom: .35rem;
  color: var(--text-light);
}
.cfg-tile-desc {
  font-size: .72rem;
  color: var(--text-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Hover: borde de color + micro-elevación + highlight de ícono */
.cfg-tile:hover .cfg-tile-grip { opacity: .55; }

/* Light theme */
[data-theme="light"] .cfg-tile-title { color: #1a2e42; }
[data-theme="light"] .cfg-tile-desc  { color: #56789a; }

/* Responsive: en móvil ≤480px caben 2 columnas cómodamente */
@media (max-width: 480px) {
  .cfg-tile { padding: .75rem .8rem; }
  .cfg-tile-icon { width: 34px; height: 34px; font-size: .95rem; }
  .cfg-tile-title { font-size: .78rem; }
  .cfg-tile-desc { font-size: .68rem; -webkit-line-clamp: 2; }
}

/* ═══════════════════════════════════════════════════════════════
   1. SECTION HEADERS  — jerarquía visual consistente
   ═══════════════════════════════════════════════════════════════ */
.pc-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.pc-section-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: .05em;
  line-height: 1.2;
  margin: 0;
}
.pc-section-subtitle {
  font-size: .73rem;
  color: var(--text-muted);
  margin-top: .2rem;
}
.pc-section-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   2. KPI GRID  — auto-fill con mínimo fijo, sin Bootstrap row
   ═══════════════════════════════════════════════════════════════ */
.pc-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.kpi-icon {
  border-radius: var(--radius-md);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* dimensiones ya definidas en index.php: 48px × 48px */
}
/* Mejor separación entre icono y texto */
.kpi-card > .kpi-icon + div { min-width: 0; }

/* ═══════════════════════════════════════════════════════════════
   3. MONITOR — encabezado de columnas
   ═══════════════════════════════════════════════════════════════ */
.mon-col-hd {
  display: grid;
  grid-template-columns: var(--mon-grid);
  gap: 0;
  padding: 0 2px;
  margin-bottom: 4px;
  border-bottom: 2px solid var(--navy-border);
}
.mon-col-hd > span {
  font-size: .72rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: .4rem .65rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mon-col-hd > span.col-eta { color: var(--teal);  font-weight: 700; }
.mon-col-hd > span.col-etd { color: var(--gold);  font-weight: 700; }

/* ═══════════════════════════════════════════════════════════════
   4. LEYENDA  — componente reutilizable
   ═══════════════════════════════════════════════════════════════ */
.pc-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  font-size: .67rem;
  color: var(--text-muted);
  padding: .3rem .4rem;
  border-radius: var(--radius-sm);
}
.pc-legend-item {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  white-space: nowrap;
}
.pc-legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   5. FILTER BAR  — barra de filtros semántica
   ═══════════════════════════════════════════════════════════════ */
.pc-filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  overflow: hidden;
}
.pc-filter-cell {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem .75rem;
  border-right: 1px solid var(--navy-border);
  flex-shrink: 0;
}
.pc-filter-cell.flex-grow { flex: 1; min-width: 130px; }
.pc-filter-cell:last-child { border-right: none; margin-left: auto; }
.pc-filter-cell > i { color: var(--text-muted); font-size: .82rem; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════════
   6. TABLA  — densidad y alineación visual
   ═══════════════════════════════════════════════════════════════ */
.pc-table thead th {
  padding: .48rem .75rem;
  font-size: .71rem;
}
.pc-table tbody td {
  padding: .44rem .75rem;
  line-height: 1.4;
}
/* Columna numérica alineada a la derecha */
.pc-table .col-num { text-align: right; font-family: var(--font-mono); }
/* Columna de acciones centrada */
.pc-table .col-actions { text-align: center; white-space: nowrap; }
/* Elipsis en textos largos de tabla */
.pc-table .col-text { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ═══════════════════════════════════════════════════════════════
   7. FORMULARIOS  — mejor jerarquía label/input
   ═══════════════════════════════════════════════════════════════ */
.form-label {
  font-size: .82rem;
  font-weight: 500;
  margin-bottom: .32rem;
  letter-spacing: .01em;
}
/* Grupo de campos: separación uniforme */
.pc-field-group { margin-bottom: .9rem; }
.pc-field-group:last-child { margin-bottom: 0; }

/* ═══════════════════════════════════════════════════════════════
   8. DATA FIELDS (detail view)  — celdas clave:valor
   ═══════════════════════════════════════════════════════════════ */
.pc-data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .6rem;
}
.pc-data-cell {
  background: rgba(255,255,255,.025);
  border: 1px solid var(--navy-border);
  border-radius: var(--radius-sm);
  padding: .55rem .75rem;
  min-width: 0;
}
.pc-data-label {
  font-size: .63rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pc-data-value {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.3;
  word-break: break-word;
}
.pc-data-value.mono { font-family: var(--font-mono); }
.pc-data-value.accent { color: var(--teal); }

/* ═══════════════════════════════════════════════════════════════
   9. CARDS DE INICIO  — grid adaptativo
   ═══════════════════════════════════════════════════════════════ */
.inicio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: .85rem;
}
.inicio-card {
  /* Refuerza el gap entre icono y cuerpo */
  gap: 1rem;
  border-radius: var(--radius-lg);
}
.inicio-card-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  font-size: 1.5rem;
}
.inicio-card-body { overflow: hidden; }
.inicio-card-label { font-size: .98rem; }

/* Light mode overrides */
[data-theme="light"] .pc-data-cell {
  background: #f8fafc;
  border-color: var(--navy-border);
}
[data-theme="light"] .pc-data-label { color: #56789a; }
[data-theme="light"] .pc-data-value { color: #1a2e42; }

/* ═══════════════════════════════════════════════════════════════
   10. PILREP  — campos de hora en grid uniforme
   ═══════════════════════════════════════════════════════════════ */
.pilrep-time-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  margin-top: .5rem;
}
.pilrep-time-grid .pilrep-field {
  flex: 1 1 120px;
  min-width: 100px;
}

/* ═══════════════════════════════════════════════════════════════
   11. WIZARD  — espaciado interno del formulario de servicio
   ═══════════════════════════════════════════════════════════════ */
.wiz-section {
  background: rgba(255,255,255,.025);
  border: 1px solid var(--navy-border);
  border-radius: var(--radius-md);
  padding: .85rem 1rem;
  margin-bottom: .85rem;
}
.wiz-section-title {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .6rem;
  display: flex;
  align-items: center;
  gap: .35rem;
}

/* ═══════════════════════════════════════════════════════════════
   12. EMPTY STATE  — espaciado y tamaño
   ═══════════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 3.5rem 2rem;
  color: var(--text-muted);
}
.empty-state i {
  font-size: 2.75rem;
  margin-bottom: .9rem;
  opacity: .35;
  display: block;
}
.empty-state p { font-size: .875rem; line-height: 1.6; }
.empty-state .empty-action {
  margin-top: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
}

/* ═══════════════════════════════════════════════════════════════
   13. BADGE ESTADO  — tamaño y legibilidad mejoradas
   ═══════════════════════════════════════════════════════════════ */
.badge-estado {
  font-size: .67rem;
  padding: .3em .75em;
  letter-spacing: .06em;
}

/* ═══════════════════════════════════════════════════════════════
   14. PAGINACIÓN  — centrada y con separación de contexto
   ═══════════════════════════════════════════════════════════════ */
.pc-pagination {
  padding: .9rem 0 .4rem;
  gap: .4rem;
}
.pc-page-btn {
  width: 30px;
  height: 30px;
  font-size: .78rem;
}

/* ═══════════════════════════════════════════════════════════════
   15. RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

/* Tablet → padding reducido */
@media (max-width: 1024px) {
  .pc-kpi-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}

/* Mobile (≤ 768px) */
@media (max-width: 768px) {
  /* Main content */
  #main-content { padding: .9rem .8rem; }

  /* Monitor: oculta columna header y cambia grid a stack */
  .mon-col-hd { display: none; }
  .mon-row {
    display: flex !important;
    flex-direction: column;
    min-height: unset;
    gap: 0;
  }
  .mon-cell {
    border-right: none;
    padding: .3rem .75rem;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: .5rem;
  }
  .mon-cell .mon-cell-label { min-width: 80px; }

  /* KPI grid */
  .pc-kpi-grid { grid-template-columns: repeat(2, 1fr); gap: .65rem; }
  .kpi-card { padding: .85rem 1rem; gap: .75rem; }
  .kpi-val  { font-size: 1.65rem; }
  .kpi-icon { width: 40px !important; height: 40px !important; font-size: 1.1rem !important; }

  /* Cards */
  .pc-card-header { padding: .75rem 1rem; font-size: .95rem; }
  .pc-card-body   { padding: .9rem 1rem; }

  /* inicio */
  .inicio-card { padding: .9rem 1rem; gap: .8rem; }
  .inicio-card-icon { width: 48px !important; height: 48px !important; font-size: 1.3rem !important; }

  /* Filter bar: apila en 2 columnas */
  .pc-filter-cell { min-width: 46%; }

  /* Data grid */
  .pc-data-grid { grid-template-columns: repeat(2, 1fr); }

  /* Modales */
  .modal-body { padding: 1rem !important; }
  .modal-footer { padding: .75rem 1rem !important; }
}

/* Mobile pequeño (≤ 480px) */
@media (max-width: 480px) {
  #main-content { padding: .75rem .6rem; }
  .pc-kpi-grid { grid-template-columns: 1fr 1fr; gap: .5rem; }
  .kpi-card { padding: .75rem .85rem; }
  .kpi-val  { font-size: 1.45rem; }
  .inicio-grid { grid-template-columns: 1fr; }
  .pc-data-grid { grid-template-columns: 1fr; }
  .pc-section-header { flex-direction: column; align-items: stretch; }
  .pc-section-actions { justify-content: flex-end; }
}

/* ═══════════════════════════════════════════════════════════════
   16. LIGHT THEME  — overrides para nuevos componentes
   ═══════════════════════════════════════════════════════════════ */
[data-theme="light"] .mon-col-hd {
  border-bottom-color: var(--navy-border);
}
[data-theme="light"] .mon-col-hd > span { color: #56789a; }
[data-theme="light"] .pc-legend { color: #56789a; }
[data-theme="light"] .pc-filter-cell { border-right-color: var(--navy-border); }
[data-theme="light"] .wiz-section {
  background: #f8fafc;
  border-color: var(--navy-border);
}
[data-theme="light"] .wiz-section-title { color: #56789a; }
[data-theme="light"] .kpi-card { box-shadow: 0 1px 6px rgba(0,0,0,.06); }
[data-theme="light"] .pc-data-cell { background: #ffffff; border-color: #bfcfdf; }
[data-theme="light"] .empty-state { color: #8aabca; }

/* ═══════════════════════════════════════════════════════════════
   17. COLA DE PRIORIDAD — PILOTOS  (modal)
   ═══════════════════════════════════════════════════════════════ */

/* Grid de 3 columnas (T1 / T2 / T3) */
.pilq-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
}
.pilq-col { display: flex; flex-direction: column; min-width: 0; }
.pilq-col-sep { border-left: 1px solid var(--navy-border); }

/* Header de cada columna */
.pilq-col-hd {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .7rem .9rem;
  border-bottom: 2px solid transparent;
  background: rgba(255,255,255,.02);
}
.pilq-tier-badge {
  font-family: var(--font-display);
  font-size: .92rem; font-weight: 800;
  letter-spacing: .05em;
  padding: .22rem .6rem;
  border-radius: 7px;
  border: 1px solid transparent;
  flex-shrink: 0;
  margin-top: 1px;
}
.pilq-tier-label {
  font-size: .78rem; font-weight: 700;
  color: var(--text-light);
  line-height: 1.2;
}
.pilq-tier-sub {
  font-size: .65rem;
  color: var(--text-muted);
  margin-top: 1px;
}
.pilq-tier-count {
  font-size: .67rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Lista de pilotos en cada columna */
.pilq-col-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: .4rem .45rem;
  max-height: 240px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--navy-border) transparent;
}
.pilq-col-body::-webkit-scrollbar { width: 3px; }
.pilq-col-body::-webkit-scrollbar-track { background: transparent; }
.pilq-col-body::-webkit-scrollbar-thumb { background: var(--navy-border); border-radius: 2px; }

/* Fila de un piloto */
.pilq-pilot-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: .4rem;
  padding: .32rem .45rem;
  border-radius: 6px;
  transition: background .1s;
  cursor: default;
  min-width: 0;
}
.pilq-pilot-row:hover { background: rgba(255,255,255,.05); }
.pilq-dim { opacity: .45; }
.pilq-dim:hover { opacity: .65; }

.pilq-status-dot { font-size: .72rem; flex-shrink: 0; }

.pilq-pilot-name {
  font-size: .78rem; font-weight: 600;
  color: var(--text-light);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.pilq-pilot-meta {
  display: flex; flex-direction: column;
  align-items: flex-end; gap: 0; flex-shrink: 0;
}
.pilq-cat {
  font-size: .6rem; color: var(--text-muted);
  white-space: nowrap;
}
.pilq-count {
  font-family: var(--font-mono);
  font-size: .65rem; font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}
.pilq-zero { color: #22d48a !important; }
.pilq-empty {
  font-size: .72rem; color: var(--text-muted);
  text-align: center; padding: 1.2rem .5rem;
  opacity: .55;
}

/* Footer con leyenda */
.pilq-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .55rem 1rem;
  border-top: 1px solid var(--navy-border);
  background: rgba(255,255,255,.015);
}
.pilq-legend {
  display: flex; align-items: center;
  flex-wrap: wrap; gap: .5rem .9rem;
  font-size: .67rem; color: var(--text-muted);
}
.pilq-legend i { font-size: .65rem; }

/* Spinner en el botón de refresh */
@keyframes pilq-spin { to { transform: rotate(360deg); } }
.pilq-spin { animation: pilq-spin .65s linear infinite; }

/* Responsive: columnas apiladas en móvil */
@media (max-width: 768px) {
  .pilq-grid { grid-template-columns: 1fr; }
  .pilq-col-sep { border-left: none; border-top: 1px solid var(--navy-border); }
  .pilq-col-body { max-height: 160px; }
  .pilq-footer { flex-direction: column; align-items: flex-start; }
}

/* Light theme */
[data-theme="light"] .pilq-header:hover   { background: rgba(0,0,0,.02); }
[data-theme="light"] .pilq-col-hd         { background: rgba(0,0,0,.02); }
[data-theme="light"] .pilq-pilot-name     { color: #1a2e42; }
[data-theme="light"] .pilq-pilot-row:hover{ background: rgba(0,0,0,.04); }
[data-theme="light"] .pilq-footer         { background: rgba(0,0,0,.015); }
