/* ============================================================
 * Motorea — override del tema de Modernize (naranja + carbón)
 * Se carga DESPUÉS de styles.css. El selector [data-color-theme="Motorea_Theme"]
 * en <html> activa este tema en vez de Blue_Theme (el nombre se conserva: está
 * en cada vista).
 * ============================================================ */

/* Primario y estados. --bs-primary es el naranja 700 (texto blanco encima
   5.18:1). El acento 600 (3.56:1) queda en --bs-secondary: sólo formas, nunca
   botones ni texto. Estados de BRAND.md §4: relleno sólido = texto blanco. */
[data-bs-theme=light][data-color-theme="Motorea_Theme"]:root {
  --bs-primary:             #C2410C;
  --bs-primary-rgb:         194, 65, 12;
  --bs-light-primary:       rgba(194,65,12, 0.1);
  --bs-primary-bg-subtle:   #FFF7ED;
  --bs-primary-border-subtle:#FED7AA;
  --bs-primary-text-emphasis:#9A3412;
  --bs-secondary:           #EA580C;
  --bs-secondary-rgb:       234, 88, 12;
  --bs-light-secondary:     rgba(234,88,12, 0.1);
  --bs-secondary-bg-subtle: rgba(234,88,12, 0.1);

  --bs-success:             #15803D;
  --bs-success-rgb:         21, 128, 61;
  --bs-success-bg-subtle:   #F0FDF4;
  --bs-success-border-subtle:#BBF7D0;
  --bs-success-text-emphasis:#15803D;
  --bs-warning:             #B45309;
  --bs-warning-rgb:         180, 83, 9;
  --bs-warning-bg-subtle:   #FFFBEB;
  --bs-warning-border-subtle:#FDE68A;
  --bs-warning-text-emphasis:#B45309;
  --bs-danger:              #B91C1C;
  --bs-danger-rgb:          185, 28, 28;
  --bs-danger-bg-subtle:    #FEF2F2;
  --bs-danger-border-subtle:#FECACA;
  --bs-danger-text-emphasis:#B91C1C;
  --bs-info:                #0369A1;
  --bs-info-rgb:            3, 105, 161;
  --bs-info-bg-subtle:      #F0F9FF;
  --bs-info-border-subtle:  #BAE6FD;
  --bs-info-text-emphasis:  #0369A1;
}

/* Botones de estado: Modernize fija sus colores con hex dentro de cada clase
   (no lee --bs-success), así que se repiten aquí. Sólido = fondo del estado +
   texto blanco; outline = texto del estado sobre blanco, y al pasar el mouse
   se rellena con el mismo estado. Las variantes "light"/subtle no se tocan:
   siguen con fondo tenue y texto del estado. */
