/* css/style.css */
/* ===== RESET Y VARIABLES ===== */
:root {
  /* Colores principales */
  --primary: #4361ee;
  --primary-dark: #3a56d4;
  --primary-light: #e6ebff;
  --secondary: #7209b7;
  --accent: #f72585;
  --success: #4cc9f0;
  --warning: #f9c74f;
  --danger: #f94144;
  --info: #4895ef;
  
  /* Escala de grises */
  --gray-50: #f8f9fa;
  --gray-100: #f1f3f5;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-400: #ced4da;
  --gray-500: #adb5bd;
  --gray-600: #868e96;
  --gray-700: #495057;
  --gray-800: #343a40;
  --gray-900: #212529;
  
  /* Tipografía */
  --font-primary: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-heading: 'Poppins', 'Inter', sans-serif;
  --font-mono: 'Fira Code', monospace;
  
  /* Tamaños */
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 15px 40px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-primary);
  line-height: 1.6;
  color: var(--gray-800);
  background-color: var(--gray-100);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 1rem;
  color: var(--gray-900);
}

h1 {
  font-size: 2.5rem;
  font-weight: 700;
}

h2 {
  font-size: 2rem;
  margin-top: 2.5rem;
}

h3 {
  font-size: 1.5rem;
  margin-top: 2rem;
}

p {
  margin-bottom: 1rem;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--primary-dark);
}

