:root {
  --marron-oscuro: #5c1414;
  --rojo-tierra: #7a2020;
  --rojo-claro: #963333;
  --crema: #f3e6c8;
  --crema-clara: #faf3e2;
  --dorado: #c9a35a;
  --texto-oscuro: #3b2113;
  --verde-libre: #2e7d4f;
  --rojo-ocupada: #b23a3a;
}

body {
  background-color: var(--crema-clara);
  color: var(--texto-oscuro);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Franja decorativa tipo "zig-zag" inspirada en el menú */
.franja-zigzag {
  height: 14px;
  background:
    linear-gradient(135deg, var(--marron-oscuro) 25%, transparent 25%) 0 0,
    linear-gradient(225deg, var(--marron-oscuro) 25%, transparent 25%) 0 0;
  background-size: 14px 14px;
  background-color: var(--dorado);
}

.topbar {
  background: linear-gradient(180deg, var(--marron-oscuro), var(--rojo-tierra));
  color: var(--crema-clara);
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar .brand {
  font-weight: 800;
  letter-spacing: 1px;
  font-size: 1.4rem;
  color: var(--crema-clara);
  text-decoration: none;
}

.topbar .brand .icono {
  margin: 0 .35rem;
}

.usuario-menu .usuario-toggle {
  display: flex;
  align-items: center;
  gap: .55rem;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.3);
  color: #fff;
  border-radius: 2rem;
  padding: .4rem .7rem .4rem .6rem;
  font-size: .9rem;
  transition: background .15s;
}

.usuario-menu .usuario-toggle:hover,
.usuario-menu .usuario-toggle:focus {
  background: rgba(255,255,255,.22);
  color: #fff;
}

.usuario-menu .usuario-toggle i.bi-person-circle {
  font-size: 1.4rem;
  color: var(--dorado);
}

.usuario-menu .usuario-toggle::after {
  margin-left: .3rem;
}

.usuario-menu .dropdown-menu {
  border: none;
  border-radius: .9rem;
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
  padding: .5rem;
  margin-top: .5rem;
  min-width: 200px;
}

.usuario-menu .dropdown-item {
  border-radius: .6rem;
  padding: .65rem .9rem;
  font-weight: 600;
  color: var(--rojo-tierra);
  display: flex;
  align-items: center;
  gap: .5rem;
}

.usuario-menu .dropdown-item:hover,
.usuario-menu .dropdown-item:focus {
  background: var(--crema);
  color: var(--marron-oscuro);
}

.topbar .badge-rol {
  background: var(--dorado);
  color: var(--marron-oscuro);
  font-weight: 700;
  text-transform: uppercase;
  font-size: .7rem;
  padding: .2rem .5rem;
  border-radius: .35rem;
}

.layout {
  display: flex;
  min-height: calc(100vh - 60px);
}

.sidebar {
  width: 230px;
  background: var(--marron-oscuro);
  flex-shrink: 0;
}

.sidebar a {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: var(--crema);
  text-decoration: none;
  padding: .85rem 1.25rem;
  font-size: .95rem;
  border-left: 4px solid transparent;
  transition: background .15s;
}

.sidebar a:hover,
.sidebar a.activo {
  background: rgba(255, 255, 255, .1);
  border-left-color: var(--dorado);
}

.contenido {
  flex: 1;
  padding: 1.75rem;
}

.titulo-seccion {
  color: var(--marron-oscuro);
  font-weight: 800;
  border-bottom: 3px solid var(--dorado);
  padding-bottom: .5rem;
  margin-bottom: 1.5rem;
  display: inline-block;
}

/* Tarjetas generales */
.card-tb {
  background: #fff;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: .9rem;
  box-shadow: 0 2px 8px rgba(92,20,20,.08);
  transition: transform .12s, box-shadow .12s;
}

.card-tb:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 18px rgba(92,20,20,.15);
}

