/*
 * Calendarios de toda la plataforma con una sola piel moderna.
 *
 * La plataforma trae cuatro librerías de fecha (bootstrap-datetimepicker, bootstrap-datepicker, jQuery UI
 * y daterangepicker). Aquí no se toca su lógica ni su HTML: solo el aspecto, con los mismos tokens para las
 * cuatro, en modo claro y oscuro. Se carga al final para ganarle a vendor.css y a los estilos antiguos.
 */

:root {
  --frd-dp-bg: #ffffff;
  --frd-dp-fg: #0f172a;
  --frd-dp-muted: #94a3b8;
  --frd-dp-border: #e2e8f0;
  --frd-dp-hover: #f1f5f9;
  --frd-dp-accent: #2563eb;
  --frd-dp-accent-fg: #ffffff;
  --frd-dp-range: rgba(37, 99, 235, 0.1);
  --frd-dp-shadow: 0 20px 44px -14px rgba(15, 23, 42, 0.32), 0 2px 8px rgba(15, 23, 42, 0.06);
  --frd-dp-radius: 16px;
  --frd-dp-cell: 36px;
}

html[data-theme="dark"],
html.dark,
body.dark {
  --frd-dp-bg: #1a2231;
  --frd-dp-fg: #f1f5f9;
  --frd-dp-muted: #64748b;
  --frd-dp-border: #2b3548;
  --frd-dp-hover: #243047;
  --frd-dp-accent: #3b82f6;
  --frd-dp-range: rgba(59, 130, 246, 0.2);
  --frd-dp-shadow: 0 22px 48px -10px rgba(0, 0, 0, 0.65);
}

/* ---------- Contenedor ---------- */
html body .bootstrap-datetimepicker-widget.dropdown-menu,
html body .datepicker.datepicker-dropdown,
html body .ui-datepicker,
html body .daterangepicker {
  background: var(--frd-dp-bg) !important;
  background-image: none !important;
  color: var(--frd-dp-fg) !important;
  border: 1px solid var(--frd-dp-border) !important;
  border-radius: var(--frd-dp-radius) !important;
  box-shadow: var(--frd-dp-shadow) !important;
  padding: 12px !important;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.3;
}

html body .bootstrap-datetimepicker-widget.dropdown-menu {
  width: 21em !important;
  max-width: calc(100vw - 24px);
}

html body .ui-datepicker {
  width: 21em;
  max-width: calc(100vw - 24px);
}

/* Se quitan las flechitas de Bootstrap/daterangepicker: el contenedor ya tiene sombra y borde. */
html body .bootstrap-datetimepicker-widget:before,
html body .bootstrap-datetimepicker-widget:after,
html body .datepicker-dropdown:before,
html body .datepicker-dropdown:after,
html body .daterangepicker:before,
html body .daterangepicker:after {
  display: none !important;
}

html body .bootstrap-datetimepicker-widget table,
html body .datepicker-dropdown table,
html body .ui-datepicker table,
html body .daterangepicker .calendar-table {
  width: 100%;
  margin: 0;
  background: transparent !important;
  border: 0 !important;
}

html body .bootstrap-datetimepicker-widget li,
html body .bootstrap-datetimepicker-widget .datepicker,
html body .bootstrap-datetimepicker-widget .timepicker {
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
}

/* ---------- Encabezado (mes y año, flechas) ---------- */
html body .bootstrap-datetimepicker-widget table thead tr:first-child th,
html body .datepicker-dropdown table thead tr:first-child th,
html body .daterangepicker .calendar-table thead tr:first-child th {
  height: 40px;
  padding: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--frd-dp-fg) !important;
  background: transparent !important;
  border-radius: 10px;
  text-align: center;
}

html body .bootstrap-datetimepicker-widget th.prev,
html body .bootstrap-datetimepicker-widget th.next,
html body .datepicker-dropdown th.prev,
html body .datepicker-dropdown th.next,
html body .daterangepicker th.prev,
html body .daterangepicker th.next {
  width: var(--frd-dp-cell);
  cursor: pointer;
}

html body .bootstrap-datetimepicker-widget th.prev:hover,
html body .bootstrap-datetimepicker-widget th.next:hover,
html body .bootstrap-datetimepicker-widget th.picker-switch:hover,
html body .datepicker-dropdown th.prev:hover,
html body .datepicker-dropdown th.next:hover,
html body .datepicker-dropdown th.datepicker-switch:hover,
html body .daterangepicker th.prev:hover,
html body .daterangepicker th.next:hover,
html body .daterangepicker th.month:hover {
  background: var(--frd-dp-hover) !important;
}

