/* ==========================================================================
   APP CORPORATE THEME - ESTILO EMPRESARIAL PREMIUM (INSPIRADO EN TMS)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800;900&display=swap');

/* --- Reset & Base Variables --- */
* {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  background-color: #f8fafc !important; /* Soft neutral off-white background */
  color: #1e293b;
}

/* --- Menú Lateral (Sidebar) --- */
aside {
  background-color: #0b0f19 !important; /* Deep carbon midnight black */
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}

aside h1 {
  font-size: 1.05rem !important;
  font-weight: 800 !important;
  letter-spacing: 0.03em;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

aside p {
  color: #64748b !important;
}

.sidebar-item {
  color: #94a3b8 !important;
  font-size: 0.82rem !important;
  font-weight: 600 !important;
  padding: 0.8rem 1.1rem !important;
  border-radius: 0.75rem !important;
  margin-bottom: 0.35rem !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
}

.sidebar-item svg {
  width: 1.25rem !important;
  height: 1.25rem !important;
  flex-shrink: 0 !important;
  margin-right: 0.75rem !important;
}

/* Chevron indicator using simple CSS arrow or chevron pseudo-element */
.sidebar-item::after {
  content: '›';
  font-size: 1.1rem;
  font-weight: 700;
  opacity: 0;
  transition: all 0.2s ease;
  transform: translateX(4px);
  margin-left: auto !important;
}

.sidebar-item:hover {
  background-color: rgba(255, 255, 255, 0.04) !important;
  color: #ffffff !important;
}

.sidebar-item:hover::after {
  opacity: 0.5;
  transform: translateX(0);
}

.sidebar-item-active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35) !important;
}

.sidebar-item-active::after {
  opacity: 1 !important;
  transform: translateX(0) !important;
  color: #ffffff !important;
}

/* Fallbacks for toggle button and other SVGs */
#sidebar-toggle-btn svg {
  width: 1.25rem !important;
  height: 1.25rem !important;
  flex-shrink: 0 !important;
}

header svg {
  width: 1.25rem !important;
  height: 1.25rem !important;
  flex-shrink: 0 !important;
}

header svg.text-slate-400 {
  width: 1rem !important;
  height: 1rem !important;
}

/* --- Encabezado Principal (Header) --- */
header {
  background-color: #ffffff !important;
  border-bottom: 1px solid #e2e8f0 !important;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.02) !important;
}

#view-title {
  font-weight: 800 !important;
  color: #0f172a !important;
  letter-spacing: -0.02em;
}

/* Buscador de Cabecera */
#global-search {
  font-size: 0.75rem !important;
  border: 0 !important;
  padding: 0 !important;
  background-color: transparent !important;
  width: 100% !important;
  font-weight: 500;
}
#global-search:focus {
  outline: none !important;
  box-shadow: none !important;
}

/* Notificaciones Badge */
header .relative span {
  box-shadow: 0 0 0 2px #ffffff;
}

/* Avatar de Iniciales */
#user-avatar-initials {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8) !important;
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.25) !important;
  font-weight: 700 !important;
  letter-spacing: 0.05em;
  border: 2px solid #ffffff;
}

/* --- Dashboard / KPI Cards Layout --- */
.card-shadow,
section[id^="view-"] > .bg-white,
section[id^="view-"] .bg-white {
  background-color: #ffffff;
  border-radius: 1rem !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.02), 0 2px 8px -1px rgba(15, 23, 42, 0.02) !important;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-shadow:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 25px -4px rgba(15, 23, 42, 0.06), 0 4px 12px -2px rgba(15, 23, 42, 0.03) !important;
}

/* Títulos y Valores del KPI */
.grid > div > div > p.text-slate-400 {
  color: #64748b !important;
  font-size: 0.7rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.05em;
}

.grid > div > div > h3 {
  color: #0f172a !important;
  font-weight: 800 !important;
  font-size: 1.6rem !important;
  letter-spacing: -0.03em;
}

/* Etiquetas de Tendencia (MoM Trends) */
.kpi-trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.45rem;
  border-radius: 0.375rem;
  font-size: 0.65rem;
  font-weight: 800;
}
.kpi-trend-up {
  background-color: #d1fae5;
  color: #065f46;
}
.kpi-trend-up::before {
  content: '▲';
  font-size: 0.5rem;
}
.kpi-trend-down {
  background-color: #fee2e2;
  color: #991b1b;
}
.kpi-trend-down::before {
  content: '▼';
  font-size: 0.5rem;
}
.kpi-trend-neutral {
  background-color: #f1f5f9;
  color: #475569;
}

