/* Modern Enterprise & Academic ERP Theme for Simulador Integral de Sistema Contable */
:root {
  --primary-navy: #0f172a;
  --secondary-slate: #1e293b;
  --accent-blue: #2563eb;
  --accent-blue-hover: #1d4ed8;
  --accent-teal: #0d9488;
  --success-emerald: #059669;
  --warning-amber: #d97706;
  --danger-rose: #e11d48;
  --bg-light: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --sidebar-width: 270px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-light);
  color: var(--text-main);
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
}

/* Sidebar Styling — TONO CLARO (institucional) */
#sidebar-wrapper {
  /* Altura FIJA, no mínima: con `min-height` la barra crece más allá de la pantalla y,
     al ser `position: fixed`, el final del menú queda inalcanzable (había que alejar con
     Ctrl+ para verlo). Con `height: 100vh` la barra se desplaza por dentro y se llega a
     todos los enlaces con la rueda del ratón. */
  height: 100vh;
  max-height: 100vh;
  width: var(--sidebar-width);
  background: #ffffff;
  border-right: 1px solid var(--border-color);
  color: var(--text-main);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1040;
  transition: all 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  box-shadow: 2px 0 12px rgba(15, 23, 42, 0.06);
}

/* Barra de desplazamiento visible en la barra lateral (Chrome/Edge/Safari) */
#sidebar-wrapper::-webkit-scrollbar {
  width: 10px;
}

#sidebar-wrapper::-webkit-scrollbar-track {
  background: #f8fafc;
}

#sidebar-wrapper::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 6px;
  border: 2px solid #f8fafc;
}

#sidebar-wrapper::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.sidebar-heading {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border-color);
  background: #f8fafc;
}

.sidebar-heading h5 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--primary-navy);
}

.sidebar-heading .subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.nav-section-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  padding: 1rem 1.25rem 0.35rem;
  font-weight: 700;
}

.sidebar-link {
  display: flex;
  align-items: center;
  padding: 0.55rem 1.25rem;
  color: #334155;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.2s ease;
}

.sidebar-link i {
  font-size: 1.1rem;
  width: 1.6rem;
  margin-right: 0.5rem;
  color: #64748b;
  transition: color 0.2s ease;
}

.sidebar-link:hover {
  color: var(--accent-blue-hover);
  background-color: #f1f5f9;
  border-left-color: var(--accent-blue);
}

.sidebar-link:hover i {
  color: var(--accent-blue);
}

.sidebar-link.active {
  color: #1d4ed8;
  background-color: #eff6ff;
  border-left-color: var(--accent-blue);
  font-weight: 600;
}

.sidebar-link.active i {
  color: var(--accent-blue);
}

/* Main Content Area */
#page-content-wrapper {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}

/* Topbar */
.topbar {
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  position: sticky;
  top: 0;
  z-index: 1030;
}

/* Global Search Autocomplete */
.search-container {
  position: relative;
  width: 380px;
}

.search-input {
  background-color: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 0.45rem 1rem 0.45rem 2.25rem;
  font-size: 0.85rem;
  width: 100%;
  transition: all 0.2s ease;
}

.search-input:focus {
  background-color: #ffffff;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: none;
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 0.85rem;
}

.search-dropdown {
  position: absolute;
  top: 105%;
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  max-height: 380px;
  overflow-y: auto;
  z-index: 1050;
  display: none;
}

.search-group-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  background: #f8fafc;
  padding: 0.4rem 0.8rem;
  border-bottom: 1px solid #e2e8f0;
}

.search-item {
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.83rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
}

.search-item:hover {
  background-color: #eff6ff;
}

/* KPI Cards */
.kpi-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.06);
}

.kpi-card .kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.kpi-card .kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.kpi-card .kpi-value {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--primary-navy);
  letter-spacing: -0.02em;
}

/* Tables */
.table-custom {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
}

.table-custom th {
  background-color: #f8fafc;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.table-custom td {
  padding: 0.85rem 1rem;
  font-size: 0.86rem;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
}

.table-custom tbody tr:hover {
  background-color: #f8fafc;
}

/* Journal Live Debit/Credit Balancer Banner */
.balance-banner {
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.balance-banner.balanced {
  background-color: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.balance-banner.unbalanced {
  background-color: #fff1f2;
  border: 1px solid #fecdd3;
  color: #9f1239;
}

/* Responsive Rules */
@media (max-width: 992px) {
  #sidebar-wrapper {
    margin-left: calc(-1 * var(--sidebar-width));
  }
  #sidebar-wrapper.active {
    margin-left: 0;
  }
  #page-content-wrapper {
    margin-left: 0;
    width: 100%;
  }
  .search-container {
    width: 220px;
  }
}
