/* ========== RESET & BASE ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --naranja: #FF6B00;
  --naranja-claro: #FF8C38;
  --negro: #111111;
  --gris-oscuro: #222222;
  --gris-medio: #444444;
  --gris-claro: #F5F5F5;
  --blanco: #FFFFFF;
  --verde: #22C55E;
  --rojo: #EF4444;
  --amarillo: #F59E0B;
  --azul: #3B82F6;
  --sombra: 0 2px 16px rgba(0,0,0,0.13);
  --radio: 14px;
  --radio-sm: 8px;
}

html { font-size: 16px; }

body {
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  background: var(--gris-claro);
  color: var(--negro);
  min-height: 100vh;
}

/* ========== LOGIN / PORTADA ========== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #111 60%, #FF6B00 200%);
  padding: 24px;
}

.login-logo {
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--naranja);
  letter-spacing: -1px;
  margin-bottom: 4px;
}

.login-sub {
  color: #aaa;
  font-size: 0.95rem;
  margin-bottom: 36px;
}

.login-card {
  background: var(--gris-oscuro);
  border-radius: var(--radio);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--sombra);
}

.login-card h2 {
  color: var(--blanco);
  font-size: 1.2rem;
  margin-bottom: 20px;
}

.role-btn {
  display: block;
  width: 100%;
  padding: 16px;
  margin-bottom: 12px;
  border-radius: var(--radio-sm);
  border: 2px solid transparent;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
}

.role-btn .icon { font-size: 1.5rem; }
.role-btn .info { display: flex; flex-direction: column; }
.role-btn .info span:first-child { font-size: 1rem; }
.role-btn .info span:last-child { font-size: 0.78rem; font-weight: 400; opacity: 0.75; }

.role-btn.admin { background: #1a1a2e; border-color: var(--azul); color: var(--blanco); }
.role-btn.admin:hover { background: var(--azul); }
.role-btn.rest { background: #1a2e1a; border-color: var(--verde); color: var(--blanco); }
.role-btn.rest:hover { background: var(--verde); color: var(--negro); }
.role-btn.rep { background: #2e1a00; border-color: var(--naranja); color: var(--blanco); }
.role-btn.rep:hover { background: var(--naranja); }

/* ========== INPUTS ========== */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.82rem; font-weight: 600; color: #aaa; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radio-sm);
  border: 1.5px solid #333;
  background: #1a1a1a;
  color: var(--blanco);
  font-size: 0.97rem;
  outline: none;
  transition: border 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--naranja); }
.field textarea { min-height: 80px; resize: vertical; }
.field select option { background: #1a1a1a; }

/* ========== BOTONES ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radio-sm);
  border: none;
  font-size: 0.97rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.16s;
}
.btn-primary { background: var(--naranja); color: var(--blanco); }
.btn-primary:hover { background: var(--naranja-claro); }
.btn-success { background: var(--verde); color: var(--blanco); }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger { background: var(--rojo); color: var(--blanco); }
.btn-danger:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; color: #aaa; border: 1.5px solid #333; }
.btn-ghost:hover { border-color: #666; color: var(--blanco); }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ========== HEADER ========== */
.header {
  background: var(--negro);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.header-logo { font-size: 1.3rem; font-weight: 900; color: var(--naranja); }
.header-role { font-size: 0.8rem; color: #888; }
.header-right { display: flex; align-items: center; gap: 10px; }

/* ========== MAIN CONTENT ========== */
.main { padding: 20px 16px; max-width: 700px; margin: 0 auto; }

/* ========== CARDS ========== */
.card {
  background: var(--blanco);
  border-radius: var(--radio);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--sombra);
}
.card-dark {
  background: var(--gris-oscuro);
  border-radius: var(--radio);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--sombra);
  color: var(--blanco);
}
.card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 14px; }
.card-dark h3 { font-size: 1rem; font-weight: 700; margin-bottom: 14px; color: var(--blanco); }