[data-bs-theme=light][data-color-theme="Motorea_Theme"]:root .btn-success {
  --bs-btn-bg: #15803D; --bs-btn-border-color: #15803D;
  --bs-btn-hover-bg: #166534; --bs-btn-hover-border-color: #166534;
  --bs-btn-active-bg: #14532D; --bs-btn-active-border-color: #14532D;
  --bs-btn-disabled-bg: #15803D; --bs-btn-disabled-border-color: #15803D;
  --bs-btn-focus-shadow-rgb: 21, 128, 61;
}
[data-bs-theme=light][data-color-theme="Motorea_Theme"]:root .btn-warning {
  --bs-btn-bg: #B45309; --bs-btn-border-color: #B45309;
  --bs-btn-hover-bg: #92400E; --bs-btn-hover-border-color: #92400E;
  --bs-btn-active-bg: #78350F; --bs-btn-active-border-color: #78350F;
  --bs-btn-disabled-bg: #B45309; --bs-btn-disabled-border-color: #B45309;
  --bs-btn-focus-shadow-rgb: 180, 83, 9;
}
[data-bs-theme=light][data-color-theme="Motorea_Theme"]:root .btn-danger {
  --bs-btn-bg: #B91C1C; --bs-btn-border-color: #B91C1C;
  --bs-btn-hover-bg: #991B1B; --bs-btn-hover-border-color: #991B1B;
  --bs-btn-active-bg: #7F1D1D; --bs-btn-active-border-color: #7F1D1D;
  --bs-btn-disabled-bg: #B91C1C; --bs-btn-disabled-border-color: #B91C1C;
  --bs-btn-focus-shadow-rgb: 185, 28, 28;
}
[data-bs-theme=light][data-color-theme="Motorea_Theme"]:root .btn-info {
  --bs-btn-bg: #0369A1; --bs-btn-border-color: #0369A1;
  --bs-btn-hover-bg: #075985; --bs-btn-hover-border-color: #075985;
  --bs-btn-active-bg: #0C4A6E; --bs-btn-active-border-color: #0C4A6E;
  --bs-btn-disabled-bg: #0369A1; --bs-btn-disabled-border-color: #0369A1;
  --bs-btn-focus-shadow-rgb: 3, 105, 161;
}
[data-bs-theme=light][data-color-theme="Motorea_Theme"]:root .btn-outline-success {
  --bs-btn-color: #15803D; --bs-btn-border-color: #15803D;
  --bs-btn-hover-bg: #15803D; --bs-btn-hover-border-color: #15803D;
  --bs-btn-active-bg: #15803D; --bs-btn-active-border-color: #15803D;
  --bs-btn-disabled-color: #15803D; --bs-btn-disabled-border-color: #15803D;
  --bs-btn-focus-shadow-rgb: 21, 128, 61;
}
[data-bs-theme=light][data-color-theme="Motorea_Theme"]:root .btn-outline-warning {
  --bs-btn-color: #B45309; --bs-btn-border-color: #B45309;
  --bs-btn-hover-bg: #B45309; --bs-btn-hover-border-color: #B45309;
  --bs-btn-active-bg: #B45309; --bs-btn-active-border-color: #B45309;
  --bs-btn-disabled-color: #B45309; --bs-btn-disabled-border-color: #B45309;
  --bs-btn-focus-shadow-rgb: 180, 83, 9;
}
[data-bs-theme=light][data-color-theme="Motorea_Theme"]:root .btn-outline-danger {
  --bs-btn-color: #B91C1C; --bs-btn-border-color: #B91C1C;
  --bs-btn-hover-bg: #B91C1C; --bs-btn-hover-border-color: #B91C1C;
  --bs-btn-active-bg: #B91C1C; --bs-btn-active-border-color: #B91C1C;
  --bs-btn-disabled-color: #B91C1C; --bs-btn-disabled-border-color: #B91C1C;
  --bs-btn-focus-shadow-rgb: 185, 28, 28;
}
[data-bs-theme=light][data-color-theme="Motorea_Theme"]:root .btn-outline-info {
  --bs-btn-color: #0369A1; --bs-btn-border-color: #0369A1;
  --bs-btn-hover-bg: #0369A1; --bs-btn-hover-border-color: #0369A1;
  --bs-btn-active-bg: #0369A1; --bs-btn-active-border-color: #0369A1;
  --bs-btn-disabled-color: #0369A1; --bs-btn-disabled-border-color: #0369A1;
  --bs-btn-focus-shadow-rgb: 3, 105, 161;
}

/* btn-primary */
[data-bs-theme=light][data-color-theme="Motorea_Theme"]:root .btn-primary {
  --bs-btn-bg:                 #C2410C;
  --bs-btn-border-color:       #C2410C;
  --bs-btn-hover-bg:           #9A3412;
  --bs-btn-hover-border-color: #9A3412;
  --bs-btn-active-bg:          #9A3412;
  --bs-btn-active-border-color:#9A3412;
}

/* btn-outline-primary */
[data-bs-theme=light][data-color-theme="Motorea_Theme"]:root .btn-outline-primary {
  --bs-btn-color:              #C2410C;
  --bs-btn-border-color:       #C2410C;
  --bs-btn-hover-bg:           #C2410C;
  --bs-btn-hover-border-color: #C2410C;
  --bs-btn-hover-color:        #fff;
  --bs-btn-active-bg:          #9A3412;
  --bs-btn-active-border-color:#9A3412;
  --bs-btn-active-color:       #fff;
}

