:root,
[data-theme="classic"] {
  /* Colors - Classic Blue */
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --nav-bg: #1e293b;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --primary-shadow-color: rgba(59, 130, 246, 0.2);

  --font-family: 'Manrope', sans-serif;
  --transition-fast: all 0.2s ease;
  --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);
  --radius-md: 12px;
}


/* =============================================
   THEME: NEÓN — White sidebar, green accent only
============================================= */
[data-theme="neon"] {
  --primary: #bef264;
  /* More yellowish/lime neon */
  --primary-hover: #a3e635;
  --bg-main: #f9fafb;
  --bg-card: #ffffff;
  --nav-bg: #ffffff;
  --text-main: #111827;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;
  --primary-shadow-color: rgba(190, 242, 100, 0.3);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
}

/* White sidebar overrides */
[data-theme="neon"] #sidebar {
  border-right: 1px solid #e5e7eb;
}

[data-theme="neon"] .sidebar-logo {
  color: #111827;
  border-bottom-color: #e5e7eb;
}

/* Neon mobile top bar: white background so content is visible */
[data-theme="neon"] .mobile-top-bar {
  background: #ffffff !important;
  border-bottom: 1px solid #e5e7eb;
}

[data-theme="neon"] .sidebar-logo span {
  color: #15803d;
}

[data-theme="neon"] .sidebar-nav a {
  color: #6b7280;
}

.btn-reset {
  background: var(--primary-light);
  color: var(--primary);
  border: none;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

[data-theme="neon"] .btn-reset,
[data-theme="dark"] .btn-reset {
  background: transparent !important;
}

.btn-reset:hover {
  filter: brightness(0.9);
}

[data-theme="neon"] .sidebar-nav a:hover {
  color: #111827;
  background: #f3f4f6;
}

[data-theme="neon"] .sidebar-nav a.active {
  color: #15803d;
  background: #f0fdf4;
  border-left-color: #bef264;
}

[data-theme="neon"] .sidebar-nav a.active svg,
[data-theme="neon"] .sidebar-nav a.active i {
  color: #15803d;
}


[data-theme="neon"] .sidebar-footer {
  border-top-color: #e5e7eb;
}

[data-theme="neon"] .sidebar-footer button {
  color: #6b7280 !important;
}

[data-theme="neon"] .sidebar-footer button:hover {
  background: #f3f4f6 !important;
  color: #374151 !important;
}

/* Green for primary, amber for danger */
[data-theme="neon"] .btn-primary {
  background: linear-gradient(180deg, #bef264 0%, #a3e635 100%);
  color: #374151 !important;
}

[data-theme="neon"] .btn-primary:hover {
  filter: brightness(1.1);
}


[data-theme="neon"] [style*="color: #ef4444"],
[data-theme="neon"] [style*="color: #dc2626"] {
  color: #d97706 !important;
}

[data-theme="neon"] [style*="background: #ef4444"],
[data-theme="neon"] [style*="background: #dc2626"] {
  background: #d97706 !important;
}

[data-theme="neon"] .premium-select {
  background: #ffffff;
  border-color: #e5e7eb;
  color: #111827;
}

/* Ensure readability in Neon for non-primary text */
[data-theme="neon"] h1,
[data-theme="neon"] h2,
[data-theme="neon"] h3,
[data-theme="neon"] .stat-label,
[data-theme="neon"] label {
  color: #15803d !important;
}



/* =============================================
   THEME: OSCURO — Deep dark, no white borders
============================================= */
[data-theme="dark"] {
  --primary: #bef264;
  /* Yellowish green */
  --primary-hover: #a3e635;
  --bg-main: #0a0a12;
  --bg-card: #111120;
  --nav-bg: #0d0d18;
  --text-main: #c8d0da;
  --text-muted: #4e5a6b;
  --border-color: transparent;
  --primary-shadow-color: rgba(190, 242, 100, 0.2);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.5);
  --shadow-md: 0 6px 20px -2px rgb(0 0 0 / 0.6);
}

/* Core */
[data-theme="dark"] body {
  background: var(--bg-main);
  color: var(--text-main);
}

[data-theme="dark"] .card {
  background: var(--bg-card);
  border: none;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04), 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* Inputs */
[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: #1a1a2e !important;
  border-color: rgba(255, 255, 255, 0.07) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] .premium-select {
  background: #1a1a2e;
  border-color: rgba(255, 255, 255, 0.07);
  color: var(--text-main);
}

/* Tables — no borders, subtle gradient rows */
[data-theme="dark"] table {
  background: transparent;
  color: var(--text-main);
  border-collapse: collapse;
}

[data-theme="dark"] table thead th,
[data-theme="dark"] table th {
  background: #0f0f1c !important;
  color: var(--text-muted) !important;
  font-size: 0.7rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.06em !important;
  border: none !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04) !important;
}