/* ===== LAYOUT ===== */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ===== LOGIN ===== */
.login-body {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-container {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 440px;
  animation: fadeIn 0.6s ease-out;
}

.login-form h1 {
  text-align: center;
  margin-bottom: 2rem;
  color: var(--gray-800);
  font-weight: 700;
}

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

/* ===== HEADER ===== */
.header {
  background: white;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 1rem 0;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 1.5rem;
  margin-bottom: 0;
  color: var(--primary);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-info span {
  color: var(--gray-700);
  font-weight: 500;
}

/* ===== NAVEGACIÓN ===== */
.navigation {
  background: var(--gray-800);
  padding: 0.75rem 0;
  margin-bottom: 2rem;
}

.navigation .container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.navigation a {
  color: white;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-sm);
  font-size: 0.9rem;
  transition: var(--transition);
}

.navigation a:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

/* ===== DASHBOARD ===== */
.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.card {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  transition: var(--transition);
  border-left: 4px solid var(--primary);
  height: 100%;
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

.card h2 {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
  color: var(--gray-800);
}

.card p {
  color: var(--gray-600);
  flex-grow: 1;
  margin-bottom: 1.5rem;
}

/* ===== FORMULARIOS ===== */
.form-container {
  background: white;
  padding: 2rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--gray-700);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--border-radius-sm);
  font-family: var(--font-primary);
  font-size: 1rem;
  transition: var(--transition);
  background-color: var(--gray-50);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group textarea {
  min-height: 120px;
  resize: vertical;
}

.form-buttons {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* ===== TABLAS ===== */
.tabla-container {
  background: white;
  padding: 2rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.tabla-crud {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.tabla-crud th,
.tabla-crud td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

.tabla-crud th {
  background: var(--gray-50);
  font-weight: 600;
  color: var(--gray-700);
  position: sticky;
  top: 0;
}

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

.tabla-crud tr:hover {
  background: var(--gray-50);
}

/* ===== BOTONES ===== */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-primary);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

button:focus, .btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Botón primario */
button, .btn {
  background: var(--primary);
  color: white;
}

button:hover, .btn:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

/* Botón secundario */
.btn-cancelar {
  background: var(--gray-400);
  color: var(--gray-800);
}

.btn-cancelar:hover {
  background: var(--gray-500);
  color: white;
}

/* Botones de acción */
.acciones {
  display: flex;
  gap: 0.5rem;
}

.btn-editar {
  background: var(--info);
  color: white;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.btn-editar:hover {
  background: #3a7bd5;
  color: white;
}

.btn-eliminar {
  background: var(--danger);
  color: white;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.btn-eliminar:hover {
  background: #d32f2f;
  color: white;
}

.btn-logout {
  background: var(--danger);
  color: white;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.btn-logout:hover {
  background: #d32f2f;
  color: white;
}

/* ===== MENSAJES ===== */
.mensaje {
  background: #e8f5e9;
  color: #2e7d32;
  padding: 1rem;
  border-radius: var(--border-radius-sm);
  margin-bottom: 1.5rem;
  border-left: 4px solid #4caf50;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.error-message {
  background: #ffebee;
  color: #c62828;
  padding: 1rem;
  border-radius: var(--border-radius-sm);
  margin-bottom: 1.5rem;
  border-left: 4px solid #f44336;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ===== CRUD LAYOUT ===== */
.crud-container {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2rem;
  margin-top: 1.5rem;
}

/* ===== UTILIDADES ===== */
.text-center {
  text-align: center;
}

.mb-0 {
  margin-bottom: 0;
}

.mt-2 {
  margin-top: 2rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .crud-container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .dashboard-cards {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
}

@media (max-width: 768px) {
  html {
    font-size: 14px;
  }
  
  .header-content {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
  
  .user-info {
    justify-content: center;
  }
  
  .navigation .container {
    justify-content: center;
  }
  
  .form-buttons {
    flex-direction: column;
  }
  
  .acciones {
    flex-direction: column;
  }
  
  .tabla-crud {
    font-size: 0.85rem;
  }
  
  .tabla-crud th,
  .tabla-crud td {
    padding: 0.75rem 0.5rem;
  }
}

@media (max-width: 480px) {
  .login-container {
    padding: 1.5rem;
  }
  
  .dashboard-cards {
    grid-template-columns: 1fr;
  }
  
  .form-container,
  .tabla-container {
    padding: 1.5rem;
  }
}

/* ===== ANIMACIONES ===== */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.tabla-crud tr {
  animation: slideIn 0.3s ease-out;
  animation-fill-mode: both;
}

.tabla-crud tr:nth-child(1) { animation-delay: 0.05s; }
.tabla-crud tr:nth-child(2) { animation-delay: 0.1s; }
.tabla-crud tr:nth-child(3) { animation-delay: 0.15s; }
.tabla-crud tr:nth-child(4) { animation-delay: 0.2s; }
.tabla-crud tr:nth-child(5) { animation-delay: 0.25s; }
.tabla-crud tr:nth-child(6) { animation-delay: 0.3s; }
.tabla-crud tr:nth-child(7) { animation-delay: 0.35s; }
.tabla-crud tr:nth-child(8) { animation-delay: 0.4s; }
.tabla-crud tr:nth-child(9) { animation-delay: 0.45s; }
.tabla-crud tr:nth-child(10) { animation-delay: 0.5s; }

/* ===== MEJORAS DE ESTADO ===== */
.form-group input:invalid,
.form-group textarea:invalid,
.form-group select:invalid {
  border-color: var(--danger);
}

.form-group input:valid,
.form-group textarea:valid,
.form-group select:valid {
  border-color: var(--success);
}

/* ===== ICONOS (Usando pseudo-elementos) ===== */
.btn-logout::before {
  content: "→";
  font-weight: bold;
}

.mensaje::before {
  content: "✓";
  font-weight: bold;
}

.error-message::before {
  content: "!";
  font-weight: bold;
}

/* ===== EFECTOS DE FOCO MEJORADOS ===== */
button:focus-visible,
.btn:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ===== SCROLLBAR PERSONALIZADO ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
  background: var(--gray-400);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-500);
}

.tabla-container::-webkit-scrollbar {
  height: 12px;
}

.tabla-container::-webkit-scrollbar-thumb {
  background: var(--gray-500);
  border-radius: 6px;
}