/*
 * Camada visual compartilhada dos três aplicativos Vai.
 * Mantém o fluxo existente e aproxima a experiência dos padrões de apps de
 * mobilidade: hierarquia forte, cartões limpos, ações grandes e mapa em foco.
 */
:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a0b;
  --surface: #141416;
  --surface-2: #1d1d20;
  --surface-3: #29292d;
  --line: #303034;
  --accent: #c8f23d;
  --accent-dim: #9fc520;
  --accent-2: #5b8cff;
  --route: #4f86ff;
  --text: #f7f7f8;
  --muted: #a0a0a8;
  --muted-2: #6f6f78;
  --danger: #ff6b6f;
  --success: #47d597;
  --warning: #ffb64d;
  --page: #030304;
  --glass: rgba(20, 20, 22, 0.94);
  --soft: rgba(255, 255, 255, 0.055);
  --soft-strong: rgba(255, 255, 255, 0.09);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  --button-bg: #f5f5f5;
  --button-text: #090909;
  --chat-own-bg: #c8f23d;
  --chat-own-text: #0b0e14;
  --chat-send-bg: #c8f23d;
  --chat-send-text: #0b0e14;
  --chat-other-bg: #1d1d20;
  --chat-other-text: #f7f7f8;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f5f3;
  --surface: #ffffff;
  --surface-2: #f1f1ef;
  --surface-3: #e5e5e2;
  --line: #dcdcd8;
  --accent: #171718;
  --accent-dim: #343438;
  --accent-2: #245de8;
  --route: #246bfe;
  --text: #111113;
  --muted: #66666d;
  --muted-2: #929298;
  --danger: #d83239;
  --success: #087d4b;
  --warning: #a85b00;
  --page: #e7e7e4;
  --glass: rgba(255, 255, 255, 0.94);
  --soft: rgba(0, 0, 0, 0.045);
  --soft-strong: rgba(0, 0, 0, 0.085);
  --shadow: 0 24px 70px rgba(25, 25, 25, 0.16);
  --button-bg: #111113;
  --button-text: #ffffff;
  --chat-own-bg: #111113;
  --chat-own-text: #ffffff;
  --chat-send-bg: #111113;
  --chat-send-text: #ffffff;
  --chat-other-bg: #f1f1ef;
  --chat-other-text: #111113;
}

body {
  background:
    radial-gradient(circle at 20% 10%, color-mix(in srgb, var(--route) 12%, transparent), transparent 34%),
    var(--page) !important;
  color: var(--text);
}

.device {
  background: var(--bg) !important;
  width: 100% !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-width: none !important;
  max-height: none !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.notch {
  display: none !important;
}

.screen {
  background: var(--bg) !important;
}

.vai-app-chrome {
  position: absolute;
  top: max(10px, env(safe-area-inset-top, 0px));
  left: 18px;
  right: 18px;
  z-index: 850;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.vai-wordmark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 3px 11px 3px 4px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--text);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(16px);
  font-family: var(--font-d, "Inter", sans-serif);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.vai-wordmark-logo {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: block;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.vai-wordmark-label {
  display: flex;
  align-items: baseline;
  gap: 7px;
  white-space: nowrap;
}

.vai-wordmark small {
  color: var(--muted);
  font-family: var(--font-b, "Inter", sans-serif);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.vai-header-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.vai-header-logo {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  display: block;
  border-radius: 16px;
  object-fit: cover;
  border: 1px solid color-mix(in srgb, var(--route) 34%, var(--line));
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
}

.vai-splash-logo {
  width: 92px;
  height: 92px;
  display: block;
  border-radius: 26px;
  object-fit: cover;
  border: 1px solid rgba(91, 140, 255, 0.32);
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.38);
}

.vai-theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--text);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(16px);
  cursor: pointer;
  pointer-events: auto;
  font-size: 17px;
  line-height: 1;
  overflow: hidden;
}

.vai-theme-toggle .vai-icon {
  width: 21px;
  height: 21px;
  margin: 0;
  pointer-events: none;
  stroke-width: 1.9;
}

.vai-theme-toggle[data-current-theme="dark"] .vai-icon {
  color: #ffd166;
}

.vai-theme-toggle[data-current-theme="light"] .vai-icon {
  color: #334155;
}

.vai-theme-toggle:hover {
  background: var(--surface-2);
}

.vai-theme-toggle:active {
  transform: scale(0.94);
}

/* Chave simples e retangular para configurações binárias. */
.vai-switch-input {
  appearance: none;
  width: 44px;
  height: 24px;
  flex: 0 0 44px;
  margin: 0;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--muted-2) 48%, var(--line));
  border-radius: 6px;
  background: var(--surface-3);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.16);
  cursor: pointer;
  position: relative;
  transition: background 180ms ease, border-color 180ms ease;
}

