/* ShipX unified app — splash → role → auth → main */
:root {
  color-scheme: dark;
  --bg: #030712;
  --surface: #0f172a;
  --card: #1e293b;
  --border: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-dim: #1d4ed8;
  --client: #2563eb;
  --driver: #059669;
  --err: #f87171;
  --ok: #4ade80;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

.app-root {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: 1.25rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}
.screen.active {
  display: flex;
}

/* Splash — full viewport; logo always visible (no reliance on animation) */
.screen-splash {
  max-width: none;
  width: 100%;
  min-height: 100dvh;
  min-height: 100vh;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: radial-gradient(ellipse 90% 70% at 50% -25%, rgba(59, 130, 246, 0.45), transparent),
    radial-gradient(ellipse 55% 45% at 100% 30%, rgba(124, 58, 237, 0.35), transparent),
    radial-gradient(ellipse 50% 40% at 0% 70%, rgba(14, 165, 233, 0.12), transparent),
    var(--bg);
}
.splash-mark {
  width: 96px;
  height: 96px;
  margin: 0 auto 1.35rem;
  border-radius: 24px;
  background: linear-gradient(145deg, #3b82f6 0%, #6366f1 45%, #7c3aed 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 24px 64px rgba(37, 99, 235, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  opacity: 1;
  transform: scale(1);
  animation: splash-pop 0.85s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}
@keyframes splash-pop {
  from {
    transform: scale(0.92);
    opacity: 0.85;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .splash-mark {
    animation: none;
  }
  .splash-bar::after {
    animation: none;
    transform: translateX(80%);
  }
}
.splash-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin: 0 0 0.35rem;
  color: #f8fafc;
}
.splash-tag {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0 0 2rem;
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.45;
}
.splash-bar {
  width: 120px;
  height: 3px;
  background: var(--border);
  border-radius: 3px;
  margin: 0 auto;
  overflow: hidden;
}
.splash-bar::after {
  content: "";
  display: block;
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, var(--client), #a78bfa);
  border-radius: 3px;
  animation: splash-load 2.2s ease-in-out infinite;
}
@keyframes splash-load {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(350%);
  }
}
.splash-skip {
  margin-top: 2rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: underline;
  cursor: pointer;
}

/* Welcome / role — designed screen */
.screen-role {
  max-width: 440px;
  min-height: 100dvh;
  min-height: 100vh;
  justify-content: flex-start;
  padding-top: 2.25rem;
  background: radial-gradient(ellipse 100% 60% at 50% -20%, rgba(59, 130, 246, 0.22), transparent),
    linear-gradient(180deg, #0f172a 0%, #030712 50%, var(--bg) 100%);
}
.welcome-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.welcome-mark {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(145deg, #3b82f6, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 12px 32px rgba(37, 99, 235, 0.35);
}
.welcome-kicker {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 700;
  margin-bottom: 0.2rem;
}
.welcome-title {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  margin: 0;
  line-height: 1.15;
  color: #f8fafc;
}
.screen-role .lead {
  color: #94a3b8;
  font-size: 1rem;
  margin: 0 0 1.75rem;
  line-height: 1.55;
}
.role-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.role-card {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  padding: 1.2rem 1.25rem 1.2rem 1.15rem;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: linear-gradient(165deg, rgba(30, 41, 59, 0.95) 0%, rgba(15, 23, 42, 0.98) 100%);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}
.role-card:hover {
  border-color: rgba(148, 163, 184, 0.35);
}
.role-card:active {
  transform: scale(0.98);
}
.role-card.client {
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 4px 28px rgba(37, 99, 235, 0.12);
}
.role-card.driver {
  border-color: rgba(16, 185, 129, 0.35);
  box-shadow: 0 4px 28px rgba(5, 150, 105, 0.1);
}
.role-card h2 {
  margin: 0 0 0.35rem;
  padding-right: 1.5rem;
  font-size: 1.15rem;
  font-weight: 700;
}
.role-card.client h2 {
  color: #93c5fd;
}
.role-card.driver h2 {
  color: #6ee7b7;
}
.role-card p {
  margin: 0;
  font-size: 0.9rem;
  color: #94a3b8;
  line-height: 1.45;
  padding-right: 1.25rem;
}
.role-card .chev {
  position: absolute;
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
  font-size: 1.5rem;
  font-weight: 300;
  color: #64748b;
  line-height: 1;
  pointer-events: none;
}

details.api-advanced {
  margin-top: 2rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: rgba(15, 23, 42, 0.6);
  font-size: 0.85rem;
  color: var(--muted);
}
details.api-advanced summary {
  cursor: pointer;
  font-weight: 600;
  color: #cbd5e1;
}
details.api-advanced input {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

/* Auth */
.screen-auth {
  min-height: 100dvh;
  background: linear-gradient(180deg, #0f172a 0%, var(--bg) 40%);
}
.screen-auth .auth-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.screen-auth .back {
  background: var(--border);
  border: none;
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}
.screen-auth h1 {
  font-size: 1.2rem;
  margin: 0;
  flex: 1;
}
.auth-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  padding: 4px;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
}
.auth-tabs button {
  flex: 1;
  padding: 0.55rem;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}
.auth-tabs button.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.auth-form label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.65rem 0 0.2rem;
}
.auth-form input {
  width: 100%;
  padding: 0.6rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}
.auth-form .btn-primary {
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.85rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--client), #6366f1);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}
.screen-auth.driver-mode .btn-primary {
  background: linear-gradient(135deg, var(--driver), #0d9488);
}
.auth-msg {
  margin-top: 0.75rem;
  font-size: 0.88rem;
  min-height: 1.25rem;
}
.auth-msg.error {
  color: var(--err);
}
.auth-msg.ok {
  color: var(--ok);
}

/* Main shell */
.screen-main {
  padding-top: 0.75rem;
}
.main-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.main-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.main-top h1 {
  margin: 0;
  font-size: 1.15rem;
}
.main-top .badge-role {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: var(--card);
  color: var(--muted);
}
.main-nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.main-nav button {
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
}
.main-nav button.active {
  background: var(--card);
  color: var(--text);
  border-color: var(--accent);
}
.main-panel {
  display: none;
}
.main-panel.active {
  display: block;
}
.panel-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: 0.85rem;
}
.panel-card h3 {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  color: var(--muted);
}
.panel-card label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0.5rem 0 0.15rem;
}
.panel-card input,
.panel-card textarea {
  width: 100%;
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}
.panel-card .btn {
  margin-top: 0.65rem;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  margin-right: 0.35rem;
}
.panel-card .btn.secondary {
  background: var(--border);
}
.pre-out {
  background: #020617;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  font-size: 0.72rem;
  overflow: auto;
  max-height: 220px;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 0.5rem;
}
.btn-logout {
  background: transparent !important;
  border: 1px solid var(--border) !important;
  color: var(--muted) !important;
  font-size: 0.8rem !important;
  padding: 0.4rem 0.65rem !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.map-key-banner {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(248, 113, 113, 0.08);
}

.trip-block .trip-block-title {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 700;
}

.trip-search-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

@media (min-width: 380px) {
  .trip-search-row {
    flex-direction: row;
    align-items: stretch;
  }
  .trip-search-row .map-search-input {
    flex: 1;
    min-width: 0;
  }
  .trip-search-row .btn-confirm-search {
    flex-shrink: 0;
    white-space: nowrap;
    margin-top: 0 !important;
    align-self: center;
  }
}

.trip-search-row .map-search-input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
}

.trip-search-row .btn-confirm-search {
  margin-top: 0;
  padding: 0.55rem 0.85rem;
}

.client-map {
  width: 100%;
  height: min(52vh, 320px);
  min-height: 200px;
  border-radius: 12px;
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  overflow: hidden;
}

.pin-toggle {
  display: flex;
  gap: 0.35rem;
  margin: 0.65rem 0 0.25rem;
}
.pin-toggle button {
  flex: 1;
  padding: 0.45rem 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
}
.pin-toggle button.active {
  border-color: var(--accent);
  color: var(--text);
  background: var(--card);
}

.addr-pair {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.35rem;
}
.addr-block {
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.addr-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.addr-label.pickup {
  color: #4ade80;
}
.addr-label.dropoff {
  color: #f87171;
}
.addr-text {
  margin: 0.25rem 0 0;
  font-size: 0.88rem;
  line-height: 1.35;
  word-break: break-word;
}

.map-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}
.map-actions .btn {
  margin-top: 0;
  font-size: 0.78rem;
  padding: 0.45rem 0.65rem;
}

.client-toast {
  position: sticky;
  bottom: 0;
  margin-top: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 0.82rem;
}
.client-toast.err {
  border-color: rgba(248, 113, 113, 0.45);
  color: #fecaca;
}
