/* =====================================================
   Estilos oscuros para Dashboards - Inspirado en el Login
   ===================================================== */

:root {
  /* Colores de fondo oscuro con estética landing */
  --bg-primary: #03091A;
  --bg-secondary: #110f24;
  --bg-tertiary: #0F1830;
  
  /* Colores de texto */
  --text-primary: #ffffff;
  --text-secondary: #ffffff;
  --text-muted: #cbd5e1;
  
  /* Bordes y divisores */
  --border-color: #1A2E55;
  --border-hover: #2A4A80;
  
  /* Superficies */
  --surface-light: rgba(15, 23, 42, 0.86);
  --surface-medium: rgba(15, 23, 42, 0.94);
  --surface-dark: rgba(2, 6, 23, 0.7);

  /* Accent de la landing */
  --brand: #4A8BDF;
  --brand-soft: rgba(74,139,223, 0.18);
  --brand-soft-border: rgba(122,176,235, 0.48);
  --brand-glow: rgba(42,90,159, 0.34);
  
  /* Sombras */
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.5);
}

/* Fondo base oscuro con gradientes animados */
body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  margin: 0;
  padding: 0;
}

.container {
  width: 100%;
  margin: 0 auto;
}

.dashboard-container.dashboard-dark {
  position: relative;
  overflow-x: hidden;
  min-height: 100vh;
}

.dashboard-container.dashboard-dark::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 16% 22%, rgba(30,74,150, 0.22) 0%, transparent 42%),
    radial-gradient(circle at 84% 18%, rgba(122,176,235, 0.08) 0%, transparent 36%),
    linear-gradient(to bottom right, rgba(2, 6, 23, 1) 0%, rgba(15, 23, 42, 0.96) 52%, rgba(2, 6, 23, 1) 100%);
}

.dashboard-container.dashboard-dark::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.4;
  background-image: 
    radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.03) 0%, transparent 50%);
}

/* Animación de puntos en el fondo */
.dot-grid-dark {
  background-image: 
    radial-gradient(circle, rgba(255, 255, 255, 0.15) 0.5px, transparent 0.5px);
  background-size: 40px 40px;
  animation: dot-slide 30s linear infinite;
}

@keyframes dot-slide {
  0% { 
    background-position: 0 0; 
  }
  100% { 
    background-position: 40px 40px; 
  }
}

/* Contenedor principal */
.dashboard-container {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  width: 100%;
  padding: 0 clamp(0.75rem, 2vw, 1.75rem);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Navbar del dashboard */
.dashboard-header {
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  width: min(1200px, calc(100% - 1.5rem));
  background: rgba(2, 6, 23, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  transition: all 0.3s ease;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.dashboard-header:hover {
  border-color: var(--border-hover);
  background: rgba(0, 0, 0, 0.8);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}

.dashboard-header-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1rem;
}

.dashboard-header-logo::before {
  content: "";
  width: 20px;
  height: 20px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.85), rgba(51,65,85, 0.55));
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(51,65,85, 0.35);
}

.dashboard-nav {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  justify-content: center;
}

.dashboard-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.dashboard-nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.dashboard-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dashboard-user-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
}

.dashboard-credits-info {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.8rem;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #EFFAFD;
}

.dashboard-user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.dashboard-user-info::before {
  content: "👤";
  font-size: 0.9rem;
}

/* Botones del dashboard */
.btn-dashboard {
  padding: 0.6rem 1.2rem;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-dashboard:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.btn-dashboard.btn-primary {
  background: var(--brand);
  border-color: rgba(255, 255, 255, 0.26);
  color: #fff;
  box-shadow: 0 8px 22px var(--brand-glow);
}

.btn-dashboard.btn-primary:hover {
  background: #4A8BDF;
  border-color: rgba(255, 255, 255, 0.38);
}

.btn-dashboard.btn-brand-outline {
  background: var(--brand-soft);
  border-color: var(--brand-soft-border);
  color: #F0CCDE;
}

.btn-dashboard.btn-brand-outline:hover {
  background: rgba(160,0,109, 0.24);
  color: #F5D6E8;
}

.btn-dashboard.logout {
  background: rgba(30, 41, 59, 0.7);
  border-color: #334155;
  color: #cbd5e1;
}

.btn-dashboard.logout:hover {
  background: rgba(30, 41, 59, 0.9);
  border-color: #475569;
  box-shadow: 0 8px 24px rgba(30,74,150, 0.22);
}

/* Contenido principal */
.dashboard-content {
  position: relative;
  z-index: 11;
  margin-top: 4.5rem;
  padding: 2rem 0 1.5rem;
  width: min(1100px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 5.5rem);
  min-height: calc(100dvh - 5.5rem);
}


.dashboard-user-summary {
  width: min(1100px, 100%);
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
  margin: 0 0 1rem;
}

/* Tarjetas/Paneles */
.dashboard-panel {
  width: min(100%, 1100px);
  background: var(--surface-medium);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 2rem;
  margin-bottom: 1.5rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
  overflow: hidden;
  position: relative;
}

.dashboard-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at bottom left, rgba(160,0,109, 0.14) 0%, transparent 54%);
  pointer-events: none;
}

.dashboard-panel > * {
  position: relative;
  z-index: 1;
}

.dashboard-panel:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-lg);
  background: rgba(255, 255, 255, 0.1);
}

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

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

