/* ===================================================================
   PROYIT — Design System (general.css)
   Fuente única de verdad para colores, espaciado y componentes.
   Todas las vistas deben usar estas clases en vez de Tailwind inline
   para mantener coherencia visual.
   =================================================================== */

/* -------------------------------------------------------
   1. CSS Custom Properties (Design Tokens)
   Cambiar aquí actualiza TODO el sistema.
   ------------------------------------------------------- */
:root {
  /* Primario */
  --color-primary: #2563eb;        /* blue-600 */
  --color-primary-hover: #1d4ed8;  /* blue-700 */
  --color-primary-light: #dbeafe;  /* blue-100 */
  --color-primary-50: #eff6ff;     /* blue-50 */
  --color-primary-ring: #3b82f6;   /* blue-500 — focus rings */

  /* Superficies */
  --color-bg: #f8fafc;             /* slate-50 */
  --color-card: #ffffff;
  --color-card-border: #e2e8f0;    /* slate-200 */
  --color-card-border-light: #f1f5f9; /* slate-100 */

  /* Texto */
  --color-text: #0f172a;           /* slate-900 */
  --color-text-secondary: #64748b; /* slate-500 */
  --color-text-muted: #94a3b8;     /* slate-400 */

  /* Feedback */
  --color-success: #16a34a;
  --color-warning: #d97706;
  --color-danger: #dc2626;

  /* Radii */
  --radius-sm: 0.5rem;   /* 8px — botones, badges */
  --radius-md: 0.75rem;  /* 12px — inputs, selects */
  --radius-lg: 1rem;     /* 16px — tarjetas normales */
  --radius-xl: 1.5rem;   /* 24px — tarjetas hero / pedidos */

  /* Sombras */
  --shadow-card: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-modal: 0 25px 50px -12px rgb(0 0 0 / 0.25);
}

/* -------------------------------------------------------
   2. Tarjetas
   ------------------------------------------------------- */