/* Sidebar — fondo carbón con acentos naranja claro */
[data-color-theme="Motorea_Theme"] .left-sidebar {
  background-color: #1F2328 !important;
}
[data-color-theme="Motorea_Theme"] .left-sidebar .sidebar-link,
[data-color-theme="Motorea_Theme"] .left-sidebar .hide-menu {
  color: rgba(255, 255, 255, 0.75);
}
[data-color-theme="Motorea_Theme"] .left-sidebar .nav-small-cap {
  color: rgba(255, 255, 255, 0.4);
}
[data-color-theme="Motorea_Theme"] .left-sidebar .nav-small-cap-icon {
  color: rgba(255, 255, 255, 0.3);
}
[data-color-theme="Motorea_Theme"] .left-sidebar .sidebar-link:hover {
  background-color: rgba(234,88,12, 0.15);
  color: #FED7AA !important;
}
[data-color-theme="Motorea_Theme"] .left-sidebar .sidebar-link:hover .hide-menu {
  color: #FED7AA;
}
[data-color-theme="Motorea_Theme"] .left-sidebar .sidebar-link.active,
[data-color-theme="Motorea_Theme"] .left-sidebar .sidebar-item.selected > .sidebar-link {
  background-color: rgba(234,88,12, 0.2);
  color: #FED7AA !important;
}
[data-color-theme="Motorea_Theme"] .left-sidebar .sidebar-link.active .hide-menu {
  color: #FED7AA;
}
/* Brand-logo container — keep Modernize's 70px min-height. Horizontal padding
   tuned so the logo's leading edge sits at the same X as the first-level
   sidebar icon (link padding-left + .sidebar-item start). */
[data-color-theme="Motorea_Theme"] .left-sidebar .brand-logo {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0 34px;
}
/* Mini sidebar (87px rail): zero horizontal padding + center, so the 32px
   mark glyph sits in the middle of the rail and isn't clipped by the
   34px padding used in expanded state. !important needed because Modernize's
   .brand-logo carries Bootstrap utility .justify-content-between inline. */
body[data-sidebartype="mini-sidebar"]
  [data-color-theme="Motorea_Theme"] .left-sidebar .brand-logo,
[data-color-theme="Motorea_Theme"]
  body[data-sidebartype="mini-sidebar"] .left-sidebar .brand-logo {
  padding: 0 !important;
  justify-content: center !important;
}
/* Center the 32px mark glyph in mini mode. The <a> wrapper is `display:block`
   with intrinsic width 40 (text-nowrap), so we force text-align center inside
   it so the inline-block logo-mini sits in the middle of the wrapper. */
body[data-sidebartype="mini-sidebar"]
  [data-color-theme="Motorea_Theme"] .left-sidebar .brand-logo a.logo-img,
[data-color-theme="Motorea_Theme"]
  body[data-sidebartype="mini-sidebar"] .left-sidebar .brand-logo a.logo-img {
  text-align: center;
}
[data-color-theme="Motorea_Theme"] .left-sidebar .sidebartoggler {
  color: rgba(255, 255, 255, 0.6);
}

/* has-arrow chevron — Modernize default color is too dark on charcoal sidebar.
   Use white-ish so the expand affordance is visible. */
[data-color-theme="Motorea_Theme"] .left-sidebar .sidebar-link.has-arrow::after {
  border-color: rgba(255, 255, 255, 0.65) !important;
  width: 8px !important;
  height: 8px !important;
}
[data-color-theme="Motorea_Theme"] .left-sidebar .sidebar-link.has-arrow:hover::after,
[data-color-theme="Motorea_Theme"] .left-sidebar .sidebar-link.has-arrow.active::after {
  border-color: #FED7AA !important;
}
/* Long module labels ("Entrega de Matrículas", "Cuentas por Cobrar") ran
   under the chevron: reserve its room and let the label wrap to a second line. */
[data-color-theme="Motorea_Theme"] .left-sidebar .sidebar-link.has-arrow {
  padding-right: 34px;
}
[data-color-theme="Motorea_Theme"] .left-sidebar .sidebar-link.has-arrow .hide-menu {
  white-space: normal;
  line-height: 1.3;
  min-width: 0;
}
[data-color-theme="Motorea_Theme"] .left-sidebar .sidebar-link.has-arrow::after {
  top: 50%;
}
[data-color-theme="Motorea_Theme"] .left-sidebar .simplebar-scrollbar::before {
  background: rgba(255, 255, 255, 0.2);
}

