/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:    #007aff;
  --green:   #34c759;
  --red:     #ff3b30;
  --bg:      #f2f2f7;
  --card:    #ffffff;
  --dark:    #1c1c1e;
  --mid:     #3a3a3c;
  --gray:    #8e8e93;
  --divider: #e5e5ea;
  --radius:  16px;
  --safe-top:    env(safe-area-inset-top,    0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--dark);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app {
  height: 100%;
  min-height: 100dvh;
}

/* ── Loading screen ─────────────────────────────────────────────────────────── */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  gap: 32px;
  background: var(--blue);
}

.loading-screen .app-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #fff;
}

.loading-screen .app-logo .icon {
  font-size: 56px;
  line-height: 1;
}

.loading-screen .app-logo .name {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Views ──────────────────────────────────────────────────────────────────── */
.view {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-top: calc(var(--safe-top) + 20px);
  padding-bottom: calc(var(--safe-bottom) + 24px);
  padding-left: 20px;
  padding-right: 20px;
}

/* ── Login view ─────────────────────────────────────────────────────────────── */
.login-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 0 32px;
  gap: 8px;
}

.login-hero .icon {
  font-size: 64px;
  line-height: 1;
}

.login-hero .name {
  font-size: 40px;
  font-weight: 800;
  color: var(--blue);
  letter-spacing: -1.5px;
}

.login-hero .tagline {
  font-size: 17px;
  color: var(--gray);
  font-weight: 400;
}

/* ── Card component ─────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.card + .card { margin-top: 12px; }

/* ── Form ───────────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-group:last-child { margin-bottom: 0; }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

input, select {
  width: 100%;
  font-size: 17px;
  font-family: inherit;
  color: var(--dark);
  background: var(--bg);
  border: 1.5px solid var(--divider);
  border-radius: 10px;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

input:focus, select:focus { border-color: var(--blue); }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238e8e93' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: block;
  width: 100%;
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  text-align: center;
  border: none;
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { opacity: 0.8; transform: scale(0.98); }

.btn-primary {
  background: var(--blue);
  color: #fff;
  margin-top: 20px;
}

.btn-danger {
  background: var(--red);
  color: #fff;
  margin-top: 12px;
}

.btn-ghost {
  background: var(--bg);
  color: var(--blue);
  margin-top: 12px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-back {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 17px;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.btn-link {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* ── Section header ─────────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  flex: 1;
}

/* ── Tap view ───────────────────────────────────────────────────────────────── */
.tap-view {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-top: calc(var(--safe-top) + 16px);
  padding-bottom: calc(var(--safe-bottom) + 24px);
}

.tap-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 16px;
}

.tap-navbar .greeting {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.tap-navbar .nav-actions {
  display: flex;
  gap: 8px;
}

.btn-icon {
  background: var(--card);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s;
}

.btn-icon:active { transform: scale(0.9); }

/* ── Status card ─────────────────────────────────────────────────────────────── */
.status-card {
  margin: 0 20px;
  background: var(--card);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

.status-idle-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  margin-bottom: 4px;
}

.status-dot.active {
  background: var(--red);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,59,48,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(255,59,48,0); }
}

.status-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.status-subtitle {
  font-size: 15px;
  color: var(--gray);
}

.journey-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.journey-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--divider);
}

.journey-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.journey-label {
  font-size: 14px;
  color: var(--gray);
  font-weight: 500;
}

.journey-value {
  font-size: 16px;
  font-weight: 600;
}

.journey-value.fare {
  color: var(--blue);
  font-size: 20px;
}

/* ── Tap button ─────────────────────────────────────────────────────────────── */
.tap-action-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  gap: 20px;
}

.location-row {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.location-row label {
  color: var(--mid);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.6px;
}

.btn-tap {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: none;
  background: var(--green);
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 8px 32px rgba(52,199,89,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-tap.off {
  background: var(--red);
  box-shadow: 0 8px 32px rgba(255,59,48,0.4);
}

.btn-tap:active {
  transform: scale(0.94);
  box-shadow: 0 4px 16px rgba(52,199,89,0.3);
}

.btn-tap.off:active {
  box-shadow: 0 4px 16px rgba(255,59,48,0.3);
}

.btn-tap .tap-label {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 1px;
}

.btn-tap .tap-sub {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.85;
}

/* ── Card bar at bottom ───────────────────────────────────────────────────────── */
.card-bar {
  margin: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.card-bar .card-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 500;
}

.card-bar .card-brand {
  text-transform: capitalize;
  color: var(--gray);
  font-size: 14px;
}

/* ── Setup card view ─────────────────────────────────────────────────────────── */
.setup-header {
  margin-bottom: 24px;
}

.setup-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 16px 0 6px;
}

.setup-header p {
  font-size: 16px;
  color: var(--gray);
}

#payment-element {
  margin-bottom: 4px;
}

.powered-by {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
  font-size: 13px;
  color: var(--gray);
}

.powered-by svg { flex-shrink: 0; }

/* ── Receipt view ───────────────────────────────────────────────────────────── */
.receipt-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
  padding: calc(var(--safe-top) + 60px) 20px calc(var(--safe-bottom) + 24px);
  gap: 24px;
  text-align: center;
}

.receipt-checkmark {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: #fff;
  animation: pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.receipt-view h1 {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.receipt-view .subtext {
  font-size: 16px;
  color: var(--gray);
  margin-top: -16px;
}

.receipt-card {
  width: 100%;
  text-align: left;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--divider);
}

.receipt-row:last-child { border-bottom: none; }

.receipt-row .r-label { font-size: 15px; color: var(--gray); }
.receipt-row .r-value { font-size: 16px; font-weight: 600; }
.receipt-row.total .r-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--blue);
}

/* ── History view ───────────────────────────────────────────────────────────── */
.history-view {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-top: calc(var(--safe-top) + 16px);
  padding-bottom: calc(var(--safe-bottom) + 24px);
}

.history-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px 20px;
}

.history-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.trips-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 20px;
  overflow-y: auto;
}

.trip-item {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.05);
}

.trip-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.trip-icon.failed { background: #fff0ef; }

.trip-info { flex: 1; min-width: 0; }

.trip-route {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trip-meta {
  font-size: 13px;
  color: var(--gray);
  margin-top: 2px;
}

.trip-fare {
  font-size: 18px;
  font-weight: 700;
  color: var(--blue);
  flex-shrink: 0;
}

.trip-fare.failed {
  color: var(--red);
  font-size: 13px;
  font-weight: 600;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 12px;
  color: var(--gray);
  padding: 60px 40px;
  text-align: center;
}

.empty-state .empty-icon { font-size: 48px; }
.empty-state p { font-size: 16px; }

/* ── Error ──────────────────────────────────────────────────────────────────── */
.error-msg {
  color: var(--red);
  font-size: 14px;
  margin-top: 12px;
  text-align: center;
  min-height: 20px;
}

/* ── Hint text ──────────────────────────────────────────────────────────────── */
.hint {
  font-size: 13px;
  color: var(--gray);
  text-align: center;
  margin-top: 14px;
}

/* ── Utility ────────────────────────────────────────────────────────────────── */
.spacer { flex: 1; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