[data-theme="dark"] table td {
  background: transparent !important;
  border: none !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.025) !important;
  color: rgba(200, 208, 218, 0.72) !important;
}

[data-theme="dark"] table tr:nth-child(odd) td {
  background: rgba(255, 255, 255, 0.01) !important;
}

[data-theme="dark"] table tr:hover td {
  background: rgba(255, 255, 255, 0.03) !important;
  /* Muted hover instead of green */
  color: #ffffff !important;
}

/* Custom Table Row Classes instead of inline JS */
.mov-row {
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s;
}

.mov-row:hover {
  background: #f8fafc;
}

[data-theme="neon"] .mov-row:hover {
  background: #f3f4f6;
}

.row-pagada {
  background: #f0fdf4;
}

.row-previsto {
  opacity: 0.65;
  font-style: italic;
  background: #fcfcfc;
}

.row-ingreso {
  background: rgba(16, 185, 129, 0.03);
}

.row-gasto {
  background: rgba(239, 68, 68, 0.02);
}

/* Dark Mode Overrides for these specific semantic rows */
[data-theme="dark"] .mov-row:hover {
  background: rgba(255, 255, 255, 0.03) !important;
}

[data-theme="dark"] .row-pagada {
  background: rgba(16, 185, 129, 0.08) !important;
}

[data-theme="dark"] .row-pagada:hover {
  background: rgba(16, 185, 129, 0.12) !important;
}

[data-theme="dark"] .row-previsto {
  opacity: 0.65;
  font-style: italic;
  background: rgba(255, 255, 255, 0.02) !important;
}

[data-theme="dark"] .row-previsto:hover {
  background: rgba(255, 255, 255, 0.05) !important;
}

[data-theme="dark"] .row-ingreso {
  background: rgba(16, 185, 129, 0.04) !important;
}

[data-theme="dark"] .row-ingreso:hover {
  background: rgba(16, 185, 129, 0.08) !important;
}

[data-theme="dark"] .row-gasto {
  background: rgba(239, 68, 68, 0.03) !important;
}

[data-theme="dark"] .row-gasto:hover {
  background: rgba(239, 68, 68, 0.07) !important;
}

/* Filters */
[data-theme="dark"] .multi-filter-dropdown {
  background: #1a1a2e;
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .multi-filter-dropdown label {
  color: var(--text-main);
}

[data-theme="dark"] .multi-filter-dropdown label:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Inline white/light bg */
[data-theme="dark"] [style*="background: white"],
[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background: #fff"],
[data-theme="dark"] [style*="background:#ffffff"],
[data-theme="dark"] [style*="background: #ffffff"],
[data-theme="dark"] .bg-white {
  background: var(--bg-card) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] [style*="background: #f8fafc"],
[data-theme="dark"] [style*="background: #f1f5f9"],
[data-theme="dark"] [style*="background: #f9fafb"],
[data-theme="dark"] .bg-gray-50,
[data-theme="dark"] .bg-slate-50 {
  background: #181828 !important;
  color: var(--text-main) !important;
}

/* Inline borders — very subtle */
[data-theme="dark"] [style*="border: 1px solid #e"] {
  border-color: rgba(255, 255, 255, 0.04) !important;
}

[data-theme="dark"] [style*="border: 1px solid var(--border"] {
  border-color: rgba(255, 255, 255, 0.04) !important;
}

/* Force override blue utility classes */
[data-theme="dark"] .bg-blue-50,
[data-theme="dark"] .bg-blue-100 {
  background: rgba(255, 255, 255, 0.03) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] .text-blue-600 {
  color: var(--primary) !important;
}

[data-theme="dark"] .border-blue-200 {
  border-color: rgba(255, 255, 255, 0.05) !important;
}

[data-theme="neon"] .bg-blue-50,
[data-theme="neon"] .bg-blue-100 {
  background: #f0fdf4 !important;
  color: #15803d !important;
}

[data-theme="neon"] .text-blue-600 {
  color: #15803d !important;
}

[data-theme="neon"] .border-blue-200 {
  border-color: #e5e7eb !important;
}

/* Global icon fix */
[data-theme="neon"] i[style*="color: #3b82f6"],
[data-theme="dark"] i[style*="color: #3b82f6"],
[data-theme="neon"] svg[style*="color: #3b82f6"],
[data-theme="dark"] svg[style*="color: #3b82f6"] {
  color: var(--primary) !important;
}


/* Inline text colors */
[data-theme="dark"] [style*="color: var(--text-main)"],
[data-theme="dark"] [style*="color: #1e293b"],
[data-theme="dark"] [style*="color: #111827"] {
  color: var(--text-main) !important;
}

[data-theme="dark"] [style*="color: var(--text-muted)"],
[data-theme="dark"] [style*="color: #64748b"],
[data-theme="dark"] [style*="color: #6b7280"] {
  color: var(--text-muted) !important;
}

/* Modals */
[data-theme="dark"] .modal-content,
[data-theme="dark"] [id$="-modal"] {
  background: #111120 !important;
  color: var(--text-main) !important;
  border: 1px solid rgba(255, 255, 255, 0.04) !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7) !important;
}

/* Notification dropdown */
[data-theme="dark"] .notification-dropdown {
  background: #111120 !important;
  border: 1px solid rgba(255, 255, 255, 0.05) !important;
  color: var(--text-main) !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5) !important;
}