/* ========== BADGES / ESTADOS ========== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.badge-pendiente { background: #FEF3C7; color: #92400E; }
.badge-asignado  { background: #DBEAFE; color: #1E40AF; }
.badge-camino    { background: #EDE9FE; color: #5B21B6; }
.badge-entregado { background: #D1FAE5; color: #065F46; }
.badge-rechazado { background: #FEE2E2; color: #991B1B; }
.badge-activo    { background: #D1FAE5; color: #065F46; }
.badge-inactivo  { background: #F3F4F6; color: #6B7280; }

/* ========== PEDIDO CARD ========== */
.pedido-item {
  border: 1.5px solid #eee;
  border-radius: var(--radio-sm);
  padding: 14px;
  margin-bottom: 10px;
  background: #fafafa;
}
.pedido-item:last-child { margin-bottom: 0; }
.pedido-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.pedido-id { font-size: 0.8rem; color: #888; }
.pedido-body { font-size: 0.93rem; color: #333; }
.pedido-body p { margin-bottom: 4px; }
.pedido-footer { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.pedido-item-dark {
  border: 1.5px solid #333;
  border-radius: var(--radio-sm);
  padding: 14px;
  margin-bottom: 10px;
  background: #1a1a1a;
}
.pedido-item-dark .pedido-id { color: #666; }
.pedido-item-dark .pedido-body { color: #ccc; }

/* ========== USUARIO ITEM ========== */
.user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1.5px solid #eee;
  border-radius: var(--radio-sm);
  margin-bottom: 8px;
  background: #fafafa;
}
.user-info { display: flex; flex-direction: column; gap: 2px; }
.user-name { font-weight: 700; font-size: 0.95rem; }
.user-meta { font-size: 0.8rem; color: #888; }
.user-actions { display: flex; gap: 6px; }

/* ========== MAPA PLACEHOLDER ========== */
.mapa-box {
  background: #1a2535;
  border-radius: var(--radio-sm);
  height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #5a8a6a;
  font-size: 0.9rem;
  gap: 8px;
  margin-bottom: 14px;
  border: 1.5px solid #2a3a4a;
}
.mapa-box .mapa-icon { font-size: 2.2rem; }

/* ========== GPS STATUS ========== */
.gps-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radio-sm);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 14px;
}
.gps-bar.on { background: #D1FAE5; color: #065F46; }
.gps-bar.off { background: #FEE2E2; color: #991B1B; }
.gps-dot { width: 9px; height: 9px; border-radius: 50%; }
.gps-bar.on .gps-dot { background: var(--verde); animation: pulse 1.5s infinite; }
.gps-bar.off .gps-dot { background: var(--rojo); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.4); }
}

/* ========== TOAST ========== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--negro);
  color: var(--blanco);
  padding: 12px 24px;
  border-radius: 99px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  z-index: 9999;
  transition: transform 0.3s cubic-bezier(.175,.885,.32,1.275);
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--verde); }
.toast.error { background: var(--rojo); }
.toast.info { background: var(--azul); }

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: flex-end;
  z-index: 500;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-box {
  background: var(--gris-oscuro);
  border-radius: var(--radio) var(--radio) 0 0;
  padding: 28px 20px 32px;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  transform: translateY(60px);
  transition: transform 0.25s cubic-bezier(.175,.885,.32,1.275);
  color: var(--blanco);
}
.modal-overlay.open .modal-box { transform: translateY(0); }
.modal-title { font-size: 1.1rem; font-weight: 800; margin-bottom: 18px; color: var(--naranja); }

/* ========== TABS ========== */
.tabs { display: flex; gap: 4px; background: #eee; border-radius: var(--radio-sm); padding: 4px; margin-bottom: 18px; }
.tab-btn { flex: 1; padding: 9px; border: none; border-radius: 6px; background: transparent; font-size: 0.85rem; font-weight: 600; cursor: pointer; color: #888; transition: all 0.15s; }
.tab-btn.active { background: var(--blanco); color: var(--negro); box-shadow: 0 1px 4px rgba(0,0,0,0.1); }

.tabs-dark { display: flex; gap: 4px; background: #1a1a1a; border-radius: var(--radio-sm); padding: 4px; margin-bottom: 18px; }
.tab-btn-dark { flex: 1; padding: 9px; border: none; border-radius: 6px; background: transparent; font-size: 0.85rem; font-weight: 600; cursor: pointer; color: #666; transition: all 0.15s; }
.tab-btn-dark.active { background: var(--naranja); color: var(--blanco); }

/* ========== STATS ========== */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
.stat-box { background: var(--negro); border-radius: var(--radio-sm); padding: 16px; text-align: center; }
.stat-num { font-size: 2rem; font-weight: 900; color: var(--naranja); line-height: 1; }
.stat-label { font-size: 0.78rem; color: #888; margin-top: 4px; }

/* ========== EMPTY STATE ========== */
.empty { text-align: center; padding: 36px 20px; color: #aaa; }
.empty-icon { font-size: 2.5rem; margin-bottom: 8px; }
.empty p { font-size: 0.9rem; }

/* ========== NOTIFICACION PEDIDO NUEVO ========== */
.notif-pedido {
  position: fixed; top: 70px; left: 50%;
  transform: translateX(-50%) translateY(-120px);
  background: var(--naranja);
  color: var(--blanco);
  padding: 16px 24px;
  border-radius: var(--radio);
  font-weight: 700;
  font-size: 1rem;
  z-index: 9998;
  box-shadow: 0 4px 24px rgba(255,107,0,0.5);
  transition: transform 0.4s cubic-bezier(.175,.885,.32,1.275);
  text-align: center;
  max-width: 320px;
  width: 90vw;
}
.notif-pedido.show { transform: translateX(-50%) translateY(0); }

/* ========== RESPONSIVE ========== */
@media (min-width: 480px) {
  .main { padding: 24px 20px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