/* Tarjetas de opción grande (Mesa / Domicilio) */
.opcion-grande {
  cursor: pointer;
  text-align: center;
  padding: 2.5rem 1.5rem;
  border-radius: 1rem;
  border: 3px solid var(--dorado);
  background: var(--crema);
  color: var(--marron-oscuro);
  font-weight: 700;
  font-size: 1.3rem;
  transition: all .15s;
}

.opcion-grande:hover {
  background: var(--dorado);
  color: #fff;
  transform: translateY(-4px);
}

.opcion-grande .bi {
  font-size: 2.8rem;
  display: block;
  margin-bottom: .5rem;
}

/* Tarjetas de mesa */
.mesa-card {
  cursor: pointer;
  border-radius: .8rem;
  padding: 1.25rem .5rem;
  text-align: center;
  font-weight: 700;
  color: #fff;
  border: none;
}

.mesa-card.libre { background: var(--verde-libre); }
.mesa-card.ocupada { background: var(--rojo-ocupada); cursor: not-allowed; opacity: .85; }
.mesa-card small { display: block; font-weight: 400; opacity: .9; }

.mesa-card.seleccionada {
  outline: 4px solid var(--dorado);
  outline-offset: 2px;
}

/* Tarjetas de producto */
.producto-card {
  border-radius: .8rem;
  padding: 1rem;
  background: #fff;
  border: 1px solid rgba(0,0,0,.08);
  height: 100%;
  display: flex;
  flex-direction: column;
}

.producto-card .nombre {
  font-weight: 700;
  color: var(--marron-oscuro);
}

.producto-card .descripcion {
  font-size: .78rem;
  color: #6b5a4a;
  flex: 1;
}

.producto-card .precio {
  font-weight: 800;
  color: var(--rojo-tierra);
  font-size: 1.05rem;
}

/* Carrito lateral */
.carrito {
  position: sticky;
  top: 1rem;
  background: #fff;
  border-radius: .9rem;
  border: 1px solid rgba(0,0,0,.08);
  box-shadow: 0 2px 8px rgba(92,20,20,.08);
}

.carrito .carrito-header {
  background: var(--marron-oscuro);
  color: #fff;
  padding: .85rem 1rem;
  border-radius: .9rem .9rem 0 0;
  font-weight: 700;
}

.carrito-item {
  padding: .6rem 1rem;
  border-bottom: 1px dashed rgba(0,0,0,.1);
  font-size: .9rem;
}

.carrito-total {
  padding: 1rem;
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--rojo-tierra);
  text-align: right;
}