/* Días de la semana */
html body .bootstrap-datetimepicker-widget thead tr:last-child th.dow,
html body .datepicker-dropdown thead th.dow,
html body .ui-datepicker th,
html body .daterangepicker .calendar-table thead tr:last-child th {
  height: 32px;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--frd-dp-muted) !important;
  text-align: center;
}

/* ---------- Días ---------- */
html body .bootstrap-datetimepicker-widget td.day,
html body .datepicker-dropdown td.day,
html body .ui-datepicker td a,
html body .ui-datepicker td span,
html body .daterangepicker td.available,
html body .daterangepicker td.off {
  width: var(--frd-dp-cell);
  height: var(--frd-dp-cell);
  line-height: var(--frd-dp-cell);
  padding: 0;
  font-size: 14px;
  text-align: center;
  color: var(--frd-dp-fg) !important;
  background: transparent !important;
  background-image: none !important;
  border: 0 !important;
  border-radius: 999px !important;
  text-shadow: none !important;
  transition: background-color 0.12s ease, color 0.12s ease;
}

html body .ui-datepicker td {
  padding: 1px;
  border: 0;
}

html body .ui-datepicker td a,
html body .ui-datepicker td span {
  display: block;
}

html body .bootstrap-datetimepicker-widget td.day:hover,
html body .datepicker-dropdown td.day:hover,
html body .ui-datepicker td a:hover,
html body .daterangepicker td.available:hover {
  background: var(--frd-dp-hover) !important;
}

/* Días del mes anterior y siguiente */
html body .bootstrap-datetimepicker-widget td.day.old,
html body .bootstrap-datetimepicker-widget td.day.new,
html body .datepicker-dropdown td.day.old,
html body .datepicker-dropdown td.day.new,
html body .ui-datepicker td.ui-datepicker-other-month a,
html body .ui-datepicker td.ui-datepicker-other-month span,
html body .daterangepicker td.off,
html body .daterangepicker td.off.in-range {
  color: var(--frd-dp-muted) !important;
  opacity: 0.7;
}

/* Hoy: anillo, sin el triangulito de Bootstrap */
html body .bootstrap-datetimepicker-widget td.today:before,
html body .datepicker-dropdown td.today:before {
  display: none !important;
}

html body .bootstrap-datetimepicker-widget td.day.today,
html body .datepicker-dropdown td.day.today,
html body .ui-datepicker td.ui-datepicker-today a,
html body .daterangepicker td.today {
  box-shadow: inset 0 0 0 1.5px var(--frd-dp-accent) !important;
  font-weight: 700;
}

/* Día elegido */
html body .bootstrap-datetimepicker-widget td.day.active,
html body .bootstrap-datetimepicker-widget td.day.active:hover,
html body .datepicker-dropdown td.day.active,
html body .datepicker-dropdown td.day.active:hover,
html body .ui-datepicker td a.ui-state-active,
html body .ui-datepicker td a.ui-state-active:hover,
html body .daterangepicker td.active,
html body .daterangepicker td.active:hover,
html body .daterangepicker td.start-date,
html body .daterangepicker td.end-date {
  background: var(--frd-dp-accent) !important;
  color: var(--frd-dp-accent-fg) !important;
  box-shadow: none !important;
  font-weight: 600;
}

/* Rango (reportes) */
html body .daterangepicker td.in-range:not(.start-date):not(.end-date):not(.off),
html body .datepicker-dropdown td.range {
  background: var(--frd-dp-range) !important;
  border-radius: 0 !important;
}

/* Días no disponibles */
html body .bootstrap-datetimepicker-widget td.day.disabled,
html body .bootstrap-datetimepicker-widget td.day.disabled:hover,
html body .datepicker-dropdown td.day.disabled,
html body .datepicker-dropdown td.day.disabled:hover,
html body .ui-datepicker .ui-state-disabled,
html body .daterangepicker td.disabled {
  color: var(--frd-dp-muted) !important;
  opacity: 0.4;
  cursor: not-allowed;
  background: transparent !important;
  text-decoration: line-through;
}

