/* Neumorphism - base compartida (home, repartidor, cliente) */
:root {
  --bg: #e4eaf3;
  --bg-2: #dbe3ef;
  --text: #3b4a63;
  --muted: #7d8aa3;
  --accent: #5b9cf5;
  --accent-dark: #3d7fe0;
  --ok: #3cb878;
  --warn: #e8a33d;
  --danger: #e2605f;
  --light: rgba(255, 255, 255, .95);
  --dark: rgba(150, 167, 195, .55);
  --raised: 9px 9px 20px var(--dark), -9px -9px 20px var(--light);
  --raised-sm: 5px 5px 12px var(--dark), -5px -5px 12px var(--light);
  --pressed: inset 5px 5px 11px var(--dark), inset -5px -5px 11px var(--light);
  --radius: 22px;
}

* { box-sizing: border-box; }

html { -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 15% 10%, #f1f5fb 0, var(--bg) 45%, var(--bg-2) 100%) fixed;
}

h1, h2, h3 { margin: 0 0 .4em; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0 0 1em; color: var(--muted); line-height: 1.5; }
a { color: var(--accent-dark); text-decoration: none; }

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 18px 48px;
}

/* Tarjetas */
.card {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--raised);
  padding: 24px;
}
.card.sm { box-shadow: var(--raised-sm); padding: 16px 18px; }
.card.inset { box-shadow: var(--pressed); }

/* Botones */
.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border-radius: 16px;
  padding: 14px 22px;
  box-shadow: var(--raised-sm);
  transition: box-shadow .15s, transform .15s, color .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
}
.btn:hover { color: var(--accent-dark); }
.btn:active, .btn.is-on { box-shadow: var(--pressed); transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: var(--raised-sm); transform: none; }
.btn.primary { background: linear-gradient(145deg, #6aa8ff, var(--accent-dark)); color: #fff; box-shadow: 6px 6px 14px rgba(61, 127, 224, .35), -5px -5px 12px var(--light); }
.btn.primary:active { box-shadow: inset 4px 4px 10px rgba(30, 80, 160, .45); }
.btn.block { display: flex; width: 100%; }

/* Formularios */
.field { margin-bottom: 18px; }
.field label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin: 0 0 8px 6px; }
.field input {
  width: 100%;
  border: 0;
  outline: 0;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--pressed);
}
.field input:focus { box-shadow: var(--pressed), 0 0 0 2px rgba(91, 156, 245, .45); }

/* Insignias de estado */
.badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px; font-size: .82rem; font-weight: 700;
  background: var(--bg); box-shadow: var(--pressed); color: var(--muted);
}
.badge::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.off { color: var(--muted); }

/* Avisos */
.alert { border-radius: 14px; padding: 12px 16px; margin-bottom: 18px; font-size: .92rem; box-shadow: var(--pressed); }
.alert.error { color: var(--danger); }
.alert.ok { color: var(--ok); }
.alert.info { color: var(--accent-dark); }

/* Marca */
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 1.15rem; }
.brand-logo {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: var(--bg); box-shadow: var(--raised-sm); color: var(--accent-dark);
}
.brand-logo svg { width: 26px; height: 26px; }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 36px; }

/* Home */
.hero { text-align: center; margin: 12px auto 40px; max-width: 560px; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); }

.roles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 230px));
  justify-content: center; gap: 20px;
}
.role {
  width: 100%; max-width: 230px; margin: 0 auto;
  display: block; color: inherit; text-align: center; padding: 20px 18px;
  background: var(--bg); border-radius: 20px; box-shadow: var(--raised-sm);
  transition: box-shadow .2s, transform .2s;
}
.role:hover { transform: translateY(-3px); }
.role:active { box-shadow: var(--pressed); transform: none; }
.role-icon {
  width: 60px; height: 60px; margin: 0 auto 12px; border-radius: 50%;
  display: grid; place-items: center; background: var(--bg); box-shadow: var(--pressed); color: var(--accent-dark);
}
.role-icon svg { width: 30px; height: 30px; }
.role h2 { font-size: 1.1rem; letter-spacing: .06em; margin-bottom: .25em; }
.role p { margin: 0; font-size: .88rem; line-height: 1.4; }