.btn-tb {
  background: var(--rojo-tierra);
  border-color: var(--rojo-tierra);
  color: #fff;
  font-weight: 600;
}
.btn-tb:hover { background: var(--marron-oscuro); border-color: var(--marron-oscuro); color: #fff; }

.btn-dorado {
  background: var(--dorado);
  border-color: var(--dorado);
  color: var(--marron-oscuro);
  font-weight: 700;
}
.btn-dorado:hover { background: #b58e45; color: #fff; }

.stat-card {
  border-radius: 1rem;
  padding: 1.25rem;
  color: #fff;
  background: linear-gradient(135deg, var(--marron-oscuro), var(--rojo-claro));
}
.stat-card .valor { font-size: 1.8rem; font-weight: 800; }
.stat-card .etiqueta { font-size: .85rem; opacity: .9; }

.badge-estado-abierto { background: #6c757d; }
.badge-estado-pendiente_factura { background: var(--dorado); color: var(--marron-oscuro); }
.badge-estado-facturado { background: var(--verde-libre); }
.badge-estado-cancelado { background: var(--rojo-ocupada); }

/* Tamaño de página para impresora térmica de tickets (rollo de 58mm).
   El área imprimible real de una POS-58 es ~48mm (no los 58mm del papel);
   si se usa el ancho completo del papel, la impresora recorta el borde
   derecho del texto. Se deja el ancho de página en 48mm para que nada
   se salga del área imprimible. */
@page {
  size: 48mm auto;
  margin: 0;
}

@media print {
  .no-imprimir { display: none !important; }
  html, body { background: #fff; width: 48mm; }
  .layout { display: block; min-height: 0; }
  .contenido { padding: 0; }
  .ticket {
    max-width: 100%;
    width: 100%;
    margin: 0;
    padding: 0 1mm;
    box-shadow: none;
    border: none;
    border-radius: 0;
  }
}

/* Ticket de impresión (comanda / factura) */
.ticket {
  max-width: 380px;
  margin: 0 auto;
  background: #fff;
  padding: 1.25rem;
  font-family: 'Courier New', monospace;
  color: #000;
  font-size: .75rem;
}
.ticket h2 { text-align: center; margin: 0; font-size: .95rem; }
.ticket .linea { border-top: 1px dashed #000; margin: .3rem 0; }
.ticket table { width: 100%; font-size: .72rem; border-collapse: collapse; table-layout: fixed; }
.ticket table td { padding: 1px 2px; word-break: break-word; overflow-wrap: break-word; }
.ticket table td:first-child { width: 1.8em; white-space: nowrap; }
.ticket p { word-break: break-word; overflow-wrap: break-word; }
.ticket .total-final { font-size: .9rem; font-weight: 700; }
.ticket .nota-item { font-style: italic; }

/* Comprobante de pago de nómina: formato grande (no ticket térmico), para
   que el trabajador vea claramente cuánto se le pagó. */
.comprobante-nomina {
  max-width: 480px;
  margin: 0 auto;
  background: #fff;
  border-radius: 1.1rem;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(92,20,20,.18);
  border: 1px solid rgba(0,0,0,.08);
}
.comprobante-nomina .comprobante-header {
  background: linear-gradient(135deg, var(--marron-oscuro), var(--rojo-tierra));
  color: #fff;
  text-align: center;
  padding: 1.75rem 1.5rem 1.25rem;
}
.comprobante-nomina .comprobante-header img {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--dorado);
  margin-bottom: .5rem;
}
.comprobante-nomina .comprobante-titulo {
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: 1px;
}
.comprobante-nomina .comprobante-subtitulo {
  color: var(--crema);
  font-size: .9rem;
}
.comprobante-nomina .comprobante-body {
  padding: 1.5rem;
}
.comprobante-nomina .comprobante-linea {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 .6rem;
  font-size: .95rem;
}
.comprobante-nomina .comprobante-linea span { color: #6b5a4a; }
.comprobante-nomina hr { border-top: 1px dashed rgba(0,0,0,.15); margin: 1rem 0; }
.comprobante-nomina .comprobante-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--rojo-tierra);
  margin: 0;
}
.comprobante-nomina .comprobante-nota {
  font-size: .8rem;
  color: #6b5a4a;
  text-align: center;
  margin-top: 1rem;
}

@media print {
  .comprobante-nomina { box-shadow: none; border: 1px solid #ccc; margin: 2rem auto; }
}

/* KDS: pantalla de cocina */
.kds-card {
  background: #fff;
  border-radius: 1rem;
  border: 4px solid var(--verde-libre);
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.kds-card.kds-atencion { border-color: var(--dorado); }
.kds-card.kds-urgente { border-color: var(--rojo-ocupada); animation: kds-parpadeo 1.5s infinite; }
.kds-card.kds-listo { opacity: .55; border-color: #999; animation: none; }
@keyframes kds-parpadeo {
  0%, 100% { box-shadow: 0 4px 14px rgba(178,58,58,.25); }
  50% { box-shadow: 0 4px 26px rgba(178,58,58,.7); }
}
.kds-card-header {
  background: var(--marron-oscuro);
  color: #fff;
  padding: .9rem 1.1rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: .3rem .6rem;
  font-weight: 800;
  font-size: 1.2rem;
}
.kds-card-header > div:first-child { white-space: nowrap; }
.kds-card-header .bi { font-size: 1.25rem; margin-right: .15rem; }
.kds-minutos {
  background: rgba(255,255,255,.18);
  border-radius: 1rem;
  padding: .3rem .8rem;
  font-size: .95rem;
  font-weight: 700;
  white-space: nowrap;
}
.kds-card.kds-atencion .kds-minutos { background: var(--dorado); color: var(--marron-oscuro); }
.kds-card.kds-urgente .kds-minutos { background: #fff; color: var(--rojo-ocupada); }
.kds-card-body {
  padding: 1rem 1.1rem;
  flex: 1;
}
.kds-item {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .55rem 0;
  border-bottom: 1px dashed rgba(0,0,0,.12);
}
.kds-item:last-child { border-bottom: none; }
.kds-cantidad {
  flex-shrink: 0;
  background: var(--crema);
  color: var(--marron-oscuro);
  font-weight: 800;
  font-size: 1rem;
  border-radius: .5rem;
  padding: .2rem .55rem;
  min-width: 2.5rem;
  text-align: center;
}
.kds-nombre { font-size: 1.15rem; font-weight: 600; line-height: 1.3; color: var(--texto-oscuro); }
.kds-nota {
  margin-top: .35rem;
  background: #fff4e0;
  border-left: 3px solid var(--dorado);
  color: var(--rojo-tierra);
  font-size: .85rem;
  font-weight: 600;
  padding: .3rem .55rem;
  border-radius: .3rem;
}
.kds-card-footer {
  padding: .8rem 1.1rem 1rem;
  border-top: 1px solid rgba(0,0,0,.08);
  background: var(--crema-clara);
}
.kds-card-footer .kds-mesero {
  font-size: .85rem;
  color: #6b5a4a;
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  gap: .35rem;
}
.kds-card-footer form { margin: 0; }
.kds-card-footer .btn {
  width: 100%;
  font-size: 1.05rem;
  font-weight: 700;
  padding: .6rem;
}

/* Gráficas de reportes (Chart.js necesita un contenedor con alto fijo) */
.grafica-cont { position: relative; height: 220px; margin-bottom: .75rem; }
@media print { .grafica-cont { display: none; } }

/* ===================== Responsive (celular / tablet) ===================== */
@media (max-width: 767.98px) {
  .layout { flex-direction: column; }

  .sidebar {
    width: 100%;
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0;
  }
  .sidebar a {
    flex: 0 0 auto;
    padding: .6rem .85rem;
    font-size: .82rem;
    white-space: nowrap;
    border-left: none;
    border-bottom: 3px solid transparent;
  }
  .sidebar a:hover,
  .sidebar a.activo {
    border-left-color: transparent;
    border-bottom-color: var(--dorado);
  }

  .topbar { flex-wrap: wrap; gap: .35rem; padding: .6rem .9rem; }
  .topbar .brand { font-size: 1.1rem; }
  .usuario-menu .usuario-toggle { font-size: .8rem; padding: .3rem .6rem; }
  .usuario-menu .usuario-nombre { display: none; }

  .contenido { padding: 1rem; }
  .titulo-seccion { font-size: 1.25rem; }

  /* Barras de filtro (fecha + botones) que antes se salían de la pantalla */
  .d-flex.gap-2.align-items-end { flex-wrap: wrap; }
  .d-flex.gap-2.align-items-end > * { flex: 1 1 auto; }
  .d-flex.gap-2.align-items-end input[type="date"] { min-width: 140px; }

  .opcion-grande { padding: 1.5rem 1rem; font-size: 1.05rem; }
  .opcion-grande .bi { font-size: 2.2rem; }

  .mesa-card { padding: .75rem .25rem; font-size: .8rem; }
  .producto-card { padding: .85rem; }

  .nav-pills .nav-link { font-size: .8rem; padding: .35rem .65rem; }

  .carrito { position: static; margin-top: 1rem; }

  .stat-card .valor { font-size: 1.5rem; }

  .ticket { padding: 1rem .5rem; }
}

@media (max-width: 420px) {
  .mesa-card { font-size: .72rem; }
  .topbar .brand { font-size: 1rem; }
}