/* Global primary */
[data-color-theme="Motorea_Theme"] .bg-primary { background-color: #C2410C !important; }
/* .text-bg-primary lee --bs-primary-rgb con texto blanco; se fija igual que
   .bg-primary para que las píldoras sigan en AA. */
[data-color-theme="Motorea_Theme"] .text-bg-primary { background-color: #C2410C !important; }
/* text-primary y el <a> genérico son texto sobre fondo claro: #C2410C pasa AA
   (5.18:1); el acento #EA580C no (3.56:1). */
[data-color-theme="Motorea_Theme"] .text-primary { color: #C2410C !important; }
[data-color-theme="Motorea_Theme"] .border-primary { border-color: #C2410C !important; }
[data-color-theme="Motorea_Theme"] a:not(.btn):not(.nav-link):not(.sidebar-link):not(.sidebar-menu-link):not(.dropdown-item) {
  color: #C2410C;
}
/* El selector con cinco :not() mide (0,6,1) y le gana a `a:hover` de
   app-tokens.css, así que el hover (naranja 800 + subrayado) se declara AQUÍ. */
[data-color-theme="Motorea_Theme"] a:not(.btn):not(.nav-link):not(.sidebar-link):not(.sidebar-menu-link):not(.dropdown-item):hover {
  color: #9A3412;
  text-decoration: underline;
}

/* Tint helpers */
[data-color-theme="Motorea_Theme"] .bg-light-primary {
  background-color: rgba(234,88,12, 0.1) !important;
}
[data-color-theme="Motorea_Theme"] .bg-light-success {
  background-color: rgba(21, 128, 61, 0.1) !important;
}

/* Page background warm white — light mode only */
[data-bs-theme=light][data-color-theme="Motorea_Theme"] body {
  background-color: #F7F7F5;
}

/* Card radius */
[data-color-theme="Motorea_Theme"] .card {
  border-radius: 12px;
}

/* Sub-link spacing — Modernize default gap 23px + sidebar-icon margin-right 35px
   eats ~60px of horizontal space before text starts. On our 250px sidebar that
   clips long labels (e.g. "Catálogo de Productos"). Tighten gap + bullet box. */
[data-color-theme="Motorea_Theme"] .left-sidebar
  .sidebar-nav ul .sidebar-item .first-level .sidebar-item > .sidebar-link {
  gap: 12px;
}
/* Submenu bullets — Modernize wraps each in .round-16, but .round-16 has no
   width-lock. Lock the bullet box and align it under top-level icons.
   Top-level icon X = 34 (sidebar-item start 24 + link padding-left 10).
   Sub-link padding-left 10 → bullet margin-left 0 → bullet at x=34, same column. */
[data-color-theme="Motorea_Theme"] .left-sidebar
  .sidebar-nav .first-level .sidebar-item > .sidebar-link .round-16 {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  margin-left: 0;
  margin-right: 0;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
[data-color-theme="Motorea_Theme"] .left-sidebar
  .sidebar-nav .first-level .sidebar-link .ti-circle {
  font-size: 8px;
  line-height: 1;
}

/* Reclaim charcoal void below nav — Modernize default was -175px for a
   layout w/ topbar inside sidebar; ours has topbar outside. */
[data-color-theme="Motorea_Theme"] .left-sidebar .scroll-sidebar {
  height: calc(100vh - 90px);
}

/* Scroll affordance — bottom fade mask. BPIS: macOS/Linear/Stripe pattern. */
[data-color-theme="Motorea_Theme"] .left-sidebar .scroll-sidebar {
  -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 28px), transparent 100%);
          mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 28px), transparent 100%);
}

/* ============================================================
 * Mini-sidebar BPIS — JS-driven flyout submenus
 * ------------------------------------------------------------
 * Pattern: Linear/Notion/Tabler. Rail stays 87px in mini state.
 * Flyout is a single shared <div id="bs-bpis-flyout"> appended
 * to <body> by bs-sidebar-mini.js using position:fixed. This
 * escapes the simplebar/.scroll-sidebar overflow chain without
 * needing overflow:visible hacks on the rail.
 *
 * Rules in this section:
 *   1. Lock rail width to 87px on hover (kill Modernize's
 *      hover-inflate). Scoped to body[data-sidebartype] only
 *      (no [data-color-theme] requirement) so it works on any
 *      page regardless of theme attribute presence.
 *   2. Suppress inline submenu display in mini.
 *   3. Style the flyout container + its child list.
 * ============================================================ */

/* (1) Lock rail width across ALL color themes. Modernize ships
   .left-sidebar:hover { width:270px } that we must beat. */
body[data-sidebartype="mini-sidebar"] .left-sidebar:hover {
  width: 87px !important;
}
body[data-sidebartype="mini-sidebar"] .left-sidebar:hover .hide-menu {
  display: none !important;
}
body[data-sidebartype="mini-sidebar"] .left-sidebar:hover .sidebar-nav .has-arrow::after {
  display: none !important;
}
body[data-sidebartype="mini-sidebar"] .left-sidebar:hover .sidebar-nav ul .sidebar-item .sidebar-link {
  padding: 11px 9px !important;
}
body[data-sidebartype="mini-sidebar"] .left-sidebar:hover .logo-img {
  width: 40px !important;
}
/* Mark glyph swap on rail hover — keep showing the mini logo,
   not the wide horizontal one. */
body[data-sidebartype="mini-sidebar"] .left-sidebar:hover .logo-full {
  display: none !important;
}
body[data-sidebartype="mini-sidebar"] .left-sidebar:hover .logo-mini {
  display: inline-block !important;
}

/* (2) Hide ANY inline submenu unconditionally in mini. Covers
   the case where Bootstrap left .collapse.show on the <ul>. */
body[data-sidebartype="mini-sidebar"] .left-sidebar .sidebar-nav .first-level {
  display: none !important;
  height: auto !important;
}

/* (3) Flyout container — JS sets position/top/left inline.
   Styles below cover everything else. Uses a fixed-position
   panel so the simplebar overflow chain doesn't clip it. */
.bs-bpis-flyout {
  background: #1F2328;
  color: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 6px;
  min-width: 240px;
  max-width: 280px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.14s ease-out, transform 0.14s ease-out;
}
.bs-bpis-flyout.show {
  opacity: 1;
  transform: translateX(0);
}
.bs-bpis-flyout.label-only {
  min-width: 0;
  max-width: none;
  padding: 0;
}
.bs-bpis-flyout.label-only .bs-bpis-flyout-header {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: rgba(255, 255, 255, 0.92);
  padding: 6px 10px;
  border-bottom: 0;
  white-space: nowrap;
}
.bs-bpis-flyout-header {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.55);
  padding: 6px 10px 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.bs-bpis-flyout-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.bs-bpis-flyout-list .sidebar-item {
  list-style: none;
}
.bs-bpis-flyout-list .sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  border-radius: 6px;
  font-size: 13px;
  white-space: normal;
  line-height: 1.3;
}
.bs-bpis-flyout-list .sidebar-link .hide-menu {
  display: inline-block;
  color: inherit;
}
.bs-bpis-flyout-list .sidebar-link:hover {
  background-color: rgba(234,88,12, 0.18);
}
.bs-bpis-flyout-list .sidebar-link:hover,
.bs-bpis-flyout-list .sidebar-link:hover .hide-menu {
  color: #FED7AA;
}
.bs-bpis-flyout-list .round-16 {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bs-bpis-flyout-list .ti-circle {
  font-size: 8px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.55);
}