/* Banking section refinements for Dark Mode */
[data-theme="dark"] .mov-row {
  border-bottom-color: rgba(255, 255, 255, 0.04) !important;
}

[data-theme="dark"] .mov-row:hover {
  background: rgba(255, 255, 255, 0.02) !important;
}


* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  transition: var(--transition-fast);
}

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

.btn-primary {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: #ffffff !important;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(0, 0, 0, 0.1);
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

[data-theme="neon"] .btn-primary,
[data-theme="dark"] .btn-primary {
  color: #000000 !important;
  box-shadow: 0 4px 12px rgba(190, 242, 100, 0.2);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.3);
}

[data-theme="neon"] .btn-primary:hover,
[data-theme="dark"] .btn-primary:hover {
  box-shadow: 0 6px 18px rgba(190, 242, 100, 0.4);
}


@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* Animations */
.row-fade-out {
  animation: fadeOutRow 0.5s forwards;
  pointer-events: none;
}

@keyframes fadeOutRow {
  0% {
    opacity: 1;
    transform: translateX(0);
  }

  100% {
    opacity: 0;
    transform: translateX(20px);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
    border: none;
    overflow: hidden;
  }
}

/* Notifications Toast */
.undo-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: white;
  padding: 12px 24px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  z-index: 2000;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translate(-50%, 40px);
    opacity: 0;
  }

  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

.undo-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 4px 12px;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.8rem;
}

.undo-btn:hover {
  background: var(--primary-hover);
}

/* Filter Dropdowns */
.multi-filter-dropdown {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  gap: 8px;
  width: 200px;
  max-height: 300px;
  overflow-y: auto;
}

.multi-filter-dropdown label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.multi-filter-dropdown label:hover {
  background: #f1f5f9;
}

.multi-filter-dropdown input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.premium-select {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  transition: all 0.2s;
  outline: none;
}

.premium-select:hover {
  border-color: var(--primary);
  background: white;
}

.premium-input-ghost {
  border: none !important;
  background: transparent !important;
  padding: 8px 4px;
  /* Removed !important */
  width: 100%;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-main);
  outline: none;
  transition: all 0.2s;
}

.premium-input-ghost:focus {
  background: var(--bg-main) !important;
  border-radius: 6px;
}

#sidebar {
  flex: 0 0 220px;
  width: 220px;
  min-width: 220px;
  background: var(--nav-bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 200;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-x: hidden;
}

/* =============================================
   SIDEBAR AUTO-COLLAPSE
============================================= */
@media (min-width: 1024px) {
  #sidebar {
    flex: 0 0 66px;
    width: 66px;
    min-width: 66px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    align-items: center;
  }

  #sidebar:hover {
    flex: 0 0 220px;
    width: 220px;
    min-width: 220px;
    align-items: stretch;
  }

  #sidebar .sidebar-logo,
  #sidebar .sidebar-nav a,
  #sidebar .sidebar-footer button {
    white-space: nowrap;
  }

  #sidebar:not(:hover) .sidebar-logo {
    color: transparent;
    padding-left: 0;
    padding-right: 0;
    text-align: center;
    justify-content: center;
    height: 66px;
    overflow: hidden;
  }

  #sidebar:not(:hover) .sidebar-logo img {
    height: 50px;
    object-fit: cover;
    object-position: center top;
    clip-path: inset(0 0 44% 0);
  }

  #sidebar:hover .sidebar-logo {
    height: 100px;
    justify-content: flex-start;
    padding: 0.5rem 0.875rem;
  }

  #sidebar:hover .sidebar-logo img {
    height: 86px;
    width: auto;
    max-width: 180px;
    object-fit: contain;
    clip-path: none;
  }

  #sidebar:not(:hover) .sidebar-nav a {
    justify-content: center;
    padding: 0.6rem;
  }

  #sidebar:not(:hover) .sidebar-nav a i,
  #sidebar:not(:hover) .sidebar-nav a svg {
    margin-right: 0 !important;
  }

  #sidebar:not(:hover) .nav-text {
    display: none;
  }

  #sidebar:not(:hover) .sidebar-footer {
    align-items: center;
  }

  #sidebar:not(:hover) .sidebar-footer button {
    justify-content: center;
  }

  #sidebar:not(:hover) .sidebar-footer button i,
  #sidebar:not(:hover) .sidebar-footer button svg {
    margin-right: 0 !important;
  }

  #sidebar:not(:hover) .notification-count {
    display: none !important;
  }
}