.vai-switch-input::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.24);
  transition: transform 200ms ease, background 180ms ease;
}

.vai-switch-input:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.vai-switch-input:checked::before {
  transform: translateX(20px);
  background: var(--bg);
}

.vai-switch-input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--route) 38%, transparent);
  outline-offset: 3px;
}

.header {
  padding-top: calc(62px + env(safe-area-inset-top, 0px)) !important;
}

.headerbar {
  padding-top: calc(62px + env(safe-area-inset-top, 0px)) !important;
}

.topbar-float,
.safety-btn {
  top: calc(58px + env(safe-area-inset-top, 0px)) !important;
}

.title,
.dtitle,
.section-title,
.metric-value,
.sheet h2 {
  letter-spacing: -0.035em !important;
}

.title,
.dtitle {
  color: var(--text);
}

.card,
.stat-card,
.list-item,
.driver-card,
.request-card,
.summary-row,
.pay-row {
  background: var(--surface) !important;
  border-color: var(--line) !important;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.08);
}

.sheet {
  background: var(--glass) !important;
  border-top-color: var(--line) !important;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.26) !important;
  backdrop-filter: blur(22px);
}

.field,
.input,
.search-input-wrap,
.search-trigger,
.channel-toggle,
.quick-dest .item,
.ride-emoji,
.place-icon,
.action-circle,
.chip,
.tag,
.badge {
  background: var(--surface-2) !important;
  border-color: var(--line) !important;
  color: var(--text);
}

.field:focus,
.input:focus,
.search-input-wrap:focus-within {
  border-color: var(--text) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 9%, transparent);
}

.btn,
.btn-primary {
  min-height: 52px;
  border-radius: 15px !important;
  background: var(--button-bg) !important;
  color: var(--button-text) !important;
  box-shadow: none !important;
}

.btn:hover,
.btn-primary:hover {
  filter: brightness(0.91);
}

.btn.secondary,
.btn-outline,
.btn-ghost {
  background: var(--surface-2) !important;
  border: 1px solid var(--line) !important;
  color: var(--text) !important;
}

.btn.danger,
.btn-danger {
  background: color-mix(in srgb, var(--danger) 13%, var(--surface)) !important;
  border-color: color-mix(in srgb, var(--danger) 36%, var(--line)) !important;
  color: var(--danger) !important;
}

.tab.active,
.channel-opt.active {
  background: var(--text) !important;
  border-color: var(--text) !important;
  color: var(--bg) !important;
}

.ride-option {
  border-radius: 18px !important;
}

.ride-option.selected {
  background: color-mix(in srgb, #c8f23d 11%, var(--surface)) !important;
  border-color: #a9ce2d !important;
}

.bottomnav,
.bottom-nav {
  background: var(--glass) !important;
  border-top-color: var(--line) !important;
  backdrop-filter: blur(22px) !important;
}

.navitem.active,
.nav-button.active {
  color: var(--text) !important;
  background: color-mix(in srgb, #c8f23d 16%, transparent) !important;
}

.status-pill:not(.off),
.badge,
.pill.active {
  background: color-mix(in srgb, #c8f23d 13%, var(--surface)) !important;
  color: color-mix(in srgb, #96ba1c 88%, var(--text)) !important;
}

.toast {
  background: var(--surface-3) !important;
  border-color: var(--line) !important;
  color: var(--text);
}

/* Contraste previsível do chat nos temas claro e escuro. */
.trip-chat-panel,
.trip-chat-form {
  background: var(--surface) !important;
  color: var(--text) !important;
}

.trip-chat-header {
  border-color: var(--line) !important;
}

.trip-chat-message {
  background: var(--chat-other-bg) !important;
  border: 1px solid var(--line);
  color: var(--chat-other-text) !important;
}

.trip-chat-message.mine {
  background: var(--chat-own-bg) !important;
  border-color: transparent !important;
  color: var(--chat-own-text) !important;
}

.trip-chat-time {
  color: inherit !important;
}

.trip-chat-input {
  background: var(--surface-2) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
}

.trip-chat-input::placeholder {
  color: var(--muted) !important;
  opacity: 1;
}

.trip-chat-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--chat-send-bg) !important;
  border: 1px solid transparent !important;
  color: var(--chat-send-text) !important;
}

.trip-chat-send:disabled {
  cursor: wait;
  opacity: 0.55;
}

.trip-chat-icon-button {
  background: var(--surface-2) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
}

.leaflet-container {
  background: var(--surface-2) !important;
}

html[data-theme="dark"] .leaflet-tile-pane {
  filter: brightness(0.72) saturate(0.72) contrast(1.14);
}

html[data-theme="light"] .leaflet-tile-pane {
  filter: none;
}

html[data-theme="light"] input.field[type="date"] {
  color-scheme: light;
}

*:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--route) 48%, transparent) !important;
  outline-offset: 2px;
}