/* ---------- Vista de meses, años y décadas ---------- */
html body .bootstrap-datetimepicker-widget span.month,
html body .bootstrap-datetimepicker-widget span.year,
html body .bootstrap-datetimepicker-widget span.decade,
html body .datepicker-dropdown span.month,
html body .datepicker-dropdown span.year,
html body .datepicker-dropdown span.decade,
html body .datepicker-dropdown span.century {
  width: 25%;
  height: 44px;
  margin: 0;
  line-height: 44px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--frd-dp-fg);
  background-image: none !important;
  text-shadow: none !important;
}

html body .bootstrap-datetimepicker-widget span.month:hover,
html body .bootstrap-datetimepicker-widget span.year:hover,
html body .bootstrap-datetimepicker-widget span.decade:hover,
html body .datepicker-dropdown span.month:hover,
html body .datepicker-dropdown span.year:hover,
html body .datepicker-dropdown span.decade:hover {
  background: var(--frd-dp-hover) !important;
}

html body .bootstrap-datetimepicker-widget span.month.active,
html body .bootstrap-datetimepicker-widget span.year.active,
html body .bootstrap-datetimepicker-widget span.decade.active,
html body .datepicker-dropdown span.month.active,
html body .datepicker-dropdown span.year.active,
html body .datepicker-dropdown span.decade.active {
  background: var(--frd-dp-accent) !important;
  color: var(--frd-dp-accent-fg) !important;
}

html body .bootstrap-datetimepicker-widget span.old,
html body .bootstrap-datetimepicker-widget span.new,
html body .datepicker-dropdown span.old,
html body .datepicker-dropdown span.new {
  color: var(--frd-dp-muted);
}

/* ---------- Hora (datetimepicker) ---------- */
html body .bootstrap-datetimepicker-widget .timepicker-hour,
html body .bootstrap-datetimepicker-widget .timepicker-minute,
html body .bootstrap-datetimepicker-widget .timepicker-second,
html body .bootstrap-datetimepicker-widget .timepicker-picker td span {
  font-size: 22px;
  font-weight: 600;
  color: var(--frd-dp-fg);
}

html body .bootstrap-datetimepicker-widget .timepicker-picker a.btn,
html body .bootstrap-datetimepicker-widget .timepicker-picker td a {
  color: var(--frd-dp-muted) !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 10px;
  box-shadow: none !important;
}

html body .bootstrap-datetimepicker-widget .timepicker-picker a.btn:hover,
html body .bootstrap-datetimepicker-widget .timepicker-picker td a:hover,
html body .bootstrap-datetimepicker-widget .timepicker-hour:hover,
html body .bootstrap-datetimepicker-widget .timepicker-minute:hover {
  background: var(--frd-dp-hover) !important;
  color: var(--frd-dp-fg) !important;
}

html body .bootstrap-datetimepicker-widget .btn[data-action="togglePeriod"] {
  min-width: 52px;
  font-weight: 600;
  color: var(--frd-dp-accent) !important;
}

/* Cambiar entre calendario y reloj */
html body .bootstrap-datetimepicker-widget li.picker-switch.accordion-toggle {
  margin-top: 6px;
  border-top: 1px solid var(--frd-dp-border) !important;
}

html body .bootstrap-datetimepicker-widget li.picker-switch a,
html body .bootstrap-datetimepicker-widget li.picker-switch span {
  color: var(--frd-dp-muted) !important;
  border-radius: 10px;
}

html body .bootstrap-datetimepicker-widget li.picker-switch a:hover {
  background: var(--frd-dp-hover) !important;
  color: var(--frd-dp-fg) !important;
}

/* ---------- Pie de bootstrap-datepicker: Hoy / Limpiar ---------- */
html body .datepicker-dropdown tfoot th {
  height: 34px;
  font-size: 13px;
  font-weight: 600;
  color: var(--frd-dp-accent);
  border-radius: 10px;
}

html body .datepicker-dropdown tfoot th:hover {
  background: var(--frd-dp-hover) !important;
}

/* ---------- jQuery UI: encabezado y flechas ---------- */
html body .ui-datepicker .ui-datepicker-header {
  position: relative;
  padding: 0 0 8px;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0;
}

html body .ui-datepicker .ui-datepicker-title {
  margin: 0 40px;
  line-height: 36px;
  font-size: 15px;
  font-weight: 600;
  color: var(--frd-dp-fg);
}

