/* RM — modo noche (6 pm a 6 am, hora de Mexico). Lo activa tema-noche.js con <html data-tema="noche">.
   Casi todo se resuelve cambiando las variables de color que ya usa cada pagina; abajo van solo los pocos
   colores que estaban escritos a mano. No aplica al imprimir (los reportes/PDF siguen en blanco). */

@media not print {

  html[data-tema="noche"]{
    color-scheme: dark;
    /* paleta compartida (login, inicio, taller, mantenimiento, profit, usuarios) */
    --black:#0F0E0C; --charcoal:#1A1815; --charcoal-2:#26231F; --charcoal-3:#332F29;
    --border:#3B3730; --white:#F3EFE7; --gray:#B2AB9E; --gray-dim:#8A8376;
    --shadow:0 8px 24px rgba(0,0,0,.55);
    /* inventario (Renta de Maquinaria) */
    --bg-page:#0F0E0C; --bg-header:#171512; --surface-1:#1A1815; --surface-2:#26231F; --surface-3:#332F29;
    --border-strong:rgba(243,239,231,.22);
    --text-primary:#F3EFE7; --text-secondary:#B2AB9E; --text-muted:#8A8376;
    /* El azul marino de dia (--gold:#2A4D7A) casi no se ve sobre un fondo casi negro, asi que en modo
       noche se aclara — mismo criterio que ya se uso en la maqueta de la propuesta de colores. */
    --gold:#6E97D1; --gold-dim:#4A6FA0; --gold-strong:#4A6FA0; --gold-soft:rgba(110,151,209,.22);
  }
  html[data-tema="noche"], html[data-tema="noche"] body{ background:#0F0E0C; }
  html[data-tema="noche"] body{ color:#F3EFE7; }

  /* ---------- Barra superior y menus ---------- */
  html[data-tema="noche"] #rm-topbar{ background:#151311 !important; border-bottom-color:#6E97D1 !important; }
  html[data-tema="noche"] #rm-topbar a[data-rmnav]{ color:#F3EFE7 !important; }
  html[data-tema="noche"] #rm-topbar a[data-rmnav].rm-nav-active{ background:#6E97D1 !important; color:#FFFFFF !important; }
  html[data-tema="noche"] #rm-topbar a[data-rmnav]:hover{ background:rgba(255,255,255,.08); }
  html[data-tema="noche"] #rm-logout-btn, html[data-tema="noche"] #logoutBtn{ color:#D8D2C6 !important; border-color:#4A453D !important; }
  html[data-tema="noche"] img.rm-logo-noche{ display:block !important; }
  html[data-tema="noche"] img.rm-logo-dia{ display:none !important; }
  img.rm-logo-noche{ display:none; }
  @media (min-width:860px){
    html[data-tema="noche"] #rm-topbar{
      background:color-mix(in srgb, #151311 50%, transparent) !important;
      -webkit-backdrop-filter:blur(18px) saturate(170%); backdrop-filter:blur(18px) saturate(170%);
    }
    html[data-tema="noche"] #rm-topbar:hover, html[data-tema="noche"] #rm-topbar:focus-within{
      background:color-mix(in srgb, #151311 80%, transparent) !important;
    }
  }
  html[data-tema="noche"] .rmnav-menu{ background:rgba(30,28,25,.94) !important; border-color:#3B3730 !important; box-shadow:0 16px 36px rgba(0,0,0,.6); }
  html[data-tema="noche"] .rmnav-menu a{ color:#F3EFE7 !important; }
  html[data-tema="noche"] .rmnav-menu a:hover{ background:#2E2A25 !important; }

  /* ---------- Encabezados ---------- */
  html[data-tema="noche"] header{ background:linear-gradient(180deg,#1B1916,#141210); }
  html[data-tema="noche"] #topbar{ background:#151311; }
  html[data-tema="noche"] .hero{
    background: radial-gradient(120% 160% at 4% -10%, rgba(110,151,209,.16), transparent 55%), linear-gradient(180deg,#1E1C19,#171512);
    box-shadow:0 14px 34px rgba(0,0,0,.45);
  }
  html[data-tema="noche"] .hero-badge-logo{ background:#fff; }
  html[data-tema="noche"] .hero-date{ background:rgba(110,151,209,.16); border-color:rgba(110,151,209,.38); }

  /* ---------- Campos y avisos ---------- */
  html[data-tema="noche"] input:focus, html[data-tema="noche"] select:focus, html[data-tema="noche"] textarea:focus{ background:#2E2618; }
  html[data-tema="noche"] .storage-banner{ background:rgba(201,122,22,.16); border-color:rgba(201,122,22,.4); color:#F5B15C; }
  html[data-tema="noche"] .folio{ background:rgba(110,151,209,.16); border-color:rgba(110,151,209,.42); }
  html[data-tema="noche"] .horometro-ok{ background:rgba(30,143,78,.22); color:#5FD08B; }
  html[data-tema="noche"] .horometro-cerca{ background:rgba(201,122,22,.20); color:#F5B15C; }
  html[data-tema="noche"] .horometro-vencido{ background:rgba(192,64,42,.26); color:#FF8A75; }
  html[data-tema="noche"] .mec-widget.semana{ background:rgba(110,151,209,.12); border-color:rgba(110,151,209,.35); }

  /* ---------- Botones de cristal (liquid glass) en modo noche ---------- */
  html[data-tema="noche"] .btn-ghost, html[data-tema="noche"] .order-toggle, html[data-tema="noche"] .push-btn, html[data-tema="noche"] .ajuste-btn{
    color:#E8E2D6; border-color:rgba(255,255,255,.14);
    background:
      radial-gradient(110px 46px at var(--lx, 50%) var(--ly, -10%), rgba(255,255,255,.22), rgba(255,255,255,0) 70%),
      linear-gradient(180deg, rgba(255,255,255,.14) 0%, rgba(255,255,255,.05) 100%);
    box-shadow: inset 0 1.5px 0 rgba(255,255,255,.22), inset 0 -1px 1px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.06), 0 6px 16px rgba(0,0,0,.45);
  }
  html[data-tema="noche"] .btn-ghost:hover, html[data-tema="noche"] .order-toggle:hover, html[data-tema="noche"] .push-btn:hover, html[data-tema="noche"] .ajuste-btn:hover{
    color:#AECBF0; box-shadow: inset 0 1.5px 0 rgba(255,255,255,.28), 0 0 0 1px rgba(255,255,255,.10), 0 10px 22px rgba(0,0,0,.55);
  }

  /* ---------- Burbuja "Ver detalles" (mantenimiento) ---------- */
  html[data-tema="noche"] .det-sheet{ background:rgba(28,26,23,.95); border-color:rgba(255,255,255,.08); color:#F3EFE7; box-shadow:0 40px 100px rgba(0,0,0,.7); }
  html[data-tema="noche"] .det-head{ background:linear-gradient(180deg,rgba(40,37,32,.92),rgba(28,26,23,.75)); border-bottom-color:rgba(255,255,255,.08); }
  html[data-tema="noche"] .det-head h3{ color:#F3EFE7; }
  html[data-tema="noche"] .det-head p{ color:#B2AB9E; }
  html[data-tema="noche"] .det-close{ background:rgba(255,255,255,.12); color:#E8E2D6; }
  html[data-tema="noche"] .det-close:hover{ background:rgba(255,255,255,.22); }
  html[data-tema="noche"] .det-resumen{ background:rgba(255,255,255,.08); }
  html[data-tema="noche"] .det-resumen > div, html[data-tema="noche"] .det-motivo, html[data-tema="noche"] .det-section, html[data-tema="noche"] .det-body .contador-trabajo{ background:#221F1B; color:#F3EFE7; }
  html[data-tema="noche"] .det-body .field-mini label{ color:#B2AB9E; }
  html[data-tema="noche"] .det-body input[type="tel"], html[data-tema="noche"] .det-body input[type="number"]{ background:#2C2925; color:#F3EFE7; border-color:#3B3730; }

  /* ---------- Hoja "Cambiar equipo" (inventario) ---------- */
  html[data-tema="noche"] .swap-sheet{ background:rgba(30,28,25,.95); border-color:rgba(255,255,255,.08); color:#F3EFE7; box-shadow:0 30px 80px rgba(0,0,0,.7); }
  html[data-tema="noche"] .swap-sheet h3, html[data-tema="noche"] .swap-sheet .swap-sub b{ color:#F3EFE7; }
  html[data-tema="noche"] .swap-sheet .swap-sub, html[data-tema="noche"] .swap-label{ color:#B2AB9E; }
  html[data-tema="noche"] .swap-field select, html[data-tema="noche"] .swap-field textarea{ background:rgba(255,255,255,.08); color:#F3EFE7; }
  html[data-tema="noche"] .swap-flow{ background:rgba(255,255,255,.06); color:#D8D2C6; }
  html[data-tema="noche"] .swap-primary:disabled{ background:#3A3630; color:#8A8376; }
  html[data-tema="noche"] .swap-cancel, html[data-tema="noche"] .swap-btn{ color:#F3EFE7; background:#26231F; border:1px solid #A69F91; }
  html[data-tema="noche"] .swap-primary{ color:#17161A; background:#F3EFE7; border:1px solid #F3EFE7; }


  /* ---------- Calendario de Historial ---------- */
  html[data-tema="noche"] .cal-ev.sale{ background:rgba(255,106,26,.24); color:#FFB27A; }
  html[data-tema="noche"] .cal-ev.vuelve{ background:rgba(30,143,78,.26); color:#6FD9A0; }
  html[data-tema="noche"] .cal-ev.atrasado{ background:rgba(214,64,39,.30); color:#FF9A85; }
  html[data-tema="noche"] .cal-w, html[data-tema="noche"] .cal-item{ box-shadow:0 6px 18px rgba(0,0,0,.4); }
  html[data-tema="noche"] .cal-dia:hover{ box-shadow:0 10px 22px rgba(0,0,0,.45); }
  html[data-tema="noche"] .cal-overlay{ background:rgba(0,0,0,.55); }
  html[data-tema="noche"] .cal-sheet{ background:rgba(28,26,23,.9); border-color:rgba(255,255,255,.09); box-shadow:0 40px 100px rgba(0,0,0,.7); }
  html[data-tema="noche"] .cal-rnd{ background:rgba(255,255,255,.12); color:#F3EFE7; }
  html[data-tema="noche"] .cal-rnd:hover{ background:rgba(255,255,255,.22); }
  html[data-tema="noche"] .cal-col{ background:rgba(255,255,255,.05); }
  html[data-tema="noche"] .cal-item.atras{ background:linear-gradient(180deg,rgba(214,64,39,.2),var(--surface-1)); }
  html[data-tema="noche"] .cal-chip.rojo{ background:rgba(214,64,39,.28); color:#FF9A85; }
  html[data-tema="noche"] .cal-chip.verde{ background:rgba(30,143,78,.28); color:#6FD9A0; }
  html[data-tema="noche"] .cal-chip.naranja{ background:rgba(255,106,26,.26); color:#FFB27A; }
  html[data-tema="noche"] .cal-sub.atras{ color:#FF8A75; }

  /* ---------- Historial del mecanico (taller) ---------- */
  html[data-tema="noche"] .hist-pill{ background:rgba(30,143,78,.24); color:#6FD9A0; }
  html[data-tema="noche"] .hist-card{ box-shadow:0 8px 24px rgba(0,0,0,.45); }


  /* ---------- Barras de busqueda ---------- */
  html[data-tema="noche"] #histBuscarCliente, html[data-tema="noche"] #histBuscar, html[data-tema="noche"] #inv-buscar, html[data-tema="noche"] #h-buscar-cliente,
  html[data-tema="noche"] #h-buscar-equipo, html[data-tema="noche"] #cal-filtro, html[data-tema="noche"] #cr-buscar-cliente, html[data-tema="noche"] #tallerSearch, html[data-tema="noche"] #histSearch{
    background-color:#26231F; color:#F3EFE7; border-color:rgba(110,151,209,.6); box-shadow:0 4px 14px rgba(0,0,0,.4);
  }
  html[data-tema="noche"] #histBuscarCliente::placeholder, html[data-tema="noche"] #histBuscar::placeholder, html[data-tema="noche"] #inv-buscar::placeholder,
  html[data-tema="noche"] #h-buscar-cliente::placeholder, html[data-tema="noche"] #h-buscar-equipo::placeholder, html[data-tema="noche"] #cal-filtro::placeholder,
  html[data-tema="noche"] #cr-buscar-cliente::placeholder, html[data-tema="noche"] #tallerSearch::placeholder, html[data-tema="noche"] #histSearch::placeholder{ color:#A69F91; }
  html[data-tema="noche"] #histBuscarCliente:focus, html[data-tema="noche"] #histBuscar:focus, html[data-tema="noche"] #inv-buscar:focus, html[data-tema="noche"] #h-buscar-cliente:focus,
  html[data-tema="noche"] #h-buscar-equipo:focus, html[data-tema="noche"] #cal-filtro:focus, html[data-tema="noche"] #cr-buscar-cliente:focus, html[data-tema="noche"] #tallerSearch:focus, html[data-tema="noche"] #histSearch:focus{
    background-color:#2E2A25; border-color:#6E97D1;
  }

  /* ---------- Mapa: teselas oscuras ---------- */
  html[data-tema="noche"] .leaflet-tile-pane{ filter:invert(1) hue-rotate(180deg) brightness(.92) contrast(.9) saturate(.75); }
  html[data-tema="noche"] .leaflet-container{ background:#1A1815; }

  /* ---------- Login ---------- */
  html[data-tema="noche"] .box input{ background:#26231F; color:#F3EFE7; border-color:#3B3730; }
  html[data-tema="noche"] .box input::placeholder{ color:#8A8376; }
  html[data-tema="noche"] body::before, html[data-tema="noche"] body::after{ opacity:.32; }
  html[data-tema="noche"] .box{ box-shadow:0 12px 50px rgba(0,0,0,.6); }

  /* ---------- Detalles ---------- */
  html[data-tema="noche"] ::-webkit-scrollbar{ width:11px; height:11px; }
  html[data-tema="noche"] ::-webkit-scrollbar-thumb{ background:#3B3730; border-radius:8px; border:2px solid #0F0E0C; }
  html[data-tema="noche"] ::-webkit-scrollbar-track{ background:#0F0E0C; }
  html[data-tema="noche"] ::selection{ background:rgba(110,151,209,.45); }
  html[data-tema="noche"] body{ transition:background-color .6s ease, color .6s ease; }
}
