/* ============================================================
   ML-MANAGER MODERN UPGRADE 2026
   Override de estilos para modernizar la interfaz existente
   Sin romper funcionalidad - solo mejora visual
   ============================================================ */

:root {
  /* Nuevos tokens modernos - compatibles con los existentes */
  --ml-yellow: #FFE600;
  --ml-blue: #3483FA;
  --ml-blue-light: #4d9bff;
  --ml-blue-dark: #2962cc;
  --ml-dark: #0f172a;
  --ml-sidebar: #1e293b;
  --ml-sidebar-hover: #334155;
  --ml-card: #ffffff;
  --ml-bg: #f8fafc;
  --ml-bg-soft: #f1f5f9;
  --ml-success: #10b981;
  --ml-warning: #f59e0b;
  --ml-danger: #ef4444;
  --ml-text: #0f172a;
  --ml-text-light: #64748b;
  --ml-text-muted: #94a3b8;
  --ml-border: #e2e8f0;
  --ml-border-soft: #f1f5f9;

  /* Sombras modernas */
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.10), 0 10px 10px -5px rgba(0,0,0,0.03);

  /* Radios */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* Espaciado consistente */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
}

/* === Body moderno === */
body {
  background: var(--ml-bg);
  color: var(--ml-text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  letter-spacing: -0.011em;
}

/* === Login / Auth modernizado === */
.auth-container {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #312e81 100%);
  position: relative;
  overflow: hidden;
}

.auth-container::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 20% 50%, rgba(52, 131, 250, 0.15) 0%, transparent 50%),
              radial-gradient(circle at 80% 50%, rgba(255, 230, 0, 0.08) 0%, transparent 50%);
  animation: float 20s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(-30px, 30px) rotate(5deg); }
}

.auth-card {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255,255,255,0.05);
  position: relative;
  z-index: 1;
}

/* === Sidebar moderno === */
.sidebar {
  background: linear-gradient(180deg, var(--ml-sidebar) 0%, var(--ml-dark) 100%);
  border-right: 1px solid rgba(255,255,255,0.05);
  box-shadow: var(--shadow-xl);
}

.sidebar-header h2 {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-nav a {
  border-radius: var(--radius-md);
  margin: 2px 12px;
  padding: 10px 14px;
  font-weight: 500;
  color: rgba(255,255,255,0.75);
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.06);
  color: white;
  transform: translateX(2px);
}

.sidebar-nav a.active {
  background: linear-gradient(90deg, var(--ml-blue) 0%, var(--ml-blue-dark) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(52, 131, 250, 0.3);
}

.sidebar-nav a .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

/* === Cards modernizadas === */
.card {
  background: var(--ml-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--ml-border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  font-weight: 600;
  font-size: 14px;
  color: var(--ml-text);
  padding: 16px 20px;
  border-bottom: 1px solid var(--ml-border-soft);
}

.card-body {
  padding: 20px;
}

/* === Botones modernos === */
.btn {
  font-weight: 600;
  border-radius: var(--radius-md);
  padding: 9px 18px;
  font-size: 14px;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  letter-spacing: -0.011em;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--ml-blue) 0%, var(--ml-blue-dark) 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(52, 131, 250, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--ml-blue-light) 0%, var(--ml-blue) 100%);
  box-shadow: 0 4px 12px rgba(52, 131, 250, 0.4);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
}

.btn-outline {
  background: white;
  border: 1px solid var(--ml-border);
  color: var(--ml-text);
}

.btn-outline:hover {
  background: var(--ml-bg-soft);
  border-color: var(--ml-blue);
  color: var(--ml-blue);
}

/* === Form controls modernos === */
.form-control {
  border-radius: var(--radius-md);
  border: 1.5px solid var(--ml-border);
  padding: 9px 12px;
  font-size: 14px;
  transition: all 0.15s ease;
  background: white;
  color: var(--ml-text);
  font-family: inherit;
}

.form-control:hover {
  border-color: var(--ml-text-muted);
}

.form-control:focus {
  border-color: var(--ml-blue);
  box-shadow: 0 0 0 3px rgba(52, 131, 250, 0.1);
  outline: none;
}

.form-control:focus-visible {
  outline: 2px solid var(--ml-blue);
  outline-offset: 2px;
}

/* Focus visible global para accesibilidad */
.btn:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--ml-blue);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(52, 131, 250, 0.2);
}

/* === Tablas modernas === */
table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

th {
  background: var(--ml-bg-soft);
  color: var(--ml-text-light);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ml-border);
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--ml-border-soft);
  color: var(--ml-text);
}

tbody tr:hover {
  background: var(--ml-bg-soft);
}

/* === Toasts modernos === */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--ml-dark);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 4px solid var(--ml-blue);
}

.toast.success { border-left-color: var(--ml-success); }
.toast.error { border-left-color: var(--ml-danger); }
.toast.warning { border-left-color: var(--ml-warning); }

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

/* === Modal moderno === */
.modal-overlay {
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  animation: scaleIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow: auto;
}

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

.modal-body {
  padding: 24px;
}

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

@keyframes scaleIn {
  from { transform: scale(0.95) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

/* === Spinner moderno === */
.spinner,
.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--ml-border);
  border-top-color: var(--ml-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
}

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

/* === Badges modernos === */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.badge-success {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-info {
  background: rgba(52, 131, 250, 0.12);
  color: var(--ml-blue-dark);
  border: 1px solid rgba(52, 131, 250, 0.2);
}

/* === Stats cards en dashboard === */
.stat-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--ml-border);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--ml-blue);
  opacity: 0.7;
}

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

.stat-card.success::before { background: var(--ml-success); }
.stat-card.warning::before { background: var(--ml-warning); }
.stat-card.danger::before { background: var(--ml-danger); }

/* === Scrollbar moderno === */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--ml-bg-soft);
}

::-webkit-scrollbar-thumb {
  background: var(--ml-text-muted);
  border-radius: 9999px;
  border: 2px solid var(--ml-bg-soft);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ml-text-light);
}

/* === Animaciones suaves === */
.page-content {
  animation: fadeInUp 0.3s ease;
}

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

/* === Links === */
a {
  color: var(--ml-blue);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--ml-blue-dark);
  text-decoration: underline;
}

/* === Responsive === */
@media (max-width: 768px) {
  .card { border-radius: var(--radius-md); }
  .modal { width: 95%; border-radius: var(--radius-md); }
  .toast-container { left: 12px; right: 12px; bottom: 12px; }
}

/* === Reduce motion (accesibilidad) === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