.panel-subtitle {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Tablas */
.dashboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.dashboard-table thead {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
}

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

.dashboard-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.dashboard-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.05);
  border-bottom-color: var(--border-hover);
}

.dashboard-table tbody td {
  padding: 1rem;
  color: var(--text-muted);
}

.dashboard-table tbody tr:hover td {
  color: var(--text-secondary);
}

/* Enlaces en tabla */
.table-link {
  color: #E890C5;
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  font-weight: 500;
}

.table-link:hover {
  background: rgba(160,0,109, 0.2);
  border-color: rgba(160,0,109, 0.38);
  color: #EDBEDC;
}

/* Secciones vacías */
.dashboard-empty {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--border-color);
  border-radius: 16px;
}

/* Meta información */
.dashboard-meta {
  display: flex;
  gap: 2rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.dashboard-meta span {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#optimization-summary {
  width: 100%;
  margin: 0 auto;
}

.summary-card {
  text-align: left;
  background: linear-gradient(145deg, rgba(15, 12, 17, 0.9), rgba(0, 0, 0, 0.45));
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.summary-card-compact {
  padding: 1rem 1.1rem;
}

.summary-card-danger {
  background:
    radial-gradient(circle at 100% 0%, rgba(160,0,109, 0.2) 0%, transparent 45%),
    linear-gradient(145deg, rgba(30, 15, 23, 0.9), rgba(0, 0, 0, 0.45));
}

.summary-card-success {
  background:
    radial-gradient(circle at 100% 0%, rgba(16, 185, 129, 0.2) 0%, transparent 45%),
    linear-gradient(145deg, rgba(8, 26, 23, 0.9), rgba(0, 0, 0, 0.45));
}

.summary-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #EAACE0;
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.85rem;
}

.summary-card-success .summary-chevron {
  color: #EFFAFD;
}

.summary-eyebrow {
  margin: 0;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.58);
}

.summary-value {
  font-size: clamp(2rem, 4.5vw, 2.6rem);
  font-weight: 700;
  margin: 0.85rem 0;
  line-height: 1;
}

.summary-value-danger {
  color: #E890C5;
}

.summary-value-success {
  color: #EFFAFD;
}

.summary-copy {
  margin: 0;
  font-size: 0.86rem;
  color: rgba(255, 255, 255, 0.74);
  max-width: 26ch;
}

.summary-report {
  margin: 0.75rem 0 0;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.66);
}

/* Responsive */
@media (max-width: 1024px) {
  .dashboard-header {
    width: min(100%, calc(100% - 1.5rem));
    top: 1rem;
    border-radius: 1.25rem;
  }

  .dashboard-content {
    margin-top: 4.5rem;
    min-height: calc(100vh - 5.5rem);
  }
}

@media (max-width: 768px) {
  .dashboard-header {
    width: calc(100% - 1rem);
    top: 0.75rem;
    padding: 0.8rem 1rem;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    border-radius: 1rem;
  }
  
  .dashboard-nav {
    display: none;
  }

  .dashboard-actions {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }
  
  .dashboard-content {
    padding: 0.8rem 0 1.25rem;
    margin-top: 5rem;
    width: 100%;
    min-height: calc(100vh - 5rem);
  }

  .dashboard-panel {
    padding: 1.25rem;
    border-radius: 18px;
  }
  
  .panel-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1rem;
  }
  
  .dashboard-table {
    font-size: 0.85rem;
  }
  
  .dashboard-table thead th,
  .dashboard-table tbody td {
    padding: 0.75rem;
  }
}

@media (max-width: 480px) {
  .dashboard-header-logo {
    width: 100%;
    justify-content: center;
  }

  .btn-dashboard {
    width: 100%;
    justify-content: center;
  }

  .dashboard-user-info {
    width: 100%;
    justify-content: center;
  }
}

/* Animación de entrada */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dashboard-panel {
  animation: fadeInUp 0.5s ease-out;
}

/* Gradiente de scroll para tablas muy largas */
.dashboard-table tbody::-webkit-scrollbar {
  height: 8px;
}

.dashboard-table tbody::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.dashboard-table tbody::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.dashboard-table tbody::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Estados de carga */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Modal overlay */
.modal-overlay {
  display: none;
}

.modal-overlay[style*="display: flex"] {
  display: flex !important;
}

/* Loading overlay */
.loading-overlay {
  display: none;
}

.loading-overlay[style*="display: flex"] {
  display: flex !important;
}

/* Badges y etiquetas */
.badge {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.badge.success {
  background: rgba(76, 175, 80, 0.15);
  border-color: rgba(76, 175, 80, 0.3);
  color: #81c784;
}

.badge.warning {
  background: rgba(255, 193, 7, 0.15);
  border-color: rgba(255, 193, 7, 0.3);
  color: #FFD54F;
}

.badge.error {
  background: rgba(244, 67, 54, 0.15);
  border-color: rgba(244, 67, 54, 0.3);
  color: #ef5350;
}

.dashboard-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem;
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.03);
  transition: all 0.3s ease;
}

.dropzone-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.dropzone-file-feedback {
  margin-top: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(129, 199, 132, 0.25);
  background: rgba(129, 199, 132, 0.1);
  max-width: min(100%, 420px);
}

.dropzone-file-name {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.78);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-dashboard.btn-clear-upload {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.24);
}

.btn-dashboard.btn-clear-upload:hover {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.38);
}

.dashboard-dropzone.active {
  background: rgba(160,0,109, 0.16);
  border-color: rgba(160,0,109, 0.5);
}