button,
a,
[role="button"],
input,
select,
textarea {
  touch-action: manipulation;
}

button,
[role="button"],
a.list-row {
  min-width: 44px;
  min-height: 44px;
}

button:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.58;
}

@media (forced-colors: active) {
  .btn,
  .card,
  .input,
  .field,
  .trip-chat-message {
    border: 1px solid CanvasText !important;
  }
}

@media (min-width: 800px) {
  .vai-app-chrome {
    left: 28px;
    right: 28px;
    top: max(16px, env(safe-area-inset-top, 0px));
  }

  .header {
    padding-top: calc(72px + env(safe-area-inset-top, 0px)) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Acabamento premium compartilhado pelos apps de passageiro e motorista. */
:root,
html[data-theme="dark"] {
  --bg: #080d15;
  --surface: #111927;
  --surface-2: #172235;
  --surface-3: #213049;
  --line: rgba(151, 171, 204, 0.17);
  --accent: #cfff3d;
  --accent-dim: #a8d628;
  --text: #f6f8fc;
  --muted: #9ba9bd;
  --muted-2: #66758c;
  --page: #05080e;
  --glass: rgba(12, 19, 31, 0.9);
  --button-bg: #d4ff50;
  --button-text: #08100f;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.48);
}

html[data-theme="light"] {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-2: #f1f4f8;
  --surface-3: #e5ebf2;
  --line: rgba(38, 56, 82, 0.13);
  --accent: #171d27;
  --accent-dim: #2e3746;
  --text: #111823;
  --muted: #637083;
  --muted-2: #8b97a8;
  --page: #e8edf4;
  --glass: rgba(255, 255, 255, 0.9);
  --button-bg: #111823;
  --button-text: #ffffff;
  --shadow: 0 28px 74px rgba(30, 46, 70, 0.16);
}

body {
  background:
    radial-gradient(circle at 8% -8%, color-mix(in srgb, var(--route) 18%, transparent), transparent 34%),
    radial-gradient(circle at 96% 4%, color-mix(in srgb, #cfff3d 9%, transparent), transparent 28%),
    var(--page) !important;
}

.screen {
  background:
    radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--route) 7%, transparent), transparent 30%),
    var(--bg) !important;
}

.vai-icon {
  display: block;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  color: inherit;
  overflow: visible;
}

.vai-icon-lg {
  width: 26px;
  height: 26px;
  stroke-width: 1.65;
}

.vai-icon-sm {
  width: 17px;
  height: 17px;
}

.vai-icon-shell,
.login-card-icon,
.home-info-icon,
.home-safety-icon,
.lr-icon,
.ride-emoji,
.navigation-status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.vai-icon-shell {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 1px solid color-mix(in srgb, var(--route) 24%, var(--line));
  border-radius: 13px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--route) 13%, var(--surface-2)), var(--surface-2));
  color: color-mix(in srgb, var(--route) 72%, var(--text));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08), 0 8px 18px rgba(0, 0, 0, 0.1);
}

.card,
.stat-card,
.list-item,
.driver-card,
.request-card,
.summary-row,
.pay-row,
.home-info-card,
.login-method-card {
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--surface) 97%, white 3%), var(--surface)) !important;
  border-color: var(--line) !important;
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.045),
    0 16px 42px rgba(0, 0, 0, 0.1) !important;
}

.btn,
.btn-primary {
  border: 1px solid color-mix(in srgb, var(--button-bg) 78%, white 22%) !important;
  background: linear-gradient(135deg, color-mix(in srgb, var(--button-bg) 92%, white 8%), var(--button-bg)) !important;
  box-shadow: 0 12px 28px color-mix(in srgb, var(--button-bg) 18%, transparent) !important;
  font-weight: 750 !important;
  letter-spacing: -0.01em;
}

.btn.secondary,
.btn-outline,
.btn-ghost {
  background: linear-gradient(145deg, color-mix(in srgb, var(--surface-2) 95%, white 5%), var(--surface-2)) !important;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.04) !important;
}

.field,
.input,
.trip-chat-input,
.search-input-wrap,
.search-trigger {
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.field:focus,
.input:focus,
.trip-chat-input:focus,
.search-input-wrap:focus-within {
  border-color: color-mix(in srgb, var(--route) 76%, var(--text)) !important;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--route) 13%, transparent) !important;
}

