/* ============================================================
   FERRESYS - Estilos base compartidos
   ============================================================ */

:root {
  /* Colores principales */
  --azul-oscuro: #0B1220;
  --azul-oscuro-2: #050A12;
  --azul-medio: #16233B;
  --azul-claro: #2C4A6E;
  --acento: #0E7490;
  --acento-hover: #0B5E75;
  --acento-claro: #22D3EE;
  --naranja: var(--acento);
  --naranja-hover: var(--acento-hover);
  
  /* Colores de estado */
  --verde: #22C55E;
  --verde-claro: #DCFCE7;
  --rojo: #EF4444;
  --rojo-claro: #FEE2E2;
  --amarillo: #F59E0B;
  --amarillo-claro: #FEF3C7;
  --azul-info: #3B82F6;
  --azul-info-claro: #DBEAFE;
  
  /* Neutros */
  --gris-900: #111827;
  --gris-800: #1F2937;
  --gris-700: #374151;
  --gris-600: #4B5563;
  --gris-500: #6B7280;
  --gris-400: #9CA3AF;
  --gris-300: #D1D5DB;
  --gris-200: #E5E7EB;
  --gris-100: #F3F4F6;
  --gris-50: #F9FAFB;
  --blanco: #FFFFFF;
  
  /* Sombras */
  --sombra-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --sombra-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --sombra-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --sombra-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  /* Bordes */
  --radio-sm: 6px;
  --radio-md: 10px;
  --radio-lg: 16px;
  --radio-full: 9999px;
  
  /* Transiciones */
  --transicion: 0.2s ease;
  
  /* Espaciado */
  --header-height: 64px;
  --sidebar-width: 260px;
}

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

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--gris-800);
  background: var(--gris-50);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  line-height: 1.2;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

a {
  color: var(--azul-claro);
  text-decoration: none;
}

/* ============================================================
   UTILIDADES
   ============================================================ */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gris-500); }
.text-small { font-size: 0.875rem; }
.text-danger { color: var(--rojo); }
.text-success { color: var(--verde); }
.text-warning { color: var(--amarillo); }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { display: flex; flex-direction: column; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

.hidden { display: none !important; }

/* ============================================================
   BOTONES
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radio-md);
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transicion);
  white-space: nowrap;
  border: 1px solid transparent;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--naranja);
  color: white;
}
.btn-primary:hover:not(:disabled) {
  background: var(--naranja-hover);
  transform: translateY(-1px);
  box-shadow: var(--sombra-md);
}

.btn-secondary {
  background: var(--blanco);
  color: var(--gris-700);
  border-color: var(--gris-300);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--gris-50);
  border-color: var(--gris-400);
}

.btn-danger {
  background: var(--rojo);
  color: white;
}
.btn-danger:hover:not(:disabled) {
  background: #DC2626;
  transform: translateY(-1px);
  box-shadow: var(--sombra-md);
}

.btn-ghost {
  background: transparent;
  color: var(--gris-600);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--gris-100);
  color: var(--gris-800);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-lg {
  padding: 14px 24px;
  font-size: 16px;
}

/* ============================================================
   FORMULARIOS
   ============================================================ */

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gris-700);
  margin-bottom: 6px;
}

.form-label .required {
  color: var(--rojo);
  margin-left: 2px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gris-300);
  border-radius: var(--radio-md);
  font-size: 14px;
  color: var(--gris-800);
  background: var(--blanco);
  transition: all var(--transicion);
}

.form-control:focus {
  outline: none;
  border-color: var(--naranja);
  box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.1);
}

.form-control:disabled {
  background: var(--gris-100);
  cursor: not-allowed;
}

.form-control.error {
  border-color: var(--rojo);
}

.form-error {
  color: var(--rojo);
  font-size: 12px;
  margin-top: 4px;
}

.form-help {
  color: var(--gris-500);
  font-size: 12px;
  margin-top: 4px;
}

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

.card {
  background: var(--blanco);
  border-radius: var(--radio-lg);
  box-shadow: var(--sombra-sm);
  border: 1px solid var(--gris-200);
  overflow: hidden;
}

.card-body {
  padding: 20px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gris-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--gris-800);
}

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

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radio-full);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: var(--verde-claro); color: #166534; }
.badge-danger { background: var(--rojo-claro); color: #991B1B; }
.badge-warning { background: var(--amarillo-claro); color: #92400E; }
.badge-info { background: var(--azul-info-claro); color: #1E40AF; }
.badge-neutral { background: var(--gris-100); color: var(--gris-700); }

/* ============================================================
   TABLAS
   ============================================================ */

.tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.tabla th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gris-600);
  background: var(--gris-50);
  border-bottom: 1px solid var(--gris-200);
}

.tabla td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gris-100);
  color: var(--gris-700);
}

.tabla tbody tr:hover {
  background: var(--gris-50);
}

.tabla tbody tr:last-child td {
  border-bottom: none;
}

/* ============================================================
   ALERTAS
   ============================================================ */

.alert {
  padding: 12px 16px;
  border-radius: var(--radio-md);
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success { background: var(--verde-claro); color: #166534; }
.alert-danger { background: var(--rojo-claro); color: #991B1B; }
.alert-warning { background: var(--amarillo-claro); color: #92400E; }
.alert-info { background: var(--azul-info-claro); color: #1E40AF; }

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--blanco);
  border-radius: var(--radio-lg);
  box-shadow: var(--sombra-xl);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gris-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  color: var(--gris-500);
  font-size: 20px;
  width: 32px;
  height: 32px;
  border-radius: var(--radio-md);
  transition: all var(--transicion);
}
.modal-close:hover {
  background: var(--gris-100);
  color: var(--gris-800);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gris-200);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ============================================================
   LOADING
   ============================================================ */

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--gris-300);
  border-top-color: var(--naranja);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

/* ============================================================
   TOASTS
   ============================================================ */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--blanco);
  border-radius: var(--radio-md);
  box-shadow: var(--sombra-lg);
  padding: 14px 18px;
  min-width: 280px;
  max-width: 400px;
  border-left: 4px solid var(--azul-info);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideInRight 0.3s ease;
}

.toast.success { border-left-color: var(--verde); }
.toast.error { border-left-color: var(--rojo); }
.toast.warning { border-left-color: var(--amarillo); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
  
  html, body {
    font-size: 14px;
  }
}