/* Iconos de las Cards */
.grid > div > div.rounded-2xl {
  border-radius: 0.85rem !important;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02);
}

/* --- Formulario e Inputs --- */
input, select, textarea {
  border: 1px solid #cbd5e1 !important;
  border-radius: 0.75rem !important;
  padding: 0.65rem 0.85rem !important;
  font-size: 0.82rem !important;
  background-color: #ffffff !important;
  color: #0f172a !important;
  transition: all 0.15s ease-in-out !important;
}

input:focus, select:focus, textarea:focus {
  border-color: #2563eb !important;
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15) !important;
}

label {
  color: #64748b !important;
  font-weight: 700 !important;
  letter-spacing: 0.05em;
}

/* --- Botones --- */
button:not(.sidebar-item):not(.theme-toggle):not(.mobile-nav-item) {
  border-radius: 0.75rem !important;
  font-weight: 700 !important;
  font-size: 0.75rem !important;
  letter-spacing: 0.02em;
  padding: 0.65rem 1.2rem !important;
  transition: all 0.2s ease !important;
}

button.bg-emerald-600 {
  background: linear-gradient(135deg, #10b981, #059669) !important;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2) !important;
}
button.bg-emerald-600:hover {
  background: linear-gradient(135deg, #059669, #047857) !important;
  transform: translateY(-1px);
}

button.bg-red-600 {
  background: linear-gradient(135deg, #ef4444, #dc2626) !important;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2) !important;
}
button.bg-red-600:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
  transform: translateY(-1px);
}

button.bg-blue-600 {
  background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2) !important;
}
button.bg-blue-600:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
  transform: translateY(-1px);
}

button.bg-slate-800 {
  background: #0f172a !important;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15) !important;
}
button.bg-slate-800:hover {
  background: #1e293b !important;
  transform: translateY(-1px);
}

/* --- Tablas --- */
table {
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

th {
  background-color: #f8fafc !important;
  color: #64748b !important;
  font-weight: 700 !important;
  border-bottom: 2px solid #e2e8f0 !important;
  text-transform: uppercase;
  font-size: 0.7rem !important;
  letter-spacing: 0.05em;
  padding: 0.9rem 1.1rem !important;
}

td {
  padding: 0.9rem 1.1rem !important;
  border-bottom: 1px solid #f1f5f9 !important;
  color: #334155;
  font-weight: 500;
}

tbody tr:hover {
  background-color: #f8fafc !important;
}

/* --- Modales --- */
#password-modal > div {
  border-radius: 1.25rem !important;
  border: 1px solid #e2e8f0;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* --- MODO OSCURO (THEME DARK) --- */
body.theme-dark {
  background-color: #030712 !important; /* Slate puro */
  color: #f3f4f6 !important;
}

body.theme-dark aside {
  background-color: #090d16 !important;
  border-right: 1px solid #111827;
}

body.theme-dark header {
  background-color: #0f172a !important;
  border-bottom: 1px solid #1e293b !important;
}

body.theme-dark #view-title {
  color: #ffffff !important;
}

body.theme-dark .bg-white,
body.theme-dark .bg-slate-50,
body.theme-dark .bg-slate-100 {
  background-color: #0f172a !important;
}

body.theme-dark .card-shadow,
body.theme-dark section[id^="view-"] > .bg-white,
body.theme-dark section[id^="view-"] .bg-white {
  background-color: #0f172a !important;
  border: 1px solid #1e293b !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2) !important;
}

body.theme-dark table th {
  background-color: #111827 !important;
  color: #94a3b8 !important;
  border-bottom: 2px solid #1e293b !important;
}

body.theme-dark table td {
  border-bottom: 1px solid #1e293b !important;
  color: #cbd5e1 !important;
}

body.theme-dark tbody tr:hover {
  background-color: #1e293b !important;
}

body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  background-color: #030712 !important;
  border: 1px solid #1e293b !important;
  color: #ffffff !important;
}

body.theme-dark input:focus,
body.theme-dark select:focus,
body.theme-dark textarea:focus {
  border-color: #2563eb !important;
}