/* =============================================
   RESPONSIVE MODALS & GRIDS
============================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
  overflow-y: auto;
  backdrop-filter: blur(4px);
}

.modal-content-card {
  background: var(--bg-card);
  width: 100%;
  max-width: 650px;
  padding: 2.5rem;
  border-radius: 24px;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
  position: relative;
  margin: auto;
}

.responsive-grid {
  display: grid;
  gap: 1.5rem;
}

.grid-cols-2 {
  grid-template-columns: 1fr 1fr;
}

.grid-cols-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.grid-cols-4 {
  grid-template-columns: 1fr 1fr 1fr 1fr;
}

.col-span-2 {
  grid-column: span 2;
}

.col-span-3 {
  grid-column: span 3;
}

.col-span-4 {
  grid-column: span 4;
}

.session-row {
  display: grid;
  grid-template-columns: 1.25fr 1fr 0.8fr 44px;
  gap: 0.75rem;
  align-items: center;
}

@media (max-width: 768px) {
  .modal-overlay {
    padding: 0.5rem !important;
    align-items: flex-start !important;
  }

  .modal-content-card {
    padding: 1.5rem 1.25rem !important;
    border-radius: 16px !important;
    width: 100% !important;
    margin: 0 !important;
    max-height: none !important;
  }

  .responsive-grid,
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }

  .col-span-2,
  .col-span-3,
  .col-span-4 {
    grid-column: span 1 !important;
  }

  .session-row {
    grid-template-columns: 1fr 1fr !important;
  }
}
/* =============================================
   STICKY HEADERS - Ventas, Gastos, Formaciones
============================================= */

/* Main wrappers shouldn't hide sticky elements on desktop */
#ventas-wrapper, #gastos-wrapper, #formaciones-wrapper {
    overflow: visible; /* Let th stick on desktop */
}

/* The Table Wrapper (if we add one in JS, or we attach to 'th') */
#ventas-wrapper table thead th,
#gastos-wrapper table thead th,
#formaciones-wrapper table thead th {
    position: sticky;
    top: 86px; /* Right below the filters row which takes ~60px height + 16px margin */
    z-index: 90;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05); /* Optional to delineate sticking headers from content */
}

/* On mobile, adjust for top bar (52px) and fix table overflow */
@media (max-width: 1024px) {
    .table-responsive {
        max-height: 65vh; /* Create a constrained vertical scrolling box for the table */
        overflow-x: auto !important; /* Horizontally scrollable */
        overflow-y: auto !important; /* Vertically scrollable */
        margin-left: -1.5rem; /* Full bleed on mobile adjusting for card padding */
        margin-right: -1.5rem;
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
    }
    
    #ventas-wrapper table thead th,
    #gastos-wrapper table thead th,
    #formaciones-wrapper table thead th {
        position: sticky !important; /* Enable sticky header INSIDE the .table-responsive box */
        top: 0px !important; /* Sticks to the top of the .table-responsive wrapper, not the screen */
        z-index: 80; /* Slightly lower but above rows */
        box-shadow: 0 2px 4px rgba(0,0,0,0.1); /* Add shadow to indicate it's floating */
    }
}

/* Sticky Header Backgrounds */
#ventas-wrapper table thead th,
#gastos-wrapper table thead th,
#formaciones-wrapper table thead th {
    background-color: var(--bg-main) !important;
}

[data-theme="dark"] #ventas-wrapper table thead th,
[data-theme="dark"] #gastos-wrapper table thead th,
[data-theme="dark"] #formaciones-wrapper table thead th {
    background-color: #0f0f1c !important;
}

.filters-sticky {
    position: sticky;
    top: 0px; 
    z-index: 100;
    margin-top: 0 !important;
}

@media (max-width: 1024px) {
    .filters-sticky {
        top: 52px;
    }
}

/* Ocultar el hueco transparente usando pseudo-elemento en los filtros-sticky o thead */
.filters-sticky::after {
    content: '';
    position: absolute;
    bottom: -1.1rem; /* Cubre el marginBottom de 1rem y un extra */
    left: -1.5rem; /* Ajustar para extender hasta los bordes del padding del card si es necesario */
    right: -1.5rem;
    height: 1.1rem;
    background: var(--bg-main);
    pointer-events: none;
}

[data-theme="dark"] .filters-sticky::after {
    background: var(--bg-main);
}
