/* Variables de diseño institucional */
:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-primary-light: #3b82f6;
  --color-secondary: #64748b;
  --color-accent: #f59e0b;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #06b6d4;
  
  --color-status-normal: #10b981;
  --color-status-alerta: #f59e0b;
  --color-status-critico: #ef4444;
  
  --color-background: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text-primary: #1e293b;
  --color-text-secondary: #64748b;
  --color-text-muted: #94a3b8;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
}

/* Estilos base y reset */
* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  background-color: var(--color-background);
  color: var(--color-text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Navegación superior - estilo Fluent */
.nav-header {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
}

.nav-header .container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
}

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

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-brand-icon {
  width: 2.5rem;
  height: 2.5rem;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.25rem;
}

.nav-brand-content h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
  margin: 0;
}

.nav-brand-content p {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.8);
  margin: 0;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Selectores personalizados */
.custom-select {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: var(--radius-md);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  backdrop-filter: blur(10px);
  transition: all 0.2s ease;
}

.custom-select:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.custom-select option {
  background: var(--color-surface);
  color: var(--color-text-primary);
}

/* Botones de acción */
.action-btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
}

.action-btn-primary {
  background: var(--color-success);
  color: white;
}

.action-btn-primary:hover {
  background: #059669;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.action-btn-secondary {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.action-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

/* Navegación de pestañas */
.nav-tabs {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.nav-tabs-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
}

.nav-tabs-list {
  display: flex;
  gap: 0.5rem;
}

.nav-tab {
  padding: 1rem 1.5rem;
  border: none;
  background: none;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  cursor: pointer;
}

.nav-tab:hover {
  color: var(--color-text-primary);
  background: rgba(37, 99, 235, 0.05);
}

.nav-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

.nav-tab i {
  margin-right: 0.5rem;
}

/* Contenedor principal */
.main-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Tarjetas KPI - estilo moderno */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  border-left: 4px solid var(--color-primary);
  transition: all 0.3s ease;
}

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

.kpi-card.success {
  border-left-color: var(--color-success);
}

.kpi-card.warning {
  border-left-color: var(--color-warning);
}

.kpi-card.danger {
  border-left-color: var(--color-danger);
}

.kpi-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.kpi-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin: 0;
}

.kpi-icon {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.kpi-icon.primary {
  background: rgba(37, 99, 235, 0.1);
  color: var(--color-primary);
}

.kpi-icon.success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
}

.kpi-icon.warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--color-warning);
}

.kpi-icon.danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-danger);
}

.kpi-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0.5rem 0;
}

.kpi-change {
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.kpi-change.positive {
  color: var(--color-success);
}

.kpi-change.negative {
  color: var(--color-danger);
}

/* Contenedores de gráficos */
.chart-container {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 1.5rem;
}

.chart-header {
  display: flex;
  align-items: center;
  margin-bottom: 1.5rem;
}

.chart-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
}

.chart-title i {
  margin-right: 0.5rem;
}

.chart-content {
  position: relative;
  height: 300px;
}

/* Estilos específicos para los canvas de Chart.js */
canvas[id$="Chart"] {
  max-width: 100% !important;
  max-height: 100% !important;
}

/* Estilos específicos para el gráfico de comparación */
.comparacion-actual {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  border: 2px solid #ef4444;
}

.comparacion-proyectado {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  border: 2px solid #10b981;
}

.chart-info {
  margin-top: 1rem;
}

.chart-info div {
  transition: all 0.3s ease;
}

.chart-info div:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.relative.h-80 {
  height: 20rem;
}

.relative.h-72 {
  height: 18rem;
}

/* Asegurar que los gráficos sean responsivos */
@media (max-width: 768px) {
  .relative.h-80,
  .relative.h-72 {
    height: 16rem;
  }
}

@media (max-width: 640px) {
  .relative.h-80,
  .relative.h-72 {
    height: 14rem;
  }
}

/* Tablas modernas */
.table-container {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.table-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
}

.table-content {
  overflow-x: auto;
}

.modern-table {
  width: 100%;
  border-collapse: collapse;
}

.modern-table th {
  background: var(--color-background);
  padding: 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--color-border);
}

.modern-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.875rem;
  color: var(--color-text-primary);
}

.modern-table tr:hover {
  background: rgba(37, 99, 235, 0.02);
}

/* Estado de actos */
.estado-badge {
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.estado-pendiente {
  background: rgba(245, 158, 11, 0.1);
  color: var(--color-warning);
}

.estado-aprobado {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
}

.estado-rechazado {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-danger);
}

.estado-en_proceso {
  background: rgba(6, 182, 212, 0.1);
  color: var(--color-info);
}

/* Botones de acción en tablas */
.action-buttons {
  display: flex;
  gap: 0.5rem;
}

.btn-icon {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--color-background);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--color-primary);
  color: white;
  transform: translateY(-1px);
}

/* Formularios modernos */
.form-container {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

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

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-primary);
  margin-bottom: 0.5rem;
}

.form-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  transition: all 0.2s ease;
  background: var(--color-background);
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  background: var(--color-background);
  cursor: pointer;
}

/* Sliders personalizados */
.slider-container {
  margin-bottom: 1.5rem;
}

.slider-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-primary);
  margin-bottom: 0.5rem;
}

.custom-slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--color-border);
  outline: none;
  -webkit-appearance: none;
}

.custom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.custom-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  border: none;
  box-shadow: var(--shadow-sm);
}

.slider-value {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  margin-top: 0.5rem;
}

/* Panel de navegación lateral */
.sidebar-menu {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: 1rem;
  box-shadow: var(--shadow-md);
}

.menu-item {
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  background: none;
  text-align: left;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 0.25rem;
}

.menu-item:hover {
  background: var(--color-background);
  color: var(--color-text-primary);
}

.menu-item.active {
  background: rgba(37, 99, 235, 0.1);
  color: var(--color-primary);
  font-weight: 600;
}

.menu-item i {
  margin-right: 0.75rem;
  width: 1rem;
}

/* Modal moderno */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 50;
}

.modal-content {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 32rem;
  margin: 2rem auto;
  padding: 1.5rem;
}

.modal-header {
  margin-bottom: 1.5rem;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
}

/* Responsive */
@media (max-width: 768px) {
  .nav-header-content {
    flex-direction: column;
    height: auto;
    padding: 1rem 0;
  }
  
  .nav-controls {
    margin-top: 1rem;
    flex-wrap: wrap;
  }
  
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .nav-tabs-list {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .nav-tab {
    white-space: nowrap;
  }
}

/* Animaciones */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

.slide-in {
  animation: slideIn 0.3s ease-out;
}

/* Utilidades adicionales */
.text-gradient {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.glass-effect {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.loading-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}