/* =====================================================================
   Sistema de Recolección y Reparto de Mercancía — estilos compartidos
   ===================================================================== */

:root {
  --color-bg: #f3f5f8;
  --color-panel: #ffffff;
  --color-panel-2: #f8f9fb;
  --color-border: #dde2e8;
  --color-primary: #f5a30a; /*  #1f3a5f;*/
  --color-primary-dark: #142840;
  --color-primary-soft: #e8edf4;
  --color-accent: #d9772e;
  --color-success: #2e7d4f;
  --color-success-soft: #e4f3ea;
  --color-warning: #b8860a;
  --color-warning-soft: #fbf1da;
  --color-danger: #c4432b;
  --color-danger-soft: #fbe9e5;
  --color-text: #1c2630;
  --color-muted: #6b7785;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(20, 30, 45, 0.06), 0 4px 14px rgba(20, 30, 45, 0.06);
  --font-ui: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-ui);
  color: var(--color-text);
  background: var(--color-bg);
}

body { min-height: 100vh; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; margin: 0; }

a { color: var(--color-primary); text-decoration: none; }

button {
  font-family: var(--font-ui);
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1.1rem;
  font-size: 0.92rem;
  font-weight: 600;
  transition: background 0.15s ease, transform 0.05s ease;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-panel-2); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: #eef1f5; }
.btn-success { background: var(--color-success); color: #fff; }
.btn-warning { background: var(--color-warning); color: #fff; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-link { background: transparent; color: var(--color-primary); padding: 0.3rem 0.4rem; }

input, select, textarea {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--color-text);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}
label { font-size: 0.82rem; color: var(--color-muted); font-weight: 600; display: block; margin-bottom: 0.3rem; }
.field { margin-bottom: 0.9rem; }
.field-row { display: flex; gap: 0.8rem; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 180px; }

/* ----- Layout shell usado en los 4 módulos ----- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  width: 230px;
  background: var(--color-primary-dark);
  color: #fff;
  padding: 1.4rem 1.1rem;
  flex-shrink: 0;
}
.app-sidebar .brand { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; margin-bottom: 1.6rem; line-height: 1.25; }
.app-sidebar .brand small { display: block; font-size: 0.7rem; font-weight: 400; opacity: 0.65; margin-top: 0.2rem; }
.app-sidebar nav button {
  display: block; width: 100%; text-align: left; background: transparent; color: rgba(255,255,255,0.75);
  padding: 0.55rem 0.6rem; margin-bottom: 0.2rem; font-weight: 500;
}
.app-sidebar nav button.active, .app-sidebar nav button:hover { background: rgba(255,255,255,0.08); color: #fff; }
.app-sidebar .session-box { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,0.15); font-size: 0.8rem; opacity: 0.8; }

.app-main { flex: 1; padding: 1.6rem 2rem; max-width: 100%; overflow-x: auto; }
.app-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.4rem; }
.app-topbar h1 { font-size: 1.4rem; }

.panel { background: var(--color-panel); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow); margin-bottom: 1.2rem; }
.panel h2 { font-size: 1.05rem; margin-bottom: 0.9rem; }

/* ----- Login ----- */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary)); }
.login-card { background: #fff; padding: 2.2rem 2rem; border-radius: 14px; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,0.25); }
.login-card .brand-eyebrow { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-muted); font-weight: 700; }
.login-card h1 { font-size: 1.5rem; margin: 0.2rem 0 1.4rem; }
.login-error { background: var(--color-danger-soft); color: var(--color-danger); padding: 0.6rem 0.8rem; border-radius: var(--radius-sm); font-size: 0.85rem; margin-bottom: 0.9rem; display: none; }