html body .ui-datepicker .ui-datepicker-prev,
html body .ui-datepicker .ui-datepicker-next {
  top: 0;
  width: 36px;
  height: 36px;
  border: 0 !important;
  border-radius: 10px;
  background: transparent !important;
  cursor: pointer;
}

html body .ui-datepicker .ui-datepicker-prev:hover,
html body .ui-datepicker .ui-datepicker-next:hover {
  background: var(--frd-dp-hover) !important;
}

html body .ui-datepicker .ui-datepicker-prev { left: 0; }
html body .ui-datepicker .ui-datepicker-next { right: 0; }

html body .ui-datepicker select.ui-datepicker-month,
html body .ui-datepicker select.ui-datepicker-year,
html body .daterangepicker select.monthselect,
html body .daterangepicker select.yearselect {
  height: 32px;
  padding: 0 8px;
  color: var(--frd-dp-fg);
  background: var(--frd-dp-bg);
  border: 1px solid var(--frd-dp-border);
  border-radius: 8px;
  font-size: 13px;
}

/* ---------- daterangepicker: atajos y botones ---------- */
html body .daterangepicker .ranges {
  margin: 0 12px 0 0;
}

html body .daterangepicker .ranges li {
  margin: 0 0 2px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--frd-dp-fg);
  background: transparent !important;
  border: 0 !important;
  border-radius: 10px;
}

html body .daterangepicker .ranges li:hover {
  background: var(--frd-dp-hover) !important;
}

html body .daterangepicker .ranges li.active {
  background: var(--frd-dp-accent) !important;
  color: var(--frd-dp-accent-fg) !important;
}

html body .daterangepicker .drp-buttons {
  padding: 10px 0 0;
  border-top: 1px solid var(--frd-dp-border) !important;
  background: transparent !important;
}

html body .daterangepicker .drp-selected {
  font-size: 12px;
  color: var(--frd-dp-muted);
}

html body .daterangepicker .drp-buttons .btn {
  min-height: 36px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
}

html body .daterangepicker .drp-buttons .applyBtn {
  background: var(--frd-dp-accent) !important;
  border-color: var(--frd-dp-accent) !important;
  color: var(--frd-dp-accent-fg) !important;
}

html body .daterangepicker .drp-buttons .cancelBtn {
  background: transparent !important;
  border: 1px solid var(--frd-dp-border) !important;
  color: var(--frd-dp-fg) !important;
}

/* ---------- Pantallas táctiles: celdas más grandes ---------- */
@media (max-width: 767px) {
  :root {
    --frd-dp-cell: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html body td.day,
  html body .ui-datepicker td a,
  html body .daterangepicker td {
    transition: none;
  }
}


/* ==========================================================================
   Fila de compra: fabricación y vencimiento (productos con fecha de caducidad)
   ========================================================================== */
.frd-expiry {
  display: grid;
  gap: 10px;
  min-width: 150px;
}

.frd-expiry__label {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--frd-dp-muted);
}

.frd-expiry__control {
  position: relative;
}

.frd-expiry__control .fa {
  position: absolute;
  top: 50%;
  left: 12px;
  z-index: 2;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--frd-dp-muted);
  pointer-events: none;
}

html body .frd-expiry__control .form-control {
  height: 38px;
  padding: 6px 10px 6px 34px !important;
  cursor: pointer;
  border-radius: 10px !important;
}

.frd-expiry__badge {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
}

.frd-expiry__badge[hidden] {
  display: none;
}

.frd-expiry__badge[data-state="soon"] {
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
}

.frd-expiry__badge[data-state="expired"] {
  background: rgba(239, 68, 68, 0.14);
  color: #b91c1c;
}

html[data-theme="dark"] .frd-expiry__badge,
html.dark .frd-expiry__badge,
body.dark .frd-expiry__badge {
  background: rgba(34, 197, 94, 0.16);
  color: #86efac;
}

html[data-theme="dark"] .frd-expiry__badge[data-state="soon"],
html.dark .frd-expiry__badge[data-state="soon"],
body.dark .frd-expiry__badge[data-state="soon"] {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
}

html[data-theme="dark"] .frd-expiry__badge[data-state="expired"],
html.dark .frd-expiry__badge[data-state="expired"],
body.dark .frd-expiry__badge[data-state="expired"] {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}
