/* Bajanor 3.0 — estilos compartidos. Mobile-first, herramienta de trabajo. */
:root {
  --primary: #C8102E;
  --secondary: #1A1A1A;
  --bg: #F5F5F5;
  --surface: #FFFFFF;
  --text: #1A1A1A;
  --muted: #6B7280;
  --border: #E5E7EB;
  --destructive: #DC2626;
  --success: #16A34A;
  --radius: 8px;
  --radius-card: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 640px; margin: 0 auto; padding: 16px; }

/* Barra superior de los paneles */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px; background: var(--secondary); color: #fff;
}
.topbar .brand { font-weight: 700; letter-spacing: .5px; }
.topbar .rol { font-size: 13px; color: #cbd5e1; }

/* Tarjetas */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); padding: 20px; margin: 16px 0;
}

/* Formularios */
label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 6px; }
input, select, textarea {
  width: 100%; font-size: 16px; /* >=16 evita zoom iOS */
  padding: 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

/* Botones — target táctil >=44px */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 12px 20px; border: none; border-radius: var(--radius);
  font-size: 16px; font-weight: 600; cursor: pointer; width: 100%;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-ghost { background: transparent; color: #fff; border: 1px solid #ffffff55; width: auto; min-height: 36px; padding: 6px 14px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.msg { font-size: 14px; margin-top: 12px; }
.msg.error { color: var(--destructive); }
.msg.ok { color: var(--success); }

/* Login */
.login-screen { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { color: var(--primary); margin: 0 0 4px; font-size: 28px; }
.login-card .sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }

.placeholder { color: var(--muted); font-style: italic; }

/* Botón GPS dentro de form (ghost oscuro, no sobre la topbar) */
.btn-gps { color: var(--text); border: 1px solid var(--border); background: #fff; }

/* Lista "Mis pedidos" */
.pedido { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.pedido-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pedido-meta { font-size: 14px; color: var(--muted); margin-top: 4px; }
.pedido-foot { display: flex; align-items: center; gap: 16px; margin-top: 8px; }
.pedido-foot a { font-size: 14px; color: var(--primary); text-decoration: none; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }

.badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge-programado { background: #FEF3C7; color: #92400E; }
.badge-realizado { background: #DCFCE7; color: #166534; }
.badge-cancelado { background: #FEE2E2; color: #991B1B; }
.badge-pagado { background: #DCFCE7; color: #166534; }
.badge-nopagado { background: #F3F4F6; color: #6B7280; }
.badge-bomba { background: #DBEAFE; color: #1E40AF; }
/* Columna derecha de la card: estado arriba y pago abajo, pegados al borde derecho */
.pedido-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
/* Estatus de pago en la vista previa: un poco más grande que el resto */
.badge-lg { font-size: 14px; padding: 6px 12px; }

/* Tarjeta de pedido tocable */
.pedido { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.pedido:hover, .pedido:focus { border-color: var(--primary); box-shadow: 0 1px 6px #0000000f; outline: none; }
.pedido-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.pedido-body { flex: 1; min-width: 0; }
.pedido-tap { margin-top: 8px; font-size: 12px; color: var(--primary); font-weight: 600; }

/* Modal de detalle (bottom sheet) */
.modal-bg {
  position: fixed; inset: 0; background: #00000080; z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
.modal-card {
  background: var(--surface); width: 100%; max-width: 640px; height: 85dvh;
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px #00000033;
  animation: slideup .25s ease;
}
@keyframes fade { from { opacity: 0; } }
@keyframes slideup { from { transform: translateY(100%); } }

/* Encabezado fijo (no hace scroll) y arrastrable por la barrita de agarre */
.modal-head {
  flex: 0 0 auto; position: relative; background: var(--surface);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 18px 20px 12px; border-bottom: 1px solid var(--border);
  touch-action: none; cursor: grab; user-select: none;
}
.modal-head:active { cursor: grabbing; }
.modal-card.expanded { height: 96dvh; }
.modal-head::before {
  content: ""; position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
  width: 40px; height: 4px; border-radius: 999px; background: var(--border);
}
.modal-head h2 { margin: 0; color: var(--primary); font-size: 20px; }
.modal-x { width: 40px; min-height: 40px; border: none; background: var(--bg); border-radius: 999px; font-size: 18px; cursor: pointer; flex-shrink: 0; }

/* Cuerpo desplazable (flex:1 + min-height:0 para que scrollee DENTRO de la tarjeta) */
.modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 16px 20px 28px; }
.d-badges { display: flex; gap: 8px; margin: 0 0 8px; }
.d-row { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.d-k { color: var(--muted); font-size: 14px; }
.d-v { font-weight: 600; text-align: right; }
.d-foto-title { font-size: 15px; margin: 18px 0 8px; }
.d-foto { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); display: block; }

@media (min-width: 560px) {
  .modal-bg { align-items: center; padding: 16px; }
  .modal-card { height: auto; max-height: 85dvh; border-radius: var(--radius-card); animation: fade .18s ease; }
  .modal-head { border-radius: var(--radius-card) var(--radius-card) 0 0; }
  .modal-head::before { display: none; }
}

/* === Panel del programador (Sesión 3) === */

/* Filtros de estado (chips horizontales, scrolleables en pantallas chicas) */
.filtros { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; -webkit-overflow-scrolling: touch; }
.chip {
  flex: 0 0 auto; min-height: 40px; padding: 8px 16px; border: 1px solid var(--border);
  background: #fff; color: var(--text); border-radius: 999px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.chip.active { background: var(--secondary); color: #fff; border-color: var(--secondary); }

/* Encabezado de grupo por día */
.day-group { display: flex; align-items: center; gap: 8px; margin: 18px 0 8px; font-size: 14px; font-weight: 700; color: var(--secondary); }
.day-group .day-tag { font-size: 12px; font-weight: 700; color: #fff; background: var(--primary); border-radius: 999px; padding: 2px 8px; }
.day-group .count { font-weight: 500; color: var(--muted); }

/* Acciones del programador dentro del detalle */
.sheet-actions { display: grid; gap: 10px; margin-top: 20px; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--destructive); color: #fff; }
.btn-dark { background: var(--secondary); color: #fff; }
.d-tel { color: var(--primary); text-decoration: none; font-weight: 600; }

.confirm-box { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-top: 16px; background: var(--bg); }
.confirm-box p { margin: 0 0 12px; font-weight: 600; }
.confirm-row { display: flex; gap: 10px; }
.confirm-row .btn { width: auto; flex: 1; }

/* === Gestión de usuarios (Sesión 5) === */
/* Encabezado de tarjeta con acción a la derecha (p. ej. "+ Nuevo") */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.btn-inline { width: auto; min-height: 40px; padding: 8px 16px; font-size: 14px; }

/* Badges de usuario */
.badge-activo { background: #DCFCE7; color: #166534; }
.badge-inactivo { background: #FEE2E2; color: #991B1B; }
.badge-rol { background: #E0E7FF; color: #3730A3; }

/* Usuario dado de baja: se atenúa para distinguirlo de un vistazo */
.pedido.is-inactivo { opacity: .6; }

/* Fila input + botón (contraseña / cambiar rol) */
.pass-row { display: flex; gap: 8px; align-items: stretch; }
.pass-row input, .pass-row select { flex: 1; min-width: 0; }
.pass-row .btn { width: auto; flex: 0 0 auto; }

/* Caja de credenciales recién creadas */
.cred { border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 14px; margin-top: 12px; background: var(--bg); }
