/* ================================================================
   ProAllocations · app.css  — Estilos globales compartidos
   Todas las vistas deben incluir este archivo después de Tailwind.
   ================================================================ */

/* ── Alpine ──────────────────────────────────────────────────────── */
[x-cloak] {
  display: none !important;
}

/* ── Inputs ──────────────────────────────────────────────────────── */
.input-f {
  width: 100%;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 0.875rem;
  color: #111827;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.input-f:focus {
  outline: none;
  border-color: #f15a22;
  box-shadow: 0 0 0 3px rgba(241, 90, 34, 0.1);
  background: #fff;
}
.input-f:read-only,
.input-f:disabled {
  background: #f3f4f6;
  color: #6b7280;
  cursor: default;
}

/* ── Labels ──────────────────────────────────────────────────────── */
.lbl {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #4b5563;
  margin-bottom: 5px;
}

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 14px;
  padding: 20px 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* ── Section title con borde degradado ───────────────────────────── */
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #111827;
  padding-bottom: 12px;
  margin-bottom: 20px;
  border-bottom: 2px solid transparent;
  border-image: linear-gradient(
      to right,
      #f15a22 0%,
      #ffceb8 40%,
      transparent 100%
    )
    1;
}
.step-badge {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #f15a22;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Estado badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge-pending {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
}
.badge-approved {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
.badge-rejected {
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
}

/* ── Toggle switch ───────────────────────────────────────────────── */
.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: #d1d5db;
  transition: background 0.2s;
}
.toggle input:checked + .toggle-track {
  background: #f15a22;
}
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}
.toggle input:checked ~ .toggle-thumb {
  transform: translateX(18px);
}

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  background: #fff;
  border-radius: 20px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  animation: modalIn 0.2s ease;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