/* ----- Tabla ----- */
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th { text-align: left; color: var(--color-muted); font-weight: 700; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 0.5rem 0.6rem; border-bottom: 2px solid var(--color-border); }
td { padding: 0.6rem 0.6rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
tr:hover td { background: var(--color-panel-2); }

/* ----- Badges de estatus ----- */
.badge { display: inline-block; padding: 0.22rem 0.6rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; }
.badge-emitida { background: var(--color-primary-soft); color: var(--color-primary); }
.badge-recibida { background: #e6f0fb; color: #1d5ba8; }
.badge-ruta { background: #ede6fb; color: #6940b0; }
.badge-recolectada { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-entregada { background: var(--color-success-soft); color: var(--color-success); }
.badge-pendiente { background: var(--color-danger-soft); color: var(--color-danger); }
.badge-pausada { background: #f1f1f1; color: #777; }
.badge-cancelada { background: #f1f1f1; color: #999; text-decoration: line-through; }

.pill-tipo { font-size: 0.72rem; font-weight: 700; padding: 0.18rem 0.5rem; border-radius: var(--radius-sm); background: var(--color-panel-2); border: 1px solid var(--color-border); }

/* ----- Tarjetas Kanban-like para columnas de estatus (2.1.2) ----- */
.board { display: grid; grid-template-columns: repeat(6, minmax(190px, 1fr)); gap: 0.8rem; overflow-x: auto; }
.board-col { background: var(--color-panel-2); border-radius: var(--radius); padding: 0.7rem; min-height: 200px; }
.board-col h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--color-muted); margin-bottom: 0.6rem; }
.board-card { background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 0.6rem; margin-bottom: 0.5rem; font-size: 0.8rem; cursor: pointer; overflow: hidden; }
.board-card:hover { border-color: var(--color-primary); }
.board-card .req { font-weight: 700; }
.board-card .meta { color: var(--color-muted); font-size: 0.72rem; margin-top: 0.2rem; }

/* Petición con solicitud de cancelación pendiente de confirmar por bodega */
.board-card-cancelacion { background: var(--color-danger-soft); border-color: var(--color-danger); }
.banda-cancelacion {
  background: var(--color-danger);
  color: #fff;
  font-weight: 700;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: center;
  padding: 0.25rem 0;
  margin: 0.5rem -0.6rem -0.6rem -0.6rem;
}

/* ----- Modal ----- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 35, 0.55); display: none; align-items: center; justify-content: center; padding: 1rem; z-index: 50; }
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: var(--radius); padding: 1.4rem; width: 100%; max-width: 680px; max-height: 90vh; overflow-y: auto; box-shadow: 0 25px 60px rgba(0,0,0,0.3); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.modal-close { background: transparent; color: var(--color-muted); font-size: 1.1rem; padding: 0.1rem 0.5rem; }

/* ----- Toast ----- */
#toast-container { position: fixed; bottom: 1.2rem; right: 1.2rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 80; }
.toast { background: var(--color-primary-dark); color: #fff; padding: 0.65rem 1rem; border-radius: var(--radius-sm); font-size: 0.85rem; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); animation: toast-in 0.2s ease forwards; }
.toast.error { background: var(--color-danger); }
.toast.success { background: var(--color-success); }
@keyframes toast-in { to { opacity: 1; transform: translateY(0); } }

/* ----- Mapa ----- */
.map-container { height: 460px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--color-border); }
.map-with-list { display: grid; grid-template-columns: 280px 1fr; gap: 1rem; }
.stops-list { max-height: 460px; overflow-y: auto; }
.stop-item { padding: 0.65rem; border: 1px solid var(--color-border); border-radius: var(--radius-sm); margin-bottom: 0.5rem; cursor: pointer; background: #fff; }
.stop-item.done { opacity: 0.55; }
.stop-item.active { border-color: var(--color-accent); box-shadow: 0 0 0 2px rgba(217,119,46,0.18); }
.stop-item .stop-order { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--color-primary); color: #fff; font-size: 0.72rem; font-weight: 700; margin-right: 0.4rem; }

.empty-state { text-align: center; color: var(--color-muted); padding: 2.5rem 1rem; font-size: 0.9rem; }
.helper-text { font-size: 0.78rem; color: var(--color-muted); margin-top: 0.25rem; }

.signature-pad { border: 1px dashed var(--color-border); border-radius: var(--radius-sm); background: #fff; touch-action: none; width: 100%; height: 160px; }

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .app-sidebar { width: 100%; display: flex; align-items: center; gap: 1rem; padding: 0.8rem 1rem; }
  .app-sidebar .brand { margin-bottom: 0; }
  .app-sidebar nav { display: flex; gap: 0.3rem; overflow-x: auto; }
  .app-sidebar .session-box { display: none; }
  .map-with-list { grid-template-columns: 1fr; }
  .board { grid-template-columns: repeat(2, minmax(160px,1fr)); }
}