/* Group label — replaces a.has-arrow inside the flyout clone.
 * The flyout escapes #sidebarnav, so a 3rd-level group header has
 * nothing to toggle (its children are already flattened/expanded by
 * bs-sidebar-mini.js). Reads as a quiet section heading, not a button:
 * no border, no hover state, no pointer cursor. */
.bs-bpis-flyout-group {
  display: block;
  padding: 10px 10px 4px;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  /* Quieter than a real link: #FED7AA (--brand-200) is the exact hover
   * color of a clickable leaf below (line ~308) — painting the
   * non-interactive label in that same teal made the dead text glow
   * brighter than the real links, backwards from the intent. */
  color: rgba(255, 255, 255, 0.45);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  cursor: default;
  user-select: none;
}
/* Only the first group header of the TOP-LEVEL flyout list loses its
 * separator. ".bs-bpis-flyout-list" is the class buildFlyoutContent()
 * adds to the outer clone only — nested <ul>s keep .second-level /
 * .third-level instead, never .bs-bpis-flyout-list — so the direct-child
 * combinator here scopes this to the outer list's own first <li>. A
 * descendant selector (no ">") would also match the first <li> of every
 * nested list and strip the separator from THEIR first group too. */
.bs-bpis-flyout-list > li:first-child > .bs-bpis-flyout-group {
  margin-top: 0;
  border-top: 0;
}
/* Nested lists lose Bootstrap's .collapse but keep .second-level /
 * .third-level (app.css) for indentation + the teal guide line —
 * that rule isn't scoped to #sidebarnav, it already applies here. */


/* Los estados de la familia son oscuros (BRAND.md §4): letra negra encima no se lee
 * (bg-warning text-dark = 2.5:1, 43 usos). Letra blanca, 5.0-6.5:1. */
.bg-primary.text-dark, .bg-success.text-dark, .bg-danger.text-dark,
.bg-warning.text-dark, .bg-info.text-dark { color: #fff !important; }
