/* Rede Auto Pro — Design System (estilos extras além do Tailwind) */

/* ========== Tokens ========== */
:root {
  --navy: #0B1F3B;
  --teal: #1FA2A6;
  --paper: #F3F5F7;
  --ink: #2C2C2C;
  --line: #E2E8F0;
}

/* ========== Reset/base ========== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; }

/* Mobile overflow guard - impede scroll horizontal não intencional */
html, body { overflow-x: hidden; max-width: 100vw; }
@media (max-width: 768px) {
  main { overflow-x: hidden; max-width: 100%; min-width: 0; }
  .max-w-7xl, .max-w-6xl, .max-w-5xl, .max-w-4xl, .max-w-3xl, .max-w-2xl { max-width: 100%; }
  /* Forçar containers grid/flex a respeitarem o pai */
  [class*="grid-cols"] > *, [class*="flex"] > * { min-width: 0; }
  .card { min-width: 0; max-width: 100%; }
  /* Quebra de palavras longas */
  p, span, div, dt, dd, h1, h2, h3, h4, li, td, th, a { overflow-wrap: anywhere; }
  /* fake-map com largura controlada */
  .fake-map { max-width: 100%; min-width: 0; }
  /* mensagem WhatsApp/notas ficam em block */
  .wa-bubble { max-width: 100%; word-wrap: break-word; }
  /* Tabelas e grids podem ter scroll interno se necessário */
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* Inputs e selects respeitam container */
  input, select, textarea, button { max-width: 100%; }
}

/* ========== Scrollbar elegante ========== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--paper); }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ========== Animações ========== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse-soft { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 rgba(31, 162, 166, 0.5); } 70% { box-shadow: 0 0 0 14px rgba(31, 162, 166, 0); } 100% { box-shadow: 0 0 0 0 rgba(31, 162, 166, 0); } }
@keyframes shimmer { 0% { background-position: -1000px 0; } 100% { background-position: 1000px 0; } }

.fade-in { animation: fadeIn 0.4s ease-out; }
.slide-up { animation: slideUp 0.4s ease-out; }
.slide-down { animation: slideDown 0.3s ease-out; }
.pulse-ring { animation: pulse-ring 2s infinite; }

/* ========== Componentes custom ========== */

/* Logo Rede Auto Pro */
.logo-mark {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, #0B1F3B 0%, #1FA2A6 100%);
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(11,31,59,0.15);
}
.logo-mark svg { width: 100%; height: 100%; display: block; }
.logo-mark.lg { width: 48px; height: 48px; border-radius: 12px; }
.logo-mark.xl { width: 64px; height: 64px; border-radius: 16px; }
/* Wordmark da marca */
.brand-text { font-weight: 800; letter-spacing: -0.02em; line-height: 1; color: var(--navy); white-space: nowrap; }
.brand-text .brand-pro { color: var(--teal); }

/* Botão primário (verde-água) */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--teal); color: white;
  padding: 12px 20px; border-radius: 10px;
  font-weight: 600; font-size: 14px;
  transition: all 0.2s; border: none; cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  min-height: 44px;
}
.btn-primary:hover { background: #178388; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(31,162,166,0.25); }
.btn-primary:active { transform: translateY(0); }
.btn-primary.lg { padding: 14px 28px; font-size: 16px; }

/* Botão secundário (navy) */
.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--navy); color: white;
  padding: 12px 20px; border-radius: 10px;
  font-weight: 600; font-size: 14px;
  transition: all 0.2s; border: none; cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  min-height: 44px;
}
.btn-secondary:hover { background: #1A3A6B; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(11,31,59,0.25); }
.btn-secondary.lg { padding: 14px 28px; font-size: 16px; }

/* Botão outline */
.btn-outline {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: white; color: var(--navy);
  padding: 12px 20px; border-radius: 10px;
  font-weight: 600; font-size: 14px;
  border: 1.5px solid var(--line);
  transition: all 0.2s; cursor: pointer;
  min-height: 44px;
}
.btn-outline:hover { border-color: var(--navy); background: #F8FAFC; }

/* Botão ghost */
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: transparent; color: var(--navy);
  padding: 10px 16px; border-radius: 8px;
  font-weight: 500; font-size: 14px;
  transition: all 0.2s; border: none; cursor: pointer;
}
.btn-ghost:hover { background: rgba(11,31,59,0.06); }

/* Card */
.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  transition: all 0.2s;
}
@media (max-width: 640px) {
  .card { padding: 18px; border-radius: 12px; }
}
.card.hover\:lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(11,31,59,0.08);
  border-color: rgba(31,162,166,0.3);
}