.icon-btn,
.vai-theme-toggle,
.trip-chat-icon-button,
.map-interaction-toggle {
  color: var(--text) !important;
  border-color: color-mix(in srgb, var(--line) 88%, transparent) !important;
  background: color-mix(in srgb, var(--glass) 94%, transparent) !important;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18), inset 0 1px rgba(255, 255, 255, 0.06) !important;
  backdrop-filter: blur(18px) saturate(145%);
}

.icon-btn,
.vai-theme-toggle {
  width: 46px;
  height: 46px;
  border-radius: 16px !important;
}

.vai-wordmark {
  min-height: 46px;
  border-radius: 16px;
  padding: 4px 12px 4px 4px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.16), inset 0 1px rgba(255, 255, 255, 0.06);
}

.vai-wordmark-logo {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
  border-radius: 12px;
}

.bottomnav,
.bottom-nav {
  background: color-mix(in srgb, var(--glass) 95%, transparent) !important;
  border-top: 1px solid var(--line) !important;
  box-shadow: 0 -14px 38px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(26px) saturate(150%) !important;
}

.navitem,
.nav-button {
  min-height: 54px;
  border: 1px solid transparent;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.navitem .vai-icon,
.nav-button .vai-icon {
  width: 22px;
  height: 22px;
  stroke-width: 1.75;
}

.navitem.active,
.nav-button.active {
  color: var(--text) !important;
  border-color: color-mix(in srgb, #cfff3d 20%, transparent);
  background: linear-gradient(145deg, color-mix(in srgb, #cfff3d 15%, transparent), color-mix(in srgb, var(--route) 7%, transparent)) !important;
}

.auth-shell {
  position: relative;
  isolation: isolate;
}

.auth-shell::before {
  content: "";
  position: absolute;
  z-index: -1;
  width: 260px;
  height: 260px;
  top: -85px;
  right: -105px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--route) 17%, transparent);
  filter: blur(10px);
  pointer-events: none;
}

.auth-card {
  margin-top: 26px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow), inset 0 1px rgba(255, 255, 255, 0.055);
  backdrop-filter: blur(20px) saturate(140%);
}

.auth-kicker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  color: color-mix(in srgb, var(--route) 72%, var(--text));
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.auth-input-wrap {
  position: relative;
}

.auth-input-wrap > [data-vai-icon] {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 16px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.auth-input-wrap > [data-vai-icon] .vai-icon {
  width: 19px;
  height: 19px;
}

.auth-input-wrap > .field,
.auth-input-wrap > .input {
  padding-left: 48px !important;
}

.auth-trust {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}

.auth-trust .vai-icon {
  width: 17px;
  height: 17px;
  color: color-mix(in srgb, var(--success) 75%, var(--text));
}

/* O controle de localização ocupa sua própria coluna e não sobrepõe marca ou foto. */
#screen-home .topbar-float {
  top: calc(70px + env(safe-area-inset-top, 0px)) !important;
  left: 16px;
  right: 16px;
  display: grid !important;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: start !important;
  gap: 12px;
  pointer-events: none;
}

#screen-home .topbar-float > * {
  pointer-events: auto;
}

#screen-home .home-brand-pill {
  display: none !important;
}

#screen-home .topbar-float .icon-btn,
#btn-locate {
  width: 48px !important;
  height: 48px !important;
  border-radius: 17px !important;
}

#btn-locate {
  position: relative;
  z-index: 2;
  grid-column: 3;
  color: var(--text);
}

#btn-locate .vai-icon {
  width: 21px;
  height: 21px;
}

#btn-locate.is-locating .vai-icon {
  animation: vaiLocatePulse 850ms ease-in-out infinite alternate;
}

@keyframes vaiLocatePulse {
  from { transform: scale(0.84); opacity: 0.58; }
  to { transform: scale(1.08); opacity: 1; }
}

#home-location-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: min(52vw, 260px);
  text-transform: none;
}

#home-location-label .vai-icon {
  width: 14px;
  height: 14px;
}

.trip-communication-button,
.driver-trip-communication-button,
.trip-chat-icon-button,
.trip-chat-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.trip-communication-button .vai-icon,
.driver-trip-communication-button .vai-icon {
  width: 18px;
  height: 18px;
}

.trip-chat-icon-button .vai-icon,
.trip-chat-send .vai-icon,
.profile-photo-badge .vai-icon,
.driver-photo-badge .vai-icon {
  width: 17px;
  height: 17px;
}

html[data-theme="light"] .leaflet-control-zoom a,
html[data-theme="light"] .leaflet-control-attribution {
  color: #172033 !important;
}

@media (max-width: 380px) {
  #screen-home .home-brand-pill {
    padding-right: 7px;
    font-size: 10px;
  }

  #screen-home .home-brand-pill img {
    width: 28px;
    height: 28px;
  }

  .vai-wordmark small {
    display: none;
  }
}