/* Pantallas de acceso */
.wrap.narrow { max-width: 440px; }
.center { text-align: center; }
.auth-card .role-icon { margin-bottom: 14px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 6px 0 22px; }
.tabs .btn { padding: 11px 10px; font-size: .92rem; }
.topbar form { margin: 0; }
.huella-bloque { margin: 4px 0 4px; }
.o-sep { display: flex; align-items: center; gap: 12px; margin: 20px 0 6px; color: var(--muted); font-size: .8rem; }
.o-sep::before, .o-sep::after { content: ""; flex: 1; height: 1px; background: rgba(150, 167, 195, .35); }
.huella-card .huella-acciones { display: grid; gap: 12px; margin-top: 14px; }
.huella-card .estado-linea { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.huella-card p { margin: 6px 0 0; font-size: .88rem; }
/* Panel del administrador */
.admin-panel { max-width: 760px; }
.admin-stats { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.rep-lista { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin-bottom: 26px; }
.rep { padding: 16px 18px; scroll-margin-top: 16px; min-width: 0; }
.rep-cab { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.rep-cab > div { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.rep-cab b { overflow-wrap: anywhere; }
.rep-cab small { display: block; color: var(--muted); overflow-wrap: anywhere; }
.rep-cab .badge, .rep-cab .badges { flex: none; }
.rep-dato { overflow-wrap: anywhere; }
.rep-dato { margin: 10px 0 12px; font-size: .84rem; }
.aviso-origen { color: #c0392b; }
[hidden] { display: none !important; }
.admin-codigo { text-align: center; font-size: 2.6rem; font-weight: 700; letter-spacing: .35rem; margin: 18px 0 10px; color: #3d7fe0; font-variant-numeric: tabular-nums; }
.admin-barra { height: 8px; border-radius: 6px; background: rgba(61, 127, 224, .18); overflow: hidden; }
.admin-barra > span { display: block; height: 100%; width: 100%; background: #3d7fe0; transition: width 1s linear; }
.inv-form { margin-top: 6px; }
.inv-lista { margin-top: 18px; display: grid; gap: 10px; }
.inv-fila { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.inv-fila > div { min-width: 0; flex: 1 1 160px; overflow-wrap: anywhere; }
.inv-fila small { display: block; font-size: .8rem; opacity: .75; }
.rep-acciones { display: flex; flex-wrap: wrap; gap: 10px; }
.rep-acciones form { margin: 0; }
.rep-acciones .btn { padding: 10px 14px; font-size: .88rem; }
.link-sec { display: block; text-align: center; margin-top: 18px; font-size: .9rem; }
.radio-group { display: grid; gap: 12px; margin: 4px 0 22px; }
.radio-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--bg); box-shadow: var(--raised-sm); cursor: pointer; }
.radio-row input { margin-top: 4px; accent-color: var(--accent-dark); }
.radio-row span { display: flex; flex-direction: column; gap: 2px; }
.radio-row small { color: var(--muted); font-size: .8rem; }
.radio-row:has(input:checked) { box-shadow: var(--pressed); }
.topbar .badge:last-child { margin-left: auto; }
.modo-app .solo-web { display: none !important; }
.app-android { margin-top: 22px; }

/* Panel del repartidor */
.hidden { display: none !important; }
.wrap.panel { max-width: 640px; }

.share-state { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.share-state h2 { margin: 0 0 2px; font-size: 1.15rem; }
.share-state p { font-size: .88rem; }
.pulse {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg); box-shadow: var(--pressed); position: relative;
}
.pulse::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--muted); }
.pulse.on::after { background: var(--ok); animation: latido 1.6s ease-in-out infinite; }
.pulse.pause::after { background: var(--warn); }
@keyframes latido { 0%,100% { box-shadow: 0 0 0 0 rgba(60,184,120,.55); } 50% { box-shadow: 0 0 0 8px rgba(60,184,120,0); } }

.controls { display: grid; grid-template-columns: 1fr; gap: 14px; }
.btn.big { padding: 17px 20px; font-size: 1.02rem; letter-spacing: .05em; }
.btn.danger { color: var(--danger); }

.btn.live:disabled { opacity: 1; color: #fff; background: linear-gradient(145deg, #4f95f0, #3472d6); box-shadow: inset 4px 4px 10px rgba(20, 60, 140, .5), inset -3px -3px 8px rgba(120, 170, 255, .4); cursor: default; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 22px; padding-top: 18px; border-top: 1px solid rgba(150, 167, 195, .25); cursor: pointer; }
.switch-row span:first-child { display: flex; flex-direction: column; gap: 2px; }
.switch-row small { color: var(--muted); font-size: .8rem; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { flex: none; width: 56px; height: 30px; border-radius: 999px; background: var(--bg); box-shadow: var(--pressed); position: relative; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 22px; height: 22px; border-radius: 50%; background: var(--bg); box-shadow: var(--raised-sm); transition: transform .2s, background .2s; }
.switch-row input:checked + .switch { background: #cfe0fb; }
.switch-row input:checked + .switch::after { transform: translateX(26px); background: var(--accent); }
.switch-row input:disabled + .switch { opacity: .5; }
.switch-row:has(input:disabled) { cursor: not-allowed; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stats .card { display: flex; flex-direction: column; gap: 4px; }
.stat-l { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stats b { font-size: .95rem; word-break: break-all; }

.map-card { padding: 12px; }
.map-box { height: 300px; border-radius: 16px; box-shadow: var(--pressed); overflow: hidden; z-index: 0; }

/* Panel del cliente */
.sec-t { font-size: 1.05rem; margin: 0 0 14px 4px; }
/* Lista compacta: tarjetas en fila con scroll horizontal, para que el mapa quede mas arriba */
.rider-list {
  display: flex; gap: 14px; overflow-x: auto; padding: 8px 6px 16px; margin: 0 -6px;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
}
.rider-list::-webkit-scrollbar { display: none; }
.rider-item {
  appearance: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer;
  display: flex; align-items: center; gap: 12px; background: var(--bg);
  flex: 0 0 min(82%, 300px); scroll-snap-align: start; padding: 10px 14px;
}
.rider-item.is-on { box-shadow: var(--pressed); }
.rider-av {
  flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg); box-shadow: var(--pressed); color: var(--ok);
}
.rider-av svg { width: 24px; height: 24px; }
.rider-av.pausa { color: var(--warn); }
.rider-av.sin_senal { color: var(--muted); }
.rider-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rider-info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rider-info small { color: var(--muted); }

.map-wrap { position: relative; }
/* Alto del mapa: lo que queda de pantalla bajo la cabecera y la lista */
.map-box.grande { height: clamp(380px, calc(100vh - 330px), 720px); height: clamp(380px, calc(100dvh - 330px), 720px); }

/* Tarjeta flotante sobre el mapa */
.float-card {
  position: absolute; z-index: 500; top: 12px; left: 12px; right: 12px;
  background: rgba(228, 234, 243, .93); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-radius: 16px; padding: 12px 16px; box-shadow: var(--raised-sm); pointer-events: none;
}
.float-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.float-card p { margin: 6px 0 0; font-size: .88rem; }
.float-hint { text-align: center; color: var(--muted); font-size: .9rem; }
.map-btn { position: absolute; z-index: 500; right: 12px; bottom: 12px; padding: 9px 16px; font-size: .85rem; }

.rider-pin {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: #e9eef6; color: #3d7fe0; border: 3px solid #fff;
  box-shadow: 3px 3px 9px rgba(80, 100, 140, .45), -2px -2px 6px rgba(255, 255, 255, .8);
}
.rider-pin svg { width: 24px; height: 24px; }
.rider-pin.chico { width: 30px; height: 30px; border-width: 2px; }
.rider-pin.chico svg { width: 16px; height: 16px; }
.rider-pin.pausa { color: var(--warn); }
.rider-pin.sin_senal { color: var(--muted); }
.rider-pin.activo { animation: pin-pulso 2s ease-in-out infinite; }
@keyframes pin-pulso { 0%,100% { box-shadow: 3px 3px 9px rgba(80,100,140,.45), 0 0 0 0 rgba(61,127,224,.45); } 50% { box-shadow: 3px 3px 9px rgba(80,100,140,.45), 0 0 0 10px rgba(61,127,224,0); } }

.modal-back {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 18px;
  background: rgba(60, 74, 99, .35); backdrop-filter: blur(3px);
}
.modal { max-width: 380px; width: 100%; }
.modal .role-icon { margin-bottom: 14px; }

.foot { text-align: center; margin-top: 44px; font-size: .82rem; color: var(--muted); }

@media (max-width: 520px) {
  .wrap { padding: 18px 14px 40px; }
  .card { padding: 18px; }
}

/* Ojito para ver la contraseña */
.clave-caja { position: relative; }
.clave-caja input { padding-right: 52px; }
.clave-ojo {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border: 0; border-radius: 12px; cursor: pointer;
  background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center;
}
.clave-ojo:hover, .clave-ojo[aria-pressed="true"] { color: var(--text); }
.clave-ojo:focus-visible { outline: 2px solid rgba(91, 156, 245, .7); }

/* Estado del envio de ubicacion (panel del repartidor) */
.alert.envio { font-weight: 600; font-size: 1rem; line-height: 1.35; margin: 16px 0 0; padding: 14px 16px; }
.alert.envio.ok { color: var(--ok); }
.alert.envio.warn { color: #b9770e; }
.alert.envio.error { color: #fff; background: var(--danger); box-shadow: none; }

/* Empresa: selectores, texto largo y lista de productos */
.field select, .field textarea {
  width: 100%; border: 0; outline: 0; font: inherit; color: var(--text); background: var(--bg);
  border-radius: 14px; padding: 14px 16px; box-shadow: var(--pressed);
}
.field textarea { resize: vertical; min-height: 84px; }
.field select:focus, .field textarea:focus { box-shadow: var(--pressed), 0 0 0 2px rgba(91, 156, 245, .45); }
.field small { display: block; margin: 6px 0 0 6px; color: var(--muted); font-size: .8rem; }
.campos-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 14px; }
.check-fila { display: flex; align-items: center; gap: 10px; margin: 0 0 18px 6px; font-weight: 600; }
.check-fila input { width: 20px; height: 20px; }
.prod-lista { display: grid; gap: 14px; }
.prod-fila { display: flex; gap: 14px; align-items: flex-start; }
.prod-foto { flex: none; width: 76px; height: 76px; border-radius: 14px; object-fit: cover; background: var(--bg); box-shadow: var(--pressed); display: grid; place-items: center; color: var(--muted); font-size: .7rem; text-align: center; }
.prod-info { min-width: 0; flex: 1 1 auto; }
.prod-info b { overflow-wrap: anywhere; }
.prod-info small { display: block; color: var(--muted); overflow-wrap: anywhere; }
.prod-stock { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.prod-stock input { width: 90px; border: 0; outline: 0; font: inherit; color: var(--text); background: var(--bg); border-radius: 12px; padding: 9px 12px; box-shadow: var(--pressed); }
.precio-viejo { text-decoration: line-through; color: var(--muted); font-size: .85rem; margin-left: 6px; }
.mapa-pick { height: 260px; border-radius: 16px; box-shadow: var(--pressed); overflow: hidden; z-index: 0; }

/* Tienda del cliente y seguimiento del pedido */
.tienda-link { display: block; color: inherit; text-decoration: none; }
.tienda-link:hover b { color: var(--accent-dark); }
.producto.agotado { opacity: .62; }
.producto .prod-stock { margin-bottom: 0; }
.producto .cant { min-width: 1.6em; text-align: center; font-size: 1.05rem; }
.producto .prod-stock .btn { padding: 8px 16px; font-size: 1.1rem; }
.barra-carrito {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px max(16px, env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: var(--bg); box-shadow: 0 -8px 20px rgba(120, 138, 168, .28);
}
.barra-carrito small { display: block; color: var(--muted); }
#catalogo { padding-bottom: 96px; }
.barra { height: 12px; border-radius: 999px; background: var(--bg); box-shadow: var(--pressed); overflow: hidden; }
.barra span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #6aa8ff, var(--accent-dark)); transition: width 1s linear; }
.pista { position: relative; height: 56px; overflow: hidden; margin-bottom: 4px; border-bottom: 2px dashed rgba(150, 167, 195, .5); }
.pista .moto { position: absolute; left: -48px; bottom: 4px; width: 44px; height: 44px; color: var(--accent-dark); animation: moto-cruza 4.5s linear infinite; }
.pista .moto svg { width: 100%; height: 100%; animation: moto-salta .45s ease-in-out infinite alternate; }
@keyframes moto-cruza { from { transform: translateX(0); } to { transform: translateX(calc(100vw)); } }
@keyframes moto-salta { from { transform: translateY(0); } to { transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .pista .moto, .pista .moto svg { animation: none; left: calc(50% - 22px); } }