/* Inputs */
.input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: white;
  transition: all 0.2s;
  color: var(--ink);
}
.input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(31,162,166,0.15); }
.input.error { border-color: #EF4444; }

.label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.help { display: block; font-size: 12px; color: #6B7280; margin-top: 4px; }
.err { display: block; font-size: 12px; color: #EF4444; margin-top: 4px; }

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.badge-teal { background: rgba(31,162,166,0.12); color: #10676B; }
.badge-navy { background: rgba(11,31,59,0.08); color: var(--navy); }
.badge-amber { background: #FEF3C7; color: #92400E; }
.badge-emerald { background: #D1FAE5; color: #065F46; }
.badge-rose { background: #FFE4E6; color: #9F1239; }
.badge-slate { background: #F1F5F9; color: #475569; }

/* Status dot */
.dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; }
.dot-emerald { background: #10B981; box-shadow: 0 0 0 3px rgba(16,185,129,0.2); }
.dot-amber { background: #F59E0B; box-shadow: 0 0 0 3px rgba(245,158,11,0.2); }
.dot-slate { background: #64748B; box-shadow: 0 0 0 3px rgba(100,116,139,0.2); }

/* Tabs */
.tab { padding: 10px 14px; font-size: 14px; font-weight: 500; color: #64748B; border-bottom: 2px solid transparent; cursor: pointer; transition: all 0.15s; }
.tab.active { color: var(--navy); border-bottom-color: var(--teal); font-weight: 700; }
.tab:hover:not(.active) { color: var(--navy); }

/* Toast */
.toast-stack { position: fixed; top: 80px; right: 24px; z-index: 90; display: flex; flex-direction: column; gap: 12px; max-width: 380px; }
@media (max-width: 640px) {
  .toast-stack { top: 72px; right: 12px; left: 12px; max-width: none; }
}
.toast {
  background: white;
  border-left: 4px solid var(--teal);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 10px 40px rgba(11,31,59,0.18);
  display: flex; gap: 12px; align-items: start;
  animation: slideDown 0.4s ease-out;
}
.toast.success { border-left-color: #10B981; }
.toast.warn { border-left-color: #F59E0B; }
.toast.error { border-left-color: #EF4444; }
.toast .ico { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: rgba(31,162,166,0.12); color: var(--teal); }
.toast.success .ico { background: rgba(16,185,129,0.12); color: #10B981; }
.toast.warn .ico { background: rgba(245,158,11,0.12); color: #F59E0B; }
.toast.error .ico { background: rgba(239,68,68,0.12); color: #EF4444; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(11,31,59,0.55); backdrop-filter: blur(4px); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 24px; animation: fadeIn 0.2s; overflow-y: auto; }
.modal { background: white; border-radius: 16px; max-width: 480px; width: 100%; padding: 28px; animation: slideUp 0.3s; box-shadow: 0 24px 64px rgba(0,0,0,0.3); max-height: calc(100vh - 48px); overflow-y: auto; }
@media (max-width: 640px) {
  .modal-backdrop { padding: 12px; align-items: flex-end; }
  .modal { padding: 20px; max-height: calc(100vh - 24px); border-radius: 18px; }
}

/* Range slider customizado */
input[type=range].range-teal { -webkit-appearance: none; width: 100%; height: 6px; border-radius: 999px; background: linear-gradient(to right, var(--teal) 0%, var(--teal) var(--p,30%), #E2E8F0 var(--p,30%), #E2E8F0 100%); outline: none; }
input[type=range].range-teal::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: white; border: 3px solid var(--teal); cursor: pointer; box-shadow: 0 2px 8px rgba(31,162,166,0.4); }
input[type=range].range-teal::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: white; border: 3px solid var(--teal); cursor: pointer; box-shadow: 0 2px 8px rgba(31,162,166,0.4); }

/* Mapa estilizado (mock) */
.fake-map {
  position: relative;
  background:
    radial-gradient(circle at 30% 40%, rgba(31,162,166,0.08) 0, transparent 40%),
    radial-gradient(circle at 70% 60%, rgba(11,31,59,0.05) 0, transparent 35%),
    linear-gradient(135deg, #E2E8F0 0%, #F1F5F9 100%);
  border-radius: 14px;
  overflow: hidden;
  background-color: #DCE5EE;
}
.fake-map::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.4) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.4) 1px, transparent 1px),
    linear-gradient(rgba(11,31,59,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(11,31,59,0.06) 1px, transparent 1px);
  background-size: 80px 80px, 80px 80px, 16px 16px, 16px 16px;
  pointer-events: none;
}
.fake-map::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(90deg, transparent 49%, #BCC9D6 49%, #BCC9D6 51%, transparent 51%) 25% 35% / 60% 2px no-repeat,
    linear-gradient(45deg, transparent 49%, #BCC9D6 49%, #BCC9D6 51%, transparent 51%) 50% 70% / 40% 2px no-repeat,
    linear-gradient(120deg, transparent 49%, #BCC9D6 49%, #BCC9D6 51%, transparent 51%) 70% 50% / 50% 2px no-repeat;
  pointer-events: none; opacity: 0.7;
}
.map-pin {
  position: absolute;
  width: 32px; height: 32px;
  background: var(--teal);
  border: 3px solid white;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  cursor: pointer;
  transition: transform 0.2s;
  z-index: 5;
}
.map-pin:hover { transform: rotate(-45deg) scale(1.15); }
.map-pin.navy { background: var(--navy); }
.map-pin.amber { background: #F59E0B; }
.map-pin .label { position: absolute; top: -28px; left: 50%; transform: translateX(-50%) rotate(45deg); background: var(--navy); color: white; padding: 2px 8px; border-radius: 6px; font-size: 11px; white-space: nowrap; font-weight: 600; }
.map-radius {
  position: absolute;
  border-radius: 50%;
  border: 2px dashed var(--teal);
  background: rgba(31,162,166,0.06);
  pointer-events: none;
}

/* KPI tile */
.kpi { background: white; border: 1px solid var(--line); border-radius: 14px; padding: 20px; transition: all 0.2s; }
@media (max-width: 640px) { .kpi { padding: 16px; border-radius: 12px; } .kpi-value { font-size: 22px !important; } }
.kpi:hover { border-color: rgba(31,162,166,0.4); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(11,31,59,0.06); }
.kpi-icon { width: 40px; height: 40px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; }
.kpi-label { font-size: 13px; color: #64748B; font-weight: 500; }
.kpi-value { font-size: 28px; font-weight: 800; color: var(--navy); line-height: 1.1; margin-top: 4px; letter-spacing: -0.02em; }
.kpi-delta { font-size: 12px; font-weight: 600; margin-top: 6px; display: inline-flex; align-items: center; gap: 3px; }

/* Section heading */
.eyebrow { font-size: 13px; font-weight: 700; color: var(--teal); letter-spacing: 0.08em; text-transform: uppercase; }
.h-display { font-size: clamp(2rem, 4vw, 3.25rem); line-height: 1.05; font-weight: 800; color: var(--navy); letter-spacing: -0.025em; }
.h-section { font-size: clamp(1.5rem, 3vw, 2.25rem); font-weight: 800; color: var(--navy); letter-spacing: -0.02em; line-height: 1.15; }

/* Hero gradient */
.hero-grad {
  background:
    radial-gradient(ellipse 60% 80% at 80% 20%, rgba(31,162,166,0.18) 0, transparent 60%),
    radial-gradient(ellipse 80% 60% at 0% 100%, rgba(11,31,59,0.06) 0, transparent 60%),
    linear-gradient(180deg, #FFFFFF 0%, #F3F5F7 100%);
}
.hero-grad-dark {
  background:
    radial-gradient(ellipse at 70% 30%, rgba(31,162,166,0.4) 0, transparent 60%),
    linear-gradient(135deg, #0B1F3B 0%, #1A3A6B 100%);
}

/* Decorative pattern */
.dot-pattern {
  background-image: radial-gradient(circle, rgba(11,31,59,0.08) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* Form section */
.form-section { background: white; border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.form-section + .form-section { margin-top: 16px; }

/* Stepper */
.step { display: flex; align-items: center; gap: 8px; }
.step-num { width: 28px; height: 28px; border-radius: 50%; background: var(--paper); color: var(--ink); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; border: 2px solid var(--line); }
.step.active .step-num { background: var(--teal); color: white; border-color: var(--teal); }
.step.done .step-num { background: var(--navy); color: white; border-color: var(--navy); }
.step-label { font-size: 13px; font-weight: 500; color: #64748B; }
.step.active .step-label, .step.done .step-label { color: var(--navy); font-weight: 700; }

/* Empty state */
.empty { text-align: center; padding: 48px 24px; }
.empty-ico { width: 64px; height: 64px; border-radius: 16px; background: rgba(31,162,166,0.1); color: var(--teal); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 16px; }

/* Sidebar (dashboards) */
.sidebar { width: 240px; background: white; border-right: 1px solid var(--line); padding: 20px 16px; transition: transform 0.25s ease; }
.side-link { display: flex; align-items: center; gap: 12px; padding: 12px 12px; border-radius: 10px; color: var(--ink); font-size: 14px; font-weight: 500; transition: all 0.15s; text-decoration: none; min-height: 44px; }
.side-link:hover { background: var(--paper); }
.side-link.active { background: rgba(31,162,166,0.12); color: #10676B; font-weight: 700; }
.side-link.active i, .side-link.active svg { color: var(--teal); }

/* Sidebar drawer mobile */
.sidebar-backdrop { display: none; }
@media (max-width: 768px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 95;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(11,31,59,0.18);
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(11,31,59,0.5); z-index: 94;
    opacity: 0; pointer-events: none; transition: opacity 0.2s;
  }
  .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }
}

/* Topbar */
.topbar { background: white; border-bottom: 1px solid var(--line); padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
@media (max-width: 640px) {
  .topbar { padding: 10px 14px; }
}
.topbar-burger {
  display: none; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; background: var(--paper);
  border: 1px solid var(--line); cursor: pointer; flex-shrink: 0;
}
.topbar-burger:hover { background: white; border-color: var(--teal); }
@media (max-width: 768px) {
  .topbar-burger { display: inline-flex; }
}

/* Notification dot */
.notif-dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: #EF4444; border: 2px solid white; }

/* Mensagem WhatsApp template */
.wa-bubble { background: #DCF8C6; border-radius: 12px 12px 12px 4px; padding: 12px 14px; font-size: 14px; color: #1F2937; line-height: 1.5; max-width: 100%; white-space: pre-wrap; }

/* Print: limpar cores escuras */
@media print { .no-print { display: none !important; } }

/* ========== Phone Frame (mockup do app) ========== */
.phone-frame {
  width: 320px;
  height: 660px;
  background: #0F172A;
  border-radius: 44px;
  padding: 14px;
  box-shadow: 0 30px 80px rgba(11,31,59,0.25), 0 0 0 2px #1F2937 inset;
  position: relative;
  flex-shrink: 0;
}
@media (max-width: 380px) {
  .phone-frame { transform: scale(0.85); transform-origin: top center; margin-bottom: -100px; }
}
.phone-frame::before { /* botão lateral */
  content: ''; position: absolute; right: -3px; top: 130px; width: 3px; height: 60px; background: #1F2937; border-radius: 3px 0 0 3px;
}
.phone-frame::after { /* botão volume */
  content: ''; position: absolute; left: -3px; top: 110px; width: 3px; height: 90px; background: #1F2937; border-radius: 0 3px 3px 0;
}
.phone-screen {
  width: 100%; height: 100%;
  background: #F3F5F7;
  border-radius: 30px;
  overflow: hidden;
  position: relative;
  display: flex; flex-direction: column;
}
.phone-notch { /* dynamic island */
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 100px; height: 28px; background: #0F172A; border-radius: 16px;
  z-index: 10;
}
.phone-status {
  height: 44px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px 0 28px;
  font-size: 14px; font-weight: 700; color: #0F172A;
}
.phone-status .icons { display: flex; gap: 4px; align-items: center; }
.phone-app-bar {
  background: white; border-bottom: 1px solid #E2E8F0;
  padding: 12px 16px; display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.phone-content { flex: 1; overflow-y: auto; padding: 12px; background: #F3F5F7; }
.phone-content::-webkit-scrollbar { display: none; }
.phone-tabbar {
  height: 64px; background: white; border-top: 1px solid #E2E8F0;
  display: flex; align-items: center; justify-content: space-around;
  flex-shrink: 0;
}
.phone-tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 8px; color: #94A3B8; font-size: 10px; font-weight: 600; }
.phone-tab.active { color: var(--teal); }
.phone-tab i { width: 22px; height: 22px; }

/* Push notification fake */
.push-notif {
  background: rgba(255,255,255,0.95); backdrop-filter: blur(12px);
  border-radius: 18px; padding: 12px 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  display: flex; gap: 10px; align-items: start;
  border: 0.5px solid rgba(0,0,0,0.05);
}
.push-notif .ico { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg,#0B1F3B,#1FA2A6); flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: white; font-weight: 800; font-size: 14px; }
.push-notif .body { flex: 1; min-width: 0; }
.push-notif .title { font-size: 13px; font-weight: 700; color: #0F172A; margin-bottom: 1px; line-height: 1.2; }
.push-notif .text { font-size: 12px; color: #475569; line-height: 1.3; }
.push-notif .time { font-size: 11px; color: #94A3B8; flex-shrink: 0; }

/* QR placeholder */
.qr-mock {
  width: 140px; height: 140px;
  background-color: white;
  background-image:
    linear-gradient(45deg, #0F172A 25%, transparent 25%),
    linear-gradient(-45deg, #0F172A 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #0F172A 75%),
    linear-gradient(-45deg, transparent 75%, #0F172A 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  border: 8px solid white;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  position: relative;
}
.qr-mock::after {
  content: ''; position: absolute; inset: 35%;
  background: white;
}
.qr-mock::before {
  content: ''; position: absolute; inset: 40%;
  background: linear-gradient(135deg,#0B1F3B,#1FA2A6); border-radius: 4px;
  z-index: 1;
}

/* Chat in-app */
.chat-msg { display: flex; gap: 8px; margin-bottom: 12px; }
.chat-msg .bubble { max-width: 78%; padding: 10px 14px; border-radius: 16px; font-size: 13px; line-height: 1.4; word-wrap: break-word; }
.chat-msg.them .bubble { background: white; color: var(--ink); border-top-left-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
.chat-msg.me { justify-content: flex-end; }
.chat-msg.me .bubble { background: var(--teal); color: white; border-top-right-radius: 4px; }
.chat-msg .meta { font-size: 10px; color: #94A3B8; margin-top: 2px; }
.chat-msg.me .meta { text-align: right; color: rgba(255,255,255,0.8); }
