/* ==========================================================================
   Estilos Dashboard Estilo Metronic (CSS Moderno Vanilla)
   ========================================================================== */

:root {
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;

  /* Paleta de Colores Metronic Dark/Navy */
  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --bg-sidebar: #0f172a;
  --border-color: #334155;

  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dark: #0f172a;

  --sidebar-width: 260px;
  --topbar-height: 70px;
  --radius-lg: 14px;
  --radius-md: 8px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* Layout Main Container */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Estilo Metronic */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--primary);
  border-bottom: 1px solid var(--border-color);
}

.sidebar-brand i {
  margin-right: 0.75rem;
  font-size: 1.5rem;
}

.sidebar-nav {
  padding: 1.5rem 1rem;
  flex-grow: 1;
}

.nav-link-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  margin-bottom: 0.5rem;
  transition: all 0.2s ease;
}

.nav-link-item:hover,
.nav-link-item.active {
  background-color: rgba(99, 102, 241, 0.15);
  color: var(--primary);
}

.nav-link-item i {
  margin-right: 0.75rem;
  font-size: 1.1rem;
}

/* Main Content Area */
.app-main {
  margin-left: var(--sidebar-width);
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar Header */
.app-topbar {
  height: var(--topbar-height);
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 900;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--info));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
}

/* Content Container */
.content-body {
  padding: 2rem;
}

/* Metronic KPI Cards */
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.kpi-icon.primary {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary);
}

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

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

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

.kpi-value {
  font-size: 1.85rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.kpi-label {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Metronic Data Cards & Tables */
.card-custom {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

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

.card-title-custom {
  font-weight: 600;
  font-size: 1.1rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.table-custom {
  width: 100%;
  color: var(--text-main);
  border-collapse: separate;
  border-spacing: 0;
}

.table-custom th {
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.table-custom td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  font-size: 0.9rem;
}

.table-custom tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Badges Metronic */
.badge-custom {
  padding: 0.35em 0.75em;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

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

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

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

.badge-secondary {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

/* Quick Link Copy Container */
.link-copy-box {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 260px;
}

.link-text {
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--info);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Buttons Metronic Style */
.btn-primary-custom {
  background-color: var(--primary);
  color: #fff;
  border: none;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
  cursor: pointer;
}

.btn-primary-custom:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.btn-icon-copy {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: all 0.2s;
}

.btn-icon-copy:hover {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.2);
}

/* Modals Override for Dark Mode */
.modal-content-dark {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-lg);
}

.modal-content-dark .form-control,
.modal-content-dark .form-select {
  background-color: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.modal-content-dark .form-control:focus,
.modal-content-dark .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.25rem rgba(99, 102, 241, 0.25);
  color: var(--text-main);
}

/* ==========================================================================
   Mejoras Globales de Contraste y Colores de Iconos / Textos
   ========================================================================== */

/* Textos secundarios con mayor brillo para lectura en fondo oscuro */
.text-muted {
  color: #cbd5e1 !important;
}

/* Inputs, Selects y Elementos de Formulario */
.form-control,
.form-select {
  background-color: #1e293b !important;
  color: #f8fafc !important;
  border: 1px solid #475569 !important;
}

.form-control:focus,
.form-select:focus {
  border-color: #6366f1 !important;
  box-shadow: 0 0 0 0.25rem rgba(99, 102, 241, 0.3) !important;
  color: #ffffff !important;
}

.form-control::placeholder {
  color: #94a3b8 !important;
  opacity: 1 !important;
}

/* Iconos y Span en Input Groups */
.input-group-text {
  background-color: #0f172a !important;
  border: 1px solid #475569 !important;
  color: #818cf8 !important;
}

.input-group-text i {
  color: #818cf8 !important;
  font-size: 1.15rem;
}

/* Selector de Archivos (input file) */
input[type="file"] {
  color: #f8fafc !important;
}

input[type="file"]::file-selector-button {
  background-color: #334155;
  color: #f8fafc;
  border: 1px solid #475569;
  border-radius: 6px;
  padding: 0.375rem 0.75rem;
  margin-right: 0.75rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

input[type="file"]::file-selector-button:hover {
  background-color: #475569;
}

/* Opciones de Select */
select option {
  background-color: #1e293b;
  color: #f8fafc;
}

/* Iconos de Navegación e Histórico */
.sidebar-nav .nav-link-item i {
  color: #818cf8;
}

.sidebar-nav .nav-link-item.active i {
  color: #6366f1;
}

/* Sidebar Overlay para Celulares */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.sidebar-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* Custom Dark Nav Tabs (User Modal) */
.modal-content-dark .nav-tabs {
  border-bottom-color: var(--border-color) !important;
}

.modal-content-dark .nav-tabs .nav-link {
  color: #94a3b8 !important;
  background-color: transparent !important;
  border: 1px solid transparent !important;
  border-radius: 6px 6px 0 0 !important;
  transition: all 0.2s ease !important;
  font-weight: 500 !important;
  padding: 0.5rem 1rem !important;
}

.modal-content-dark .nav-tabs .nav-link:hover {
  color: #f8fafc !important;
  background-color: rgba(99, 102, 241, 0.15) !important;
  border-color: transparent !important;
}

.modal-content-dark .nav-tabs .nav-link.active {
  color: #ffffff !important;
  background-color: var(--primary) !important;
  border-color: var(--primary) !important;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3) !important;
}

/* Contextual Alert Colors */
.alert-danger {
  --bs-alert-bg: rgba(239, 68, 68, 0.2) !important;
  --bs-alert-color: #f87171 !important;
  --bs-alert-border-color: rgba(239, 68, 68, 0.4) !important;
}

.alert-success {
  --bs-alert-bg: rgba(16, 185, 129, 0.25) !important;
  --bs-alert-color: #34d399 !important;
  --bs-alert-border-color: rgba(16, 185, 129, 0.4) !important;
}

.alert-warning {
  --bs-alert-bg: rgba(245, 158, 11, 0.2) !important;
  --bs-alert-color: #fbbf24 !important;
  --bs-alert-border-color: rgba(245, 158, 11, 0.4) !important;
}

.alert-info {
  --bs-alert-bg: rgba(99, 102, 241, 0.2) !important;
  --bs-alert-color: #818cf8 !important;
  --bs-alert-border-color: rgba(99, 102, 241, 0.4) !important;
}

/* Responsive Adjustments */
@media (max-width: 992px) {
  .app-sidebar {
    transform: translateX(-100%);
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.5);
  }

  .app-main {
    margin-left: 0;
  }

  .app-sidebar.show {
    transform: translateX(0);
  }

  .app-topbar {
    padding: 0 1rem;
  }

  .content-body {
    padding: 1.25rem 1rem;
  }
}

@media (max-width: 576px) {
  .topbar-search-box {
    max-width: 140px !important;
  }

  .btn-primary-custom {
    padding: 0.45rem 0.75rem;
    font-size: 0.825rem;
  }

  .btn-primary-custom span.btn-text {
    display: none;
  }

  .user-badge {
    gap: 0.4rem;
  }

  .avatar-circle {
    width: 34px;
    height: 34px;
    font-size: 0.9rem;
  }

  .kpi-card {
    padding: 1rem;
  }

  .kpi-value {
    font-size: 1.4rem;
  }

  .kpi-icon {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
  }

  .card-header-custom {
    padding: 0.85rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .table-custom th,
  .table-custom td {
    padding: 0.75rem 0.75rem;
  }
}