body.theme-dark .theme-toggle {
  background-color: #1e293b !important;
  border: 1px solid #334155 !important;
  color: #f3f4f6 !important;
}
body.theme-dark .theme-toggle:hover {
  background-color: #334155 !important;
}

body.theme-dark .grid > div > div > h3 {
  color: #ffffff !important;
}

/* Modificaciones de tendencias en Modo Oscuro */
body.theme-dark .kpi-trend-up {
  background-color: rgba(16, 185, 129, 0.15);
  color: #34d399;
}
body.theme-dark .kpi-trend-down {
  background-color: rgba(239, 68, 68, 0.15);
  color: #f87171;
}
body.theme-dark .kpi-trend-neutral {
  background-color: #1e293b;
  color: #94a3b8;
}

/* Buscador de Cabecera en Modo Oscuro */
body.theme-dark #global-search {
  color: #ffffff !important;
}
body.theme-dark #global-search::placeholder {
  color: #64748b;
}

/* Avatar Border en Modo Oscuro */
body.theme-dark #user-avatar-initials {
  border-color: #0f172a;
}

/* --- Collapsible Sidebar Menu --- */
aside {
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

main {
  transition: padding-left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

body.sidebar-collapsed #main-app > aside,
body.sidebar-collapsed #main-app:has(#mobile-nav) > aside,
body.sidebar-collapsed aside {
  width: 5rem !important;
  min-width: 5rem !important;
  max-width: 5rem !important;
}

@media (hover: hover) and (pointer: fine) {
  body.sidebar-collapsed #main-app > aside {
    width: 5rem !important;
    min-width: 5rem !important;
    max-width: 5rem !important;
  }
}

body.sidebar-collapsed aside h1,
body.sidebar-collapsed aside p,
body.sidebar-collapsed aside .sidebar-text,
body.sidebar-collapsed aside .sidebar-item::after {
  display: none !important;
}

body.sidebar-collapsed aside div.p-6 {
  padding: 1rem 0.5rem !important;
}

body.sidebar-collapsed aside div.w-20 {
  width: 2.5rem !important;
  height: 2.5rem !important;
  margin-bottom: 0 !important;
}

body.sidebar-collapsed aside nav {
  padding-left: 0.75rem !important;
  padding-right: 0.75rem !important;
}

body.sidebar-collapsed .sidebar-item {
  justify-content: center !important;
  padding: 0.8rem 0 !important;
}

body.sidebar-collapsed .sidebar-item svg {
  margin-right: 0 !important;
}

/* --- Dashboard Responsive Sizing Classes --- */

/* Small Devices (Mobile): standard 1 column */
.widget-size-1,
.widget-size-2,
.widget-size-3,
.widget-size-4 {
  grid-column: span 1 / span 1 !important;
}

/* Medium Devices (md: 768px+ - 2 columns grid) */
@media (min-width: 768px) {
  .widget-size-1 {
    grid-column: span 1 / span 1 !important;
  }
  .widget-size-2,
  .widget-size-3,
  .widget-size-4 {
    grid-column: span 2 / span 2 !important;
  }
}

/* Extra Large Devices (xl: 1280px+ - 3 columns grid) */
@media (min-width: 1280px) {
  .widget-size-1 {
    grid-column: span 1 / span 1 !important;
  }
  .widget-size-2 {
    grid-column: span 2 / span 2 !important;
  }
  .widget-size-3,
  .widget-size-4 {
    grid-column: span 3 / span 3 !important;
  }
}

/* 2XL Devices (2xl: 1536px+ - 4 columns grid) */
@media (min-width: 1536px) {
  .widget-size-1 {
    grid-column: span 1 / span 1 !important;
  }
  .widget-size-2 {
    grid-column: span 2 / span 2 !important;
  }
  .widget-size-3 {
    grid-column: span 3 / span 3 !important;
  }
  .widget-size-4 {
    grid-column: span 4 / span 4 !important;
  }
}

/* Custom Configurator Panel Styles */
#dashboard-configurator-list::-webkit-scrollbar {
  width: 6px;
}

#dashboard-configurator-list::-webkit-scrollbar-track {
  background: transparent;
}

#dashboard-configurator-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

body.theme-dark #dashboard-configurator-list::-webkit-scrollbar-thumb {
  background: #334155;
}