@keyframes modalIn {
  from {
    transform: scale(0.96);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ── Toast ───────────────────────────────────────────────────────── */
/* El toast se posiciona con clases Tailwind. Solo definimos la animación. */
@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ── Topbar back-button + title (patrón común entre vistas) ─────── */
.topbar {
  background: #fff;
  border-bottom: 1px solid #f3f4f6;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 30;
}

/* ── Tabla base ──────────────────────────────────────────────────── */
.tbl-row {
  transition: background 0.1s;
}
.tbl-row:hover {
  background: #fafafa;
}
.tbl-row.selected {
  background: #fff4ee;
}

/* ── Checkbox estilizado ─────────────────────────────────────────── */
.custom-cb {
  width: 17px;
  height: 17px;
  border-radius: 5px;
  border: 2px solid #d1d5db;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
  position: relative;
}
.custom-cb:checked {
  background: #f15a22;
  border-color: #f15a22;
}
.custom-cb:checked::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 0px;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-left: none;
  border-top: none;
  transform: rotate(40deg);
}

/* ── Filtros grid — aprobaciones ─────────────────────────────────────── */
.grid-filtros {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr auto;
    gap: 12px;
    align-items: end;
}
@media (max-width: 768px) { .grid-filtros { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .grid-filtros { grid-template-columns: 1fr; } }

/* ── Búsqueda responsive ─────────────────────────────────────────────── */
.search-box { width: 200px; }
@media (max-width: 500px) {
    .search-box { width: 130px; }
    .search-box::placeholder { font-size: 0.7rem; }
}

/* ── Bulk action bar ─────────────────────────────────────────────────── */
.bulk-bar {
    position: sticky;
    bottom: 16px;
    left: 0; right: 0;
    z-index: 40;
    background: #fff;
    border-radius: 14px;
    border: 1px solid #E5E7EB;
    border-left: 4px solid #F15A22;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    box-shadow: 0 8px 32px rgba(0,0,0,.10);
    animation: slideUp .2s ease;
}
@media (max-width: 500px) {
    .bulk-bar { flex-direction: column; align-items: flex-start; gap: 10px; }
}

/* ── Panel lateral detalle ───────────────────────────────────────────── */
.detail-panel {
    position: fixed;
    top: 0; right: 0;
    height: 100vh;
    width: 100%; max-width: 480px;
    background: #fff;
    box-shadow: -8px 0 40px rgba(0,0,0,.12);
    z-index: 50;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform .25s ease;
}
.detail-panel.open { transform: translateX(0); }
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 49;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}
.overlay.open { opacity: 1; pointer-events: auto; }

/* ── Campos dentro del panel detalle ─────────────────────────────────── */
.det-field { margin-bottom: 14px; }
.det-label {
    font-size: .7rem;
    font-weight: 600;
    color: #9CA3AF;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 3px;
}
.det-value { font-size: .875rem; color: #111827; font-weight: 500; }

/* ── Login: fondo cuadrícula ─────────────────────────────────────────── */
.grid-pattern {
    background-color: #F2F2F2;
    background-image:
        linear-gradient(rgba(241,90,34,0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(241,90,34,0.07) 1px, transparent 1px);
    background-size: 36px 36px;
}

/* ── Login: input con foco naranja ───────────────────────────────────── */
.input-brand { transition: border-color .2s, box-shadow .2s; }
.input-brand:focus {
    outline: none;
    border-color: #F15A22;
    box-shadow: 0 0 0 3px rgba(241,90,34,0.15);
}

/* ── Login: borde decorativo lateral del panel derecho ───────────────── */
.card-accent { position: relative; }
.card-accent::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: linear-gradient(to bottom, #F15A22, #F7A07A);
    border-radius: 4px 0 0 4px;
}

/* ── Sidebar nav links — abierto ─────────────────────────────────────── */
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: .875rem;
    color: #6B7280;
    transition: all .15s;
    cursor: pointer;
    border-left: 3px solid transparent;
    margin: 1px 8px;
    text-decoration: none;
}
.nav-link:hover  { background: #FFF4EE; color: #F15A22; }
.nav-link.active {
    background: #FFF4EE;
    color: #F15A22;
    border-left-color: #F15A22;
    font-weight: 600;
}

/* ── Sidebar nav icons — cerrado (solo icono centrado) ───────────────── */
.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border-radius: 8px;
    width: 40px;
    color: #9CA3AF;
    transition: all .15s;
    cursor: pointer;
    margin: 2px auto;
    text-decoration: none;
}
.nav-icon:hover  { background: #FFF4EE; color: #F15A22; }
.nav-icon.active { background: #FFF4EE; color: #F15A22; }

/* ── KPI card hover ──────────────────────────────────────────────────── */
.kpi-card { transition: box-shadow .2s, transform .2s; }
.kpi-card:hover {
    box-shadow: 0 8px 24px rgba(241,90,34,.10);
    transform: translateY(-2px);
}

/* ══════════════════════════════════════════════════════════════════════
   Imputaciones · crear.php
   ══════════════════════════════════════════════════════════════════════ */

/* ── Botones turno ───────────────────────────────────────────────────── */
.badge-turno {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    border-radius: 9px;
    font-weight: 700;
    font-size: .85rem;
    cursor: pointer;
    border: 2px solid #E5E7EB;
    transition: all .15s;
    background: #fff;
}
.badge-turno:hover  { border-color: #F15A22; color: #F15A22; }
.badge-turno.active { border-color: #F15A22; background: #F15A22; color: #fff; }

/* ── Filas de tabla de máquinas ─────────────────────────────────────── */
.machine-row { cursor: pointer; transition: background .1s; }
.machine-row:hover    { background: #FFF4EE !important; }
.machine-row.selected { background: #FFF4EE; }

/* ── Selector de planta ─────────────────────────────────────────────── */
.planta-btn {
    flex: 1;
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    background: #fff;
}
.planta-btn:hover { border-color: #F15A22; background: #FFF4EE; }
.planta-btn.active {
    border-color: #F15A22;
    background: #FFF4EE;
    box-shadow: 0 0 0 3px rgba(241,90,34,.1);
}
.planta-btn.active .planta-name { color: #F15A22; }

/* ── Scroll horizontal en móvil ─────────────────────────────────────── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Turno: full width en móvil ─────────────────────────────────────── */
.turno-group { display: inline-flex; }

/* ── Grids responsive — imputaciones ────────────────────────────────── */
/* NIP · Nombre · Fecha */
.grid-operario   { display: grid; grid-template-columns: 90px 1fr 150px; gap: 12px; }
/* Ejercicio · Serie · HR · Botón */
.grid-busqueda   { display: grid; grid-template-columns: 1fr 1fr 2fr auto; gap: 12px; align-items: end; }
/* Máquina seleccionada */
.grid-maquina    { display: grid; grid-template-columns: 110px 1fr 110px 130px; gap: 12px; }
/* Cantidades · Total · Duración */
.grid-produccion { display: grid; grid-template-columns: 1fr 1fr 130px 130px; gap: 12px; }

@media (max-width: 768px) {
    .grid-maquina { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
    .grid-operario   { grid-template-columns: 1fr 1fr; }
    .grid-busqueda   { grid-template-columns: 1fr 1fr; }
    .grid-produccion { grid-template-columns: 1fr 1fr; }
    .grid-maquina    { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
    .grid-operario  { grid-template-columns: 1fr; }
    .grid-busqueda  { grid-template-columns: 1fr; }
    .turno-group    { display: flex; width: 100%; }
    .turno-group button { flex: 1; }
}

/* ══════════════════════════════════════════════════════════════════════
   Plantas · Componentes reutilizables (modal, toggle, avatar)
   ══════════════════════════════════════════════════════════════════════ */

/* ── Modal backdrop + box ───────────────────────────────────────────── */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 40;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.modal-box {
    background: #fff; border-radius: 20px;
    width: 100%; max-width: 480px;
    box-shadow: 0 20px 60px rgba(0,0,0,.18);
    animation: modalIn .2s ease;
    max-height: 90vh;
    overflow-y: auto;
}
/* Variante small para modales de confirmación */
.modal-box.modal-sm { max-width: 360px; }

@keyframes modalIn {
    from { transform: scale(.96); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

/* ── Toggle switch ──────────────────────────────────────────────────── */
.toggle {
    position: relative; width: 40px; height: 22px;
    flex-shrink: 0; cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
    position: absolute; inset: 0;
    border-radius: 99px; background: #D1D5DB;
    transition: background .2s;
}
.toggle input:checked + .toggle-track { background: #F15A22; }
.toggle-thumb {
    position: absolute; top: 3px; left: 3px;
    width: 16px; height: 16px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2);
    transition: transform .2s;
}
.toggle input:checked ~ .toggle-thumb { transform: translateX(18px); }

/* ── Planta card ────────────────────────────────────────────────────── */
.planta-card {
    border: 1px solid #E5E7EB; border-radius: 12px;
    padding: 16px 20px;
    display: flex; align-items: center; gap: 16px;
    transition: box-shadow .15s, border-color .15s;
}
.planta-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); border-color: #D1D5DB; }
.planta-card.inactiva { opacity: .55; }

/* ── Avatar de planta ───────────────────────────────────────────────── */
.planta-avatar {
    width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; font-weight: 800;
}

/* ══════════════════════════════════════════════════════════════════════
   Reportes · index.php
   ══════════════════════════════════════════════════════════════════════ */

/* ── KPI compacto (reportes) ────────────────────────────────────────── */
.kpi { border-radius: 14px; padding: 18px 20px; }
.kpi-icon {
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* ── Fila de tabla ──────────────────────────────────────────────────── */
.tbl-row { transition: background .1s; }
.tbl-row:hover { background: #FAFAFA; }

/* ── Badges de estado (reutilizables) ──────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 20px;
    font-size: .68rem; font-weight: 600;
}
.badge-pending  { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.badge-approved { background: #DCFCE7; color: #166534; border: 1px solid #BBF7D0; }
.badge-rejected { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }

/* ── Grids responsive — reportes ────────────────────────────────────── */
.grid-kpi     { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid-charts  { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-filters { display: grid; grid-template-columns: repeat(5, 1fr) auto; gap: 10px; align-items: end; }

@media (max-width: 1024px) {
    .grid-kpi     { grid-template-columns: repeat(2, 1fr); }
    .grid-charts  { grid-template-columns: 1fr; }
    .grid-filters { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
    .grid-kpi     { grid-template-columns: repeat(2, 1fr); }
    .grid-filters { grid-template-columns: repeat(2, 1fr); }
}

/* ── Print ───────────────────────────────────────────────────────────── */
@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; border: 1px solid #E5E7EB; }
}

/* ══════════════════════════════════════════════════════════════════════
   Usuarios · index.php
   ══════════════════════════════════════════════════════════════════════ */

/* ── Avatar de usuario ──────────────────────────────────────────────── */
.user-avatar {
    width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; font-weight: 700; letter-spacing: -.5px;
}

/* ── Fila de usuario ────────────────────────────────────────────────── */
.user-row {
    border: 1px solid #F3F4F6; border-radius: 12px;
    padding: 14px 18px; transition: box-shadow .15s, border-color .15s;
    display: flex; align-items: center; gap: 14px;
}
.user-row:hover  { box-shadow: 0 4px 16px rgba(0,0,0,.07); border-color: #E5E7EB; }
.user-row.inactivo { opacity: .5; }

/* ── Rol badge ──────────────────────────────────────────────────────── */
.rol-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 9px; border-radius: 20px;
    font-size: .7rem; font-weight: 600;
}
.rol-operario   { background: #EFF6FF; color: #1D4ED8; border: 1px solid #BFDBFE; }
.rol-supervisor { background: #F5F3FF; color: #6D28D9; border: 1px solid #DDD6FE; }
.rol-admin      { background: #FFF4EE; color: #C2410C; border: 1px solid #FED7AA; }

/* ── Grid búsqueda + filtros (usuarios) ─────────────────────────────── */
.grid-filtros-u {
    display: grid;
    grid-template-columns: 1fr 180px 180px;
    gap: 10px;
    align-items: end;
}
@media (max-width: 640px) {
    .grid-filtros-u { grid-template-columns: 1fr; }
}

/* ── user-row responsive (mobile) ───────────────────────────────────── */
@media (max-width: 600px) {
    .user-row {
        align-items: flex-start;
        padding: 12px 14px;
        gap: 10px;
    }
    .user-row .user-avatar {
        margin-top: 2px;   /* alinea con la primera línea de texto */
    }
    /* toggle y botones se anclan arriba también */
    .user-row .toggle,
    .user-row > div:last-child {
        margin-top: 2px;
    }
}
