/* =========================================================
   PEDEGAS — Design System Global
   Paleta: Azul #1A6BFF | Fundo #F2F2F2 | Surface #FFFFFF
   ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #1A6BFF;
  --primary-dark: #1450CC;
  --primary-light: #E8F0FF;
  --amber: #FFC107;
  --amber-dark: #E5AC00;
  --success: #22C55E;
  --error: #EF4444;
  --surface: #FFFFFF;
  --bg: #F2F2F2;
  --text: #1A1A2E;
  --text-sec: #6B7280;
  --border: #E5E7EB;
  --shadow: 0 2px 12px rgba(26,107,255,.10);
  --shadow-md: 0 8px 32px rgba(26,107,255,.18);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-pill: 50px;
}

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

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #C4C4C4; border-radius: 3px; }

/* =========================================================
   ADMIN PANEL — Layout
   ========================================================= */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 160px;
  background: var(--primary);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width .3s;
}
.sidebar-logo {
  padding: 28px 12px 20px;
  font-size: 18px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.5px;
  border-bottom: 1px solid rgba(255,255,255,.15);
}
.sidebar-logo span { color: var(--amber); }
.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px;
  color: rgba(255,255,255,.75);
  font-size: 13px;
  font-weight: 500;
  transition: all .2s;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.1); color: white; }
.nav-item.active { background: rgba(255,255,255,.15); color: white; border-left-color: var(--amber); }
.nav-item i { font-size: 20px; min-width: 20px; }
.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,.15);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,.85);
  font-size: 13px;
}
.avatar {
  width: 36px; height: 36px;
  background: var(--amber);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
}

/* Main content */
.main-content {
  flex: 1;
  margin-left: 160px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}
.topbar-title { font-size: 18px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.page-body { padding: 32px; flex: 1; }

/* ── Cards ── */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.card-title { font-size: 16px; font-weight: 700; }

/* ── KPI Grid ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}
.kpi-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--primary);
}
.kpi-card.amber::before { background: var(--amber); }
.kpi-card.success::before { background: var(--success); }
.kpi-card.error::before { background: var(--error); }
.kpi-label { font-size: 12px; font-weight: 600; color: var(--text-sec); text-transform: uppercase; letter-spacing: .5px; }
.kpi-value { font-size: 36px; font-weight: 800; color: var(--text); }
.kpi-sub { font-size: 12px; color: var(--text-sec); }
.kpi-icon {
  position: absolute;
  right: 20px; top: 50%;
  transform: translateY(-50%);
  font-size: 40px;
  opacity: .08;
  color: var(--primary);
}

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-sec);
  background: #F9FAFB;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #F9FAFB; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.badge-pendente { background: #FEF3C7; color: #92400E; }
.badge-em_rota  { background: #DBEAFE; color: #1D4ED8; }
.badge-entregue { background: #D1FAE5; color: #065F46; }
.badge-cancelado{ background: #FEE2E2; color: #991B1B; }
.badge-ativo    { background: #D1FAE5; color: #065F46; }
.badge-inativo  { background: #FEE2E2; color: #991B1B; }
.badge-master       { background: #EDE9FE; color: #5B21B6; }
.badge-cliente_agente { background: #FEF3C7; color: #92400E; }
.badge-cliente  { background: var(--primary-light); color: var(--primary); }
.badge-entregador { background: #D1FAE5; color: #065F46; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: all .2s;
  cursor: pointer;
  border: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-danger { background: var(--error); color: white; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-sec); margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: border-color .2s;
  background: white;
}
.form-control:focus { outline: none; border-color: var(--primary); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236B7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 36px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: white;
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  transform: translateY(20px) scale(.97);
  transition: transform .25s;
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-title { font-size: 20px; font-weight: 700; }
.modal-close { font-size: 24px; color: var(--text-sec); cursor: pointer; transition: color .2s; }
.modal-close:hover { color: var(--text); }

/* ── Alert banner ── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.alert-success { background: #D1FAE5; color: #065F46; }
.alert-error   { background: #FEE2E2; color: #991B1B; }
.alert-info    { background: #DBEAFE; color: #1D4ED8; }

/* ── Search bar ── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  width: 260px;
  transition: border-color .2s;
}
.search-bar:focus-within { border-color: var(--primary); background: white; }
.search-bar input { border: none; background: none; flex: 1; font-size: 14px; outline: none; }
.search-bar i { color: var(--text-sec); }

/* ── Chip / Tag ── */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
}

/* ── Section grid ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Toast ── */
.toast-container { position: fixed; top: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: white;
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  font-size: 14px;
  font-weight: 500;
  animation: slideIn .3s ease;
  border-left: 4px solid var(--primary);
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--error); }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(120%); } }

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 60%, #0D1B6E 100%);
}
.login-card {
  background: white;
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 80px rgba(0,0,0,.25);
}
.login-logo { font-size: 32px; font-weight: 800; color: var(--primary); margin-bottom: 8px; }
.login-logo span { color: var(--amber); }
.login-subtitle { color: var(--text-sec); font-size: 14px; margin-bottom: 32px; }

/* ── Status dot ── */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--success); }
.dot-amber { background: var(--amber); }
.dot-red   { background: var(--error); }
.dot-blue  { background: var(--primary); }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2,1fr); }
  .sidebar { width: 64px; }
  .sidebar-logo { font-size: 0; padding: 28px 20px 20px; }
  .sidebar-logo::after { content: 'P'; font-size: 22px; font-weight: 800; color: white; }
  .nav-item span { display: none; }
  .nav-item { justify-content: center; padding: 14px; }
  .main-content { margin-left: 64px; }
}
@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .page-body { padding: 16px; }
  .topbar { padding: 0 16px; }
}

/* =========================================================
   PRINT STYLES — PDF Report Export
   ========================================================= */
@media print {
  /* Hide interface elements */
  .sidebar, .topbar, .search-bar, .no-print, #topbar-btn, .topbar-actions, aside {
    display: none !important;
  }
  
  /* Reset layout constraints */
  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
  }
  
  .page-body {
    padding: 0 !important;
  }
  
  body {
    background: white !important;
    color: #000 !important;
    font-size: 12px !important;
  }
  
  /* Show print-specific header */
  .print-header {
    display: block !important;
  }
  
  /* Printable page layouts */
  .card {
    box-shadow: none !important;
    border: 1px solid var(--border) !important;
    margin-bottom: 24px !important;
    padding: 16px !important;
    page-break-inside: avoid;
  }
  
  .grid-3 {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr !important;
    gap: 12px !important;
    margin-bottom: 24px !important;
  }
  
  .kpi-card {
    border: 1px solid var(--border) !important;
    box-shadow: none !important;
    padding: 12px 16px !important;
    page-break-inside: avoid;
  }
  
  .kpi-card::before {
    height: 4px !important;
  }
  
  .kpi-value {
    font-size: 28px !important;
  }
  
  /* Tables formatting for print */
  table {
    width: 100% !important;
    border-collapse: collapse !important;
  }
  
  thead th {
    background: #F3F4F6 !important;
    color: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    border-bottom: 2px solid var(--border) !important;
  }
  
  tbody td {
    border-bottom: 1px solid var(--border) !important;
  }
}

