/* ==========================================================================
   APP_SJOSE_Inventory — tema propio sobre Bootstrap 5 (sin admin template).
   Layout inspirado en el mockup "Finnova" (franja superior + tarjetas de
   métricas + panel de detalle tipo tarjeta); paleta de color tomada del
   mockup "Admin Dashboard" (cálida/naranja). Ver docs/BACKLOG.md §14.
   Responsive: escritorio ≥1025px menú completo, tablet 768-1024px sidebar-
   íconos (si aplica), móvil ≤767px barra de iconos inferior fija — mismo
   patrón que CRM_APP/App_Diza_Inventory/Shop_SIGMA, ver
   docs/PATRONES_REFERENCIA_WEB.md §3.
   ========================================================================== */

:root {
  --sjose-primary: #ff7a29;
  --sjose-primary-dark: #e35d0a;
  --sjose-primary-light: #ffe8d6;
  --sjose-accent: #ffb238;
  --sjose-dark: #1f2430;
  --sjose-bg: #f6f5f3;
  --sjose-card-bg: #ffffff;
  --sjose-border: #ece7e2;
  --sjose-text: #2a2e37;
  --sjose-text-muted: #7a7f8a;
  --sjose-success: #2fb673;
  --sjose-danger: #e5484d;
  --sjose-radius-lg: 20px;
  --sjose-radius-md: 14px;
  --sjose-radius-pill: 999px;
  --sjose-shadow: 0 8px 24px rgba(31, 36, 48, 0.07);
  --topbar-height: 68px;
  --bottomnav-height: 64px;
}

html, body {
  height: 100%;
}

body {
  background: var(--sjose-bg);
  color: var(--sjose-text);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
}

a {
  color: var(--sjose-primary-dark);
}

/* ---- Botones/tarjetas propios (prefijo sjose-) ---- */
.btn-sjose-primary {
  background: var(--sjose-primary);
  border-color: var(--sjose-primary);
  color: #fff;
  border-radius: var(--sjose-radius-pill);
  padding: 10px 24px;
  font-weight: 600;
}
.btn-sjose-primary:hover, .btn-sjose-primary:focus {
  background: var(--sjose-primary-dark);
  border-color: var(--sjose-primary-dark);
  color: #fff;
}
.btn-sjose-outline {
  background: #fff;
  border: 1.5px solid var(--sjose-border);
  color: var(--sjose-text);
  border-radius: var(--sjose-radius-pill);
  padding: 9px 22px;
  font-weight: 600;
}
.btn-sjose-outline:hover { border-color: var(--sjose-primary); color: var(--sjose-primary-dark); }

.card-sjose {
  background: var(--sjose-card-bg);
  border: 1px solid var(--sjose-border);
  border-radius: var(--sjose-radius-lg);
  box-shadow: var(--sjose-shadow);
}
.card-sjose .card-body { padding: 20px; }

.badge-sjose {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: var(--sjose-radius-pill);
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--sjose-primary-light);
  color: var(--sjose-primary-dark);
}

.badge-preview {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #eef0f2;
  color: #7a7f8a;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 3px 10px;
  border-radius: var(--sjose-radius-pill);
}

.icon-btn-sjose {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1.5px solid var(--sjose-border);
  background: #fff;
  color: var(--sjose-text);
}
.icon-btn-sjose:hover { border-color: var(--sjose-primary); color: var(--sjose-primary-dark); }

/* ---- Panel lista + detalle (patrón mockup "Finnova") ---- */
.split-panel { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }
@media (max-width: 991px) { .split-panel { grid-template-columns: 1fr; } }

