/* ============================================================
   assets/css/app.css — Estilos globales RutaPan SaaS
   Diseño limpio, moderno, mobile-first
   ============================================================ */

:root {
  --primary:     #e07b2d;   /* naranja pan */
  --primary-dk:  #c4651a;
  --primary-lt:  #fdf0e3;
  --secondary:   #3d5a80;
  --success:     #2e7d32;
  --danger:      #c62828;
  --warning:     #f9a825;
  --info:        #0277bd;
  --gray-100:    #f8f9fa;
  --gray-200:    #e9ecef;
  --gray-400:    #ced4da;
  --gray-600:    #6c757d;
  --gray-800:    #343a40;
  --dark:        #1a1a2e;
  --white:       #ffffff;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow:      0 4px 12px rgba(0,0,0,.12);
  --radius:      10px;
  --radius-sm:   6px;
  --transition:  .2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ---- Layout base ---- */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--dark);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 1.2rem;
}
.sidebar-logo .logo-text { font-size: 1.1rem; font-weight: 700; }
.sidebar-logo .logo-sub  { font-size: .7rem; color: var(--gray-400); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem 0; }

.nav-section { padding: .5rem 1.5rem .25rem; font-size: .65rem; text-transform: uppercase;
  letter-spacing: .1em; color: var(--gray-600); }

.nav-item a {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem 1.5rem;
  color: rgba(255,255,255,.75);
  font-size: .9rem;
  transition: background var(--transition), color var(--transition);
  border-radius: 0;
}
.nav-item a:hover,
.nav-item.active a {
  background: rgba(255,255,255,.08);
  color: var(--white);
}
.nav-item.active a { border-left: 3px solid var(--primary); }
.nav-item a .icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: .8rem;
  color: var(--gray-400);
}

/* Contenido principal */
.main-content {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar .page-title { font-size: 1.1rem; font-weight: 600; }
.topbar .topbar-right { display: flex; align-items: center; gap: 1rem; }

.user-badge {
  display: flex; align-items: center; gap: .5rem;
  font-size: .875rem;
}
.user-avatar {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 50%;
  display: grid; place-items: center;
  color: white; font-weight: 700; font-size: .85rem;
}

.page-content { padding: 1.5rem; flex: 1; }

/* ---- Tarjetas ---- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.25rem; }

/* ---- Stat cards ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 1rem;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-icon.orange { background: var(--primary-lt); color: var(--primary); }
.stat-icon.blue   { background: #e3f2fd; color: var(--info); }
.stat-icon.green  { background: #e8f5e9; color: var(--success); }
.stat-icon.red    { background: #ffebee; color: var(--danger); }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .8rem; color: var(--gray-600); margin-top: .2rem; }

/* ---- Botones ---- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1.1rem;
  border-radius: var(--radius-sm);
  border: none; cursor: pointer;
  font-size: .875rem; font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1.4;
}
.btn-primary  { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dk); color: white; }
.btn-secondary { background: var(--gray-200); color: var(--gray-800); }
.btn-secondary:hover { background: var(--gray-400); }
.btn-success  { background: var(--success); color: white; }
.btn-danger   { background: var(--danger);  color: white; }
.btn-info     { background: var(--info);    color: white; }
.btn-sm       { padding: .3rem .75rem; font-size: .8rem; }
.btn-lg       { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-block    { width: 100%; justify-content: center; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ---- Formularios ---- */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .35rem; }
.form-control {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--gray-400);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  transition: border-color var(--transition);
  background: var(--white);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(224,123,45,.15); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.form-text { font-size: .78rem; color: var(--gray-600); margin-top: .25rem; }

/* ---- Tablas ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  background: var(--gray-100);
  padding: .65rem 1rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
tbody td {
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: middle;
}
tbody tr:hover { background: var(--primary-lt); }
tbody tr:last-child td { border-bottom: none; }

/* ---- Badges/estados ---- */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-success  { background: #e8f5e9; color: var(--success); }
.badge-danger   { background: #ffebee; color: var(--danger); }
.badge-warning  { background: #fff8e1; color: #c27400; }
.badge-info     { background: #e3f2fd; color: var(--info); }
.badge-gray     { background: var(--gray-200); color: var(--gray-600); }

/* ---- Alertas flash ---- */
.alert {
  padding: .85rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: .875rem;
}
.alert-success { background: #e8f5e9; color: var(--success); border-left: 4px solid var(--success); }
.alert-danger  { background: #ffebee; color: var(--danger);  border-left: 4px solid var(--danger); }
.alert-warning { background: #fff8e1; color: #856404;        border-left: 4px solid var(--warning); }
.alert-info    { background: #e3f2fd; color: var(--info);    border-left: 4px solid var(--info); }

/* ---- Mapa ---- */
#mapa { width: 100%; height: 400px; border-radius: var(--radius); border: 1px solid var(--gray-200); }
#mapa-repartidor { width: 100%; height: 60vh; border-radius: var(--radius); }

/* ============================================================
   VISTA REPARTIDOR — Mobile-first, botones grandes
   ============================================================ */
.rep-header {
  background: var(--primary);
  color: white;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.rep-header h1 { font-size: 1.1rem; }

.cliente-card {
  background: white;
  border-radius: var(--radius);
  margin: .75rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.cliente-card-header {
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--gray-200);
}
.cliente-card-body { padding: 1rem; }

.btn-rep {
  width: 100%;
  padding: .9rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
}
.btn-rep-primary  { background: var(--primary); color: white; }
.btn-rep-success  { background: var(--success); color: white; }
.btn-rep-danger   { background: var(--danger);  color: white; }
.btn-rep-info     { background: var(--info);    color: white; }
.btn-rep-warning  { background: var(--warning); color: var(--dark); }

/* Grid de 2 botones lado a lado en móvil */
.btn-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }

.pos-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  margin-bottom: .5rem;
}
.pos-qty { display: flex; align-items: center; gap: .5rem; }
.pos-qty input { width: 55px; text-align: center; padding: .3rem; border: 1px solid var(--gray-400);
  border-radius: 4px; font-size: 1rem; }
.pos-total-bar {
  background: var(--dark);
  color: white;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.1rem;
  font-weight: 700;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar { padding: .75rem 1rem; }
  .page-content { padding: 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  #mapa { height: 300px; }
}

/* Overlay para cerrar sidebar en móvil */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* ---- PWA / scrollbar fino ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-400); border-radius: 10px; }