.ui-card {
  background: var(--color-card);
  border: 1px solid var(--color-card-border-light);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

/* Tarjeta con borde más visible (tablas, paneles grandes) */
.ui-card-bordered {
  background: var(--color-card);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

/* Tarjeta oscura (como Producción en Pedidos) */
.ui-card-dark {
  background: #0f172a; /* slate-900 */
  color: #fff;
  border: 1px solid #1e293b; /* slate-800 */
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

/* Tarjeta de acento primario (resumen, CTAs) */
.ui-card-primary {
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  position: relative;
  overflow: hidden;
}

/* -------------------------------------------------------
   3. Tipografía de página
   ------------------------------------------------------- */
.ui-page-title {
  font-size: 1.5rem;     /* text-2xl */
  font-weight: 800;      /* font-extrabold */
  color: var(--color-text);
  letter-spacing: -0.025em;
  line-height: 1.2;
}
@media (min-width: 640px) {
  .ui-page-title { font-size: 1.875rem; /* text-3xl */ }
}

.ui-breadcrumb {
  display: flex;
  gap: 0.5rem;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
}
.ui-breadcrumb .active { color: var(--color-primary); }

/* Título de sección dentro de tarjeta (como "1. Datos del Cliente") */
.card-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* -------------------------------------------------------
   4. Inputs y Labels
   ------------------------------------------------------- */
.ui-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

/* Variante para contextos con fondo claro (la mayoría) */
.ui-label-form {
  display: block;
  font-size: 0.75rem;   /* text-xs */
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  margin-bottom: 0.25rem;
}

.ui-input {
  width: 100%;
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  outline: none;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.ui-input:focus {
  box-shadow: 0 0 0 2px var(--color-primary-ring);
  border-color: var(--color-primary-ring);
}
.ui-input:disabled {
  background: var(--color-bg);
  color: var(--color-text-secondary);
  cursor: not-allowed;
}

.ui-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  outline: none;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.ui-select:focus {
  box-shadow: 0 0 0 2px var(--color-primary-ring);
  border-color: var(--color-primary-ring);
}

/* -------------------------------------------------------
   5. Botones
   ------------------------------------------------------- */
.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  cursor: pointer;
}

.ui-btn-primary {
  background: var(--color-primary);
  color: #fff;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
}
.ui-btn-primary:hover { background: var(--color-primary-hover); }

.ui-btn-dark {
  background: #0f172a;
  color: #fff;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
}
.ui-btn-dark:hover { background: var(--color-primary); }

.ui-btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
}
.ui-btn-ghost:hover { background: var(--color-bg); }

/* -------------------------------------------------------
   6. Badges / Status
   ------------------------------------------------------- */
.ui-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  font-size: 10px;
  font-weight: 700;
  border-radius: var(--radius-sm);
}
.ui-badge-success { background: #dcfce7; color: #15803d; }
.ui-badge-warning { background: #fef3c7; color: #b45309; }
.ui-badge-danger  { background: #fee2e2; color: #dc2626; }
.ui-badge-info    { background: var(--color-primary-light); color: var(--color-primary); }

/* -------------------------------------------------------
   7. Alertas / Mensajes
   ------------------------------------------------------- */
.ui-alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}
.ui-alert-success { background: #dcfce7; border: 1px solid #86efac; color: #15803d; }
.ui-alert-error   { background: #fee2e2; border: 1px solid #fca5a5; color: #dc2626; }

/* -------------------------------------------------------
   8. Scrollbar global
   ------------------------------------------------------- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

/* -------------------------------------------------------
   9. Animaciones reutilizables
   ------------------------------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(100%) scale(0.9); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

.animate-fade   { animation: fadeIn 0.3s ease forwards; }
.animate-slide  { animation: slideIn 0.3s ease-out forwards; }
.animate-slide-right { animation: slideInRight 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }

/* -------------------------------------------------------
   10. Componentes de página: Usuarios
   ------------------------------------------------------- */

/* Tarjeta estadística con hover elevado */
.stat-card {
  background: var(--color-card);
  border: 1px solid rgba(226, 232, 240, 0.8);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.stat-card:hover {
  border-color: var(--color-primary-ring);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
  transform: translateY(-2px);
}

/* Fila de tabla con animación de entrada */
.table-row {
  transition: all 0.2s ease;
  animation: fadeIn 0.3s ease forwards;
}
.table-row:hover { background-color: #f1f5f9; }

/* Filtro activo (tabs tipo segmented control) */
.filter-btn-active {
  background-color: white;
  color: #0f172a !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Avatar con iniciales */
.avatar-initials {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #f1f5f9;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 12px;
  line-height: 1;
  text-align: center;
  color: #475569;
}

/* Toast container */
#toast-container { perspective: 1000px; }
.toast-enter { animation: slideInRight 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }

/* -------------------------------------------------------
   11. Sidebar — Link activo
   ------------------------------------------------------- */
.sidebar-link-active {
  background: rgba(59, 130, 246, 0.25) !important; /* blue-500/25 */
  color: #fff !important;
  font-weight: 700;
}
.sidebar-link-active > div:first-child {
  background: rgba(96, 165, 250, 0.35); /* blue-400/35 */
}

/* -------------------------------------------------------
   12. Skeleton / Loading placeholders
   ------------------------------------------------------- */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 800px 100%;
  animation: shimmer 1.5s infinite ease-in-out;
  border-radius: var(--radius-sm);
}
.skeleton-line {
  height: 0.75rem;
  margin-bottom: 0.5rem;
}
.skeleton-line-lg {
  height: 1rem;
  margin-bottom: 0.75rem;
  width: 60%;
}
.skeleton-circle {
  width: 38px;
  height: 38px;
  border-radius: 8px;
}

/* -------------------------------------------------------
   13. Validación visual de formularios
   ------------------------------------------------------- */
.ui-input:user-invalid,
.ui-select:user-invalid {
  border-color: var(--color-danger);
}
.ui-input:user-invalid:focus,
.ui-select:user-invalid:focus {
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.4);
  border-color: var(--color-danger);
}

/* -------------------------------------------------------
   14. Mobile sidebar
   ------------------------------------------------------- */
@media (max-width: 767px) {
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 16rem;
    z-index: 80;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  #sidebar.mobile-open {
    transform: translateX(0);
  }
  #sidebarOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 79;
  }
  #sidebarOverlay.active {
    display: block;
  }
}

/* -------------------------------------------------------
   15. Tooltips para sidebar colapsado
   ------------------------------------------------------- */
.sidebar-tooltip {
  position: relative;
}
.sidebar-tooltip[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: #0f172a;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 100;
}
.sidebar-tooltip[data-tip]:hover::after {
  opacity: 1;
}

/* -------------------------------------------------------
   15. Checkboxes personalizados
   ------------------------------------------------------- */
.ui-checkbox {
  appearance: none;
  width: 1.25em;
  height: 1.25em;
  border: 2px solid var(--color-card-border);
  border-radius: 0.5em;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.ui-checkbox:checked {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}
.ui-checkbox:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-primary-ring);
}
.ui-checkbox:checked::after {
  content: "";
  display: block;
  width: 0.5em;
  height: 0.5em;
  border-radius: 0.15em;
  background: var(--color-primary);
  position: absolute;
  top: 0.25em;
  left: 0.25em;
  transition: background 0.2s;
}
.ui-checkbox:hover {
  border-color: var(--color-primary-ring);
}