.tab-pills { display: flex; gap: 6px; }
.tab-pill {
  padding: 6px 14px;
  border-radius: var(--sjose-radius-pill);
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--sjose-bg);
  color: var(--sjose-text-muted);
  border: none;
}
.tab-pill.activo { background: var(--sjose-dark); color: #fff; }

.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  border-radius: var(--sjose-radius-md);
}
.doc-row + .doc-row { border-top: 1px solid var(--sjose-border); }
.doc-row.activo { background: var(--sjose-primary-light); }
.doc-row__avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--sjose-dark); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.78rem; flex-shrink: 0;
}
.doc-row__info { flex: 1; min-width: 0; }
.doc-row__info .num { font-weight: 700; font-size: 0.92rem; }
.doc-row__info .sub { font-size: 0.76rem; color: var(--sjose-text-muted); }
.doc-row__amount { font-weight: 700; white-space: nowrap; }
.badge-estado {
  font-size: 0.68rem; font-weight: 700; padding: 2px 9px; border-radius: var(--sjose-radius-pill);
}
.badge-estado.sin-enviar { background: #eef0f2; color: #7a7f8a; }
.badge-estado.visto { background: #fff2d9; color: #b5790a; }
.badge-estado.seleccionado { background: var(--sjose-dark); color: #fff; }
.badge-estado.aprobado { background: #dcf5e3; color: #1d7a3a; }
.badge-estado.anulado { background: #fde3e1; color: #b3261e; }
.badge-estado.facturado { background: #e3ecfb; color: #1f4fa3; }

/* Pastilla de estado con color configurable (Configuración → Estados de pedido). Un solo color
   guardado (--c); el fondo se arma como una versión clara del mismo con color-mix(). */
.badge-estado-color {
  font-size: 0.68rem; font-weight: 700; padding: 2px 9px; border-radius: var(--sjose-radius-pill);
  white-space: nowrap; display: inline-block;
  color: var(--c, #6c757d);
  background: color-mix(in srgb, var(--c, #6c757d) 16%, white);
  border: 1px solid color-mix(in srgb, var(--c, #6c757d) 30%, white);
}

.detail-item-chip {
  border: 1.5px dashed var(--sjose-border);
  border-radius: var(--sjose-radius-md);
  padding: 12px 14px;
  flex: 1;
  min-width: 140px;
}
.detail-item-chip .label { font-size: 0.72rem; color: var(--sjose-text-muted); }
.detail-item-chip .valor { font-weight: 700; }
.detail-totales { display: flex; gap: 24px; flex-wrap: wrap; }
.detail-totales .label { font-size: 0.72rem; color: var(--sjose-text-muted); }
.detail-totales .valor { font-weight: 700; }

/* ---- Pestañas de Configuración (agrupada por módulo) ---- */
.config-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--sjose-border); }
.config-tab {
  padding: 10px 18px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--sjose-text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.config-tab:hover { color: var(--sjose-text); }
.config-tab.activo { color: var(--sjose-primary-dark); border-bottom-color: var(--sjose-primary); }

/* ---- Filtro de selección múltiple (catálogo de productos, y reutilizable en cualquier
   lista con filtros por catálogo) ---- */
.filtro-multiselect { position: relative; display: inline-block; }
.filtro-multiselect summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border: 1.5px solid var(--sjose-border);
  border-radius: var(--sjose-radius-pill);
  background: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}
.filtro-multiselect summary::-webkit-details-marker { display: none; }
.filtro-multiselect[open] summary { border-color: var(--sjose-primary); color: var(--sjose-primary-dark); }
.filtro-multiselect__contador {
  background: var(--sjose-primary); color: #fff; border-radius: 999px;
  font-size: 0.7rem; padding: 1px 7px; font-weight: 700;
}
.filtro-multiselect__panel {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0;
  min-width: 220px; max-height: 260px; overflow-y: auto;
  background: #fff; border: 1px solid var(--sjose-border); border-radius: var(--sjose-radius-md);
  box-shadow: var(--sjose-shadow);
  padding: 8px;
}
.filtro-multiselect__opcion {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 8px; font-size: 0.85rem; cursor: pointer;
}
.filtro-multiselect__opcion:hover { background: var(--sjose-bg); }

/* ---- Línea de tiempo de historial/auditoría (ficha de Cliente y futuras entidades) ---- */
.historial-timeline { list-style: none; margin: 0; padding: 0; }
.historial-timeline li { position: relative; padding: 0 0 18px 22px; border-left: 2px solid var(--sjose-border); }
.historial-timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.historial-timeline__punto {
  position: absolute; left: -6px; top: 2px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--sjose-primary); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--sjose-primary);
}

/* ---- Barra superior (topbar) ---- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-height);
  background: var(--sjose-dark);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar__brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; }
.topbar__brand img { height: 32px; width: auto; border-radius: 8px; }
.topbar__brand .fallback-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--sjose-primary); display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff;
}

.site-nav-row {
  min-width: 0;
  scrollbar-width: none;
  scroll-behavior: smooth;
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
}
.nav-link-sjose {
  color: rgba(255, 255, 255, 0.72);
  padding: 8px 16px;
  border-radius: var(--sjose-radius-pill);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  display: flex; align-items: center; gap: 6px;
}
.nav-link-sjose:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.nav-link-sjose.activo { color: #fff; background: var(--sjose-primary); }
.nav-link-sjose.deshabilitado { color: rgba(255, 255, 255, 0.35); cursor: not-allowed; }

.topbar__acciones { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.topbar__brand { flex-shrink: 0; }
.topbar__avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--sjose-primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem;
}

.app-content { flex: 1; padding: 28px; max-width: 1440px; width: 100%; margin: 0 auto; }

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  margin-bottom: 24px; flex-wrap: wrap;
}
.page-header h1 { font-size: 1.6rem; font-weight: 800; margin-bottom: 2px; }
.page-header p { color: var(--sjose-text-muted); margin: 0; }

/* ---- Fila de tarjetas métricas (estilo mockup Finnova) ---- */
.metric-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.metric-card { padding: 18px 20px; }
.metric-card .metric-label { font-size: 0.8rem; color: var(--sjose-text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.metric-card .metric-value { font-size: 1.7rem; font-weight: 800; margin: 4px 0; }
.metric-card .metric-trend { font-size: 0.8rem; font-weight: 600; }
.metric-trend.up { color: var(--sjose-success); }
.metric-trend.down { color: var(--sjose-danger); }

/* ==========================================================================
   Pantalla de login — panel de imagen con degradado por defecto (naranja),
   se sobreescribe con imagen configurada si existe. Patrón de
   App_Diza_Inventory, ver docs/PATRONES_REFERENCIA_WEB.md §4.
   ========================================================================== */
.login-shell {
  min-height: 100vh;
  display: flex;
}
.login-shell__form {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background: var(--sjose-bg);
}
.login-shell__form-inner { width: 100%; max-width: 380px; }
.login-shell__image {
  flex: 1.15;
  position: relative;
  display: none;
  background-size: cover;
  background-position: center;
  background-color: var(--sjose-dark);
  background-image: linear-gradient(160deg, var(--sjose-accent) 0%, var(--sjose-primary) 45%, var(--sjose-dark) 100%);
}
.login-shell__image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, 0) 55%);
}
.login-shell__image-caption {
  position: absolute; left: 32px; bottom: 32px; right: 32px; color: #fff; z-index: 1;
}
@media (min-width: 900px) {
  .login-shell__image { display: block; }
}

/* ==========================================================================
   Responsive — barra de navegación inferior en móvil (menú de iconos, igual
   que App_Diza_Inventory/Shop_SIGMA). Breakpoint 767/768px consistente con
   los 3 proyectos de referencia.
   ========================================================================== */
.bottom-nav {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  background: var(--sjose-card-bg);
  border-top: 1px solid var(--sjose-border);
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  min-height: 56px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--sjose-text-muted);
  text-decoration: none;
}
.bottom-nav a i { font-size: 1.15rem; }
.bottom-nav a.activo, .bottom-nav a:hover { color: var(--sjose-primary-dark); }

@media (max-width: 767px) {
  .site-nav-row { display: none; }
  .topbar__brand { flex: 1; }
  .bottom-nav { display: flex; }
  .app-content { padding: 18px; padding-bottom: calc(18px + var(--bottomnav-height) + 12px); }
  .login-shell__form { padding: 24px 16px; }
}

/* ==========================================================================
   Menú "carrete": cuando los módulos no caben (pantalla angosta o muchos módulos) el menú se desplaza
   horizontalmente — con el dedo, la rueda/arrastre del mouse o las flechas — en vez de quedar cortado.
   ========================================================================== */
.site-nav-row::-webkit-scrollbar, .bottom-nav::-webkit-scrollbar { display: none; }
.nav-carrete { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; }
.nav-carrete .site-nav-row { flex: 1; }
.nav-carrete__flecha {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 30px; height: 30px; border-radius: 50%; border: 0; padding: 0;
  background: rgba(255, 255, 255, 0.18); color: #fff; display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); cursor: pointer;
}
.nav-carrete__flecha:hover { background: var(--sjose-primary); }
.nav-carrete__flecha--izq { left: 0; }
.nav-carrete__flecha--der { right: 0; }
.nav-carrete.hay-izq .nav-carrete__flecha--izq, .nav-carrete.hay-der .nav-carrete__flecha--der { display: flex; }
.nav-carrete.hay-izq .site-nav-row { padding-left: 34px; }
.nav-carrete.hay-der .site-nav-row { padding-right: 34px; }

/* Barra inferior móvil: también desplazable con el dedo, cada módulo con ancho propio */
.bottom-nav { overflow-x: auto; justify-content: flex-start; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.bottom-nav a { flex: 0 0 auto; min-width: 78px; scroll-snap-align: start; white-space: nowrap; }
.bottom-nav::after { content: ""; flex: 0 0 8px; }
.bottom-nav-wrap { position: relative; }

/* Barras de búsqueda/filtros que se adaptan al ancho: el campo ocupa toda la fila en pantallas angostas
   y los botones se reparten debajo (nada se aplasta ni se desborda). */
.barra-busqueda { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.barra-busqueda > input[type="text"], .barra-busqueda > input[type="search"] { flex: 1 1 240px; min-width: 0; }
.barra-busqueda > .btn { flex: 0 0 auto; white-space: nowrap; }
@media (max-width: 767px) {
  .barra-busqueda > input[type="text"], .barra-busqueda > input[type="search"] { flex: 1 1 100%; }
  .barra-busqueda > .btn { flex: 1 1 auto; }
  .barra-busqueda > .btn:has(> i:only-child) { flex: 0 0 auto; min-width: 48px; }
}

.doc-row[role="button"] { cursor: pointer; }
.doc-row[role="button"]:focus-visible { outline: 2px solid var(--sjose-primary); outline-offset: 2px; }
a.metric-card { transition: transform .12s, box-shadow .12s; display: block; }
a.metric-card:hover { transform: translateY(-2px); }

.atributos-producto { color: var(--sjose-text-muted); font-size: 0.78rem; line-height: 1.25; }

.fila-faltante, .fila-faltante > td { background: rgba(220, 53, 69, 0.08) !important; }
.fila-faltante { box-shadow: inset 3px 0 0 var(--sjose-danger, #dc3545); }

/* Barra de filtros que se reacomoda sola según el ancho (tablet/celular): los campos se reparten la fila y bajan de línea
   en vez de aplastarse; los botones nunca se cortan ni se encimen. */
.filtros-barra { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filtros-barra > .campo-filtro { flex: 1 1 170px; min-width: 0; }
.filtros-barra > .campo-filtro:first-child { flex: 2 1 260px; }
.filtros-barra > .campo-filtro .form-control, .filtros-barra > .campo-filtro .form-select { width: 100%; }
.filtros-barra > .acciones-filtro { flex: 0 0 auto; display: flex; gap: 8px; flex-wrap: wrap; }
.filtros-barra > .acciones-filtro .btn { white-space: nowrap; }
@media (max-width: 767px) {
  .filtros-barra > .campo-filtro, .filtros-barra > .campo-filtro:first-child { flex: 1 1 100%; }
  .filtros-barra > .acciones-filtro { flex: 1 1 100%; }
  .filtros-barra > .acciones-filtro .btn { flex: 1 1 auto; }
}

.badge-estado { white-space: nowrap; }
