/* ===========================================================
   Mody Web — design system
   Purple-themed, modern, mobile-first, responsive.
   =========================================================== */
:root {
  --primary: #7D57FD;
  --primary-600: #6B45F5;
  --primary-700: #5C3CE0;
  --grad: linear-gradient(135deg, #5C5CFF 0%, #8960FF 100%);
  --bg: #F4F5F9;
  --card: #FFFFFF;
  --text: #111928;
  --muted: #6B7280;
  --muted-2: #9CA3AF;
  --line: #E5E7EB;
  --line-soft: #F1F2F6;
  --success: #16A34A;
  --danger: #DC2626;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(17, 25, 40, 0.08);
  --shadow-sm: 0 2px 10px rgba(17, 25, 40, 0.06);
  --maxw: 720px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }
img { max-width: 100%; display: block; }

/* Layout shell */
#app { min-height: 100vh; }
.screen { max-width: var(--maxw); margin: 0 auto; padding: 0 16px 48px; }
.section { margin-top: 20px; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------- Header ---------- */
.topbar {
  background: var(--grad);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 22px) 16px 84px;
  position: relative;
  overflow: hidden;
}
.topbar::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -1px; height: 60px;
  background: var(--bg);
  border-radius: 28px 28px 0 0;
}
.topbar-inner { max-width: var(--maxw); margin: 0 auto; position: relative; z-index: 2; }
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -0.3px; }
.brand .logo {
  width: 32px; height: 32px; border-radius: 9px; background: rgba(255,255,255,.18);
  display: grid; place-items: center; font-size: 18px;
}
.topbar h1 { font-size: 24px; margin: 18px 0 4px; font-weight: 800; letter-spacing: -0.5px; }
.topbar p { margin: 0; opacity: .9; font-size: 14px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: none;
  background: rgba(255,255,255,.16); color: #fff; font-size: 16px; display: grid; place-items: center;
  transition: background .15s ease;
}
.icon-btn:hover { background: rgba(255,255,255,.28); }
.nav-pill { display: flex; gap: 6px; background: rgba(255,255,255,.16); padding: 4px; border-radius: 999px; }
.nav-pill button {
  border: none; background: transparent; color: #fff; padding: 7px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600; opacity: .85;
}
.nav-pill button.active { background: #fff; color: var(--primary); opacity: 1; }

/* pull content up under the header curve */
.pull-up { margin-top: -64px; position: relative; z-index: 3; }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; border: 1px solid var(--line-soft);
}
.card + .card { margin-top: 16px; }
.card-flat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }

/* ---------- Form controls ---------- */
.field { position: relative; margin-top: 12px; }
.field:first-child { margin-top: 0; }
.label { font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 0 6px 2px; }
.control {
  display: flex; align-items: center; gap: 10px;
  background: #F9FAFB; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0 14px; height: 54px; transition: border-color .15s, box-shadow .15s;
}
.control:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(125,87,253,.12); background: #fff; }
.control .pre { color: var(--muted-2); font-size: 16px; }
.control input, .control select {
  flex: 1; border: none; outline: none; background: transparent; font-size: 16px; color: var(--text); min-width: 0;
}
.control input::placeholder { color: var(--muted-2); }
.control.button-like { cursor: pointer; }
.control .val { flex: 1; font-size: 16px; }
.control .val.empty { color: var(--muted-2); }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Counter */
.counter { display: flex; align-items: center; justify-content: space-between;
  background: #F9FAFB; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px; }
.counter .meta b { display: block; font-size: 15px; }
.counter .meta span { font-size: 12px; color: var(--muted); }
.counter .ctrls { display: flex; align-items: center; gap: 14px; }
.round {
  width: 34px; height: 34px; border-radius: 50%; border: none; font-size: 20px; line-height: 1;
  display: grid; place-items: center; background: var(--primary); color: #fff; transition: transform .1s, opacity .15s;
}
.round:hover { transform: scale(1.06); }
.round:disabled { background: #D1D5DB; cursor: not-allowed; transform: none; }
.round.minus { background: #EDE9FE; color: var(--primary); }
.counter .num { min-width: 18px; text-align: center; font-weight: 700; font-size: 16px; }

/* Chips (popular destinations) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; display: inline-flex; gap: 6px; align-items: center;
  transition: all .15s ease;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip .star { color: #F59E0B; }

/* Buttons */
.btn {
  width: 100%; border: none; border-radius: var(--radius-sm); padding: 16px; font-size: 16px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; transition: transform .08s, opacity .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-outline { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: #F5F2FF; }
.btn-danger-outline { background: #fff; color: var(--danger); border: 1.5px solid #FCA5A5; }
.btn-danger-outline:hover { background: #FEF2F2; }
.btn .sub { margin-left: auto; font-weight: 700; }
.btn-ghost { background: transparent; color: var(--muted); width: auto; padding: 10px; }

/* Section titles */
.title { font-size: 18px; font-weight: 800; letter-spacing: -0.3px; margin: 0; }
.title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.title-row .count { color: var(--muted); font-size: 14px; }

/* Date tabs */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.tab {
  flex: 0 0 auto; min-width: 78px; text-align: center; border: 1px solid var(--line); background: #fff;
  border-radius: 14px; padding: 10px 8px; transition: all .15s ease;
}
.tab b { display: block; font-size: 14px; }
.tab span { font-size: 11px; color: var(--muted); }
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tab.active span { color: rgba(255,255,255,.85); }

/* Trip card */
.trip { cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, border-color .12s; }
.trip:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #E3DEFB; }
.trip-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 7px; background: #EEF2FF; color: #4F46E5; }
.badge.gb { background: #ECFDF5; color: #047857; }
.badge.seat { background: #FEF3C7; color: #92400E; margin-left: auto; }
.trip-times { display: flex; align-items: center; gap: 12px; }
.trip-times .t { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.dashline { flex: 1; height: 2px; background: repeating-linear-gradient(90deg, var(--line) 0 6px, transparent 6px 12px); position: relative; }
.dashline::after { content: "🚌"; position: absolute; top: -11px; left: 50%; transform: translateX(-50%); font-size: 14px; background: var(--card); padding: 0 6px; }
.trip-cities { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-top: 6px; }
.trip-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.trip-foot .price { font-size: 20px; font-weight: 800; }
.trip-foot .price small { font-size: 12px; color: var(--muted); font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); background: #F3F4F6; padding: 5px 10px; border-radius: 999px; }

/* Route detail (ticket + summary) */
.route .point { display: flex; gap: 14px; align-items: flex-start; }
.route .dot { width: 38px; height: 38px; border-radius: 50%; background: #F3F0FF; display: grid; place-items: center; flex: 0 0 38px; }
.route .dot.to { background: #EEF6FF; }
.route .pt-city { font-weight: 700; font-size: 16px; }
.route .pt-sub { color: var(--muted); font-size: 13px; }
.route .connector { width: 2px; height: 22px; background: var(--line); margin-left: 18px; }
.kv { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 700; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }

/* Summary */
.sum-row { display: flex; justify-content: space-between; padding: 6px 0; color: var(--text); }
.sum-total { display: flex; justify-content: space-between; padding-top: 10px; margin-top: 6px; border-top: 1px solid var(--line); font-size: 19px; font-weight: 800; }

/* Payment methods */
.method { display: flex; align-items: center; gap: 12px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 16px; margin-top: 10px; transition: all .15s; }
.method:hover { border-color: #C9BEF9; }
.method.active { border-color: var(--primary); background: #F8F6FF; }
.method .m-icon { width: 40px; height: 40px; border-radius: 10px; background: #F3F4F6; display: grid; place-items: center; font-size: 18px; }
.method .m-body { flex: 1; }
.method .m-body b { display: block; font-size: 15px; }
.method .m-body span { font-size: 12px; color: var(--muted); }
.method .radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); }
.method.active .radio { border-color: var(--primary); background: radial-gradient(circle, var(--primary) 0 6px, #fff 6px); }

/* QR */
.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.qr-box { padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: 16px; }
.qr-box img { width: 190px; height: 190px; image-rendering: pixelated; }
.qr-box.dim { opacity: .25; }
.qr-cap { color: var(--muted); font-size: 13px; }

/* My tickets list */
.tk { cursor: pointer; }
.tk-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.status-chip { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.status-chip.ok { background: #ECFDF5; color: #047857; }
.status-chip.returned { background: #FEF2F2; color: var(--danger); }
.leg-label { font-size: 11px; font-weight: 800; color: var(--primary); letter-spacing: .6px; text-transform: uppercase; }

/* Success */
.success { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 40px; }
.check { width: 96px; height: 96px; border-radius: 50%; background: #EDE9FE; display: grid; place-items: center; margin-bottom: 22px; animation: pop .4s ease; }
.check svg { width: 46px; height: 46px; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.success h2 { font-size: 24px; margin: 0 0 6px; font-weight: 800; }
.success p { color: var(--muted); margin: 0 0 28px; }
.success .btn { max-width: 360px; }
.success .btn + .btn { margin-top: 12px; }

/* Empty state */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .emoji { font-size: 44px; }

/* Back link */
.back { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; background: none; border: none; padding: 16px 2px; font-size: 15px; }
.back:hover { color: var(--text); }

/* Loader + toast */
.loader-overlay { position: fixed; inset: 0; background: rgba(255,255,255,.55); display: grid; place-items: center; z-index: 100; }
.spinner { width: 42px; height: 42px; border: 4px solid #E5E0FB; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 24px); z-index: 200;
  background: #111928; color: #fff; padding: 13px 20px; border-radius: 12px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all .25s ease; max-width: 90%;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #B91C1C; }
.toast.success { background: #15803D; }

/* Modal (date picker / card chooser) */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(17,25,40,.45); z-index: 150; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: var(--maxw); border-radius: 22px 22px 0 0; padding: 20px 18px calc(env(safe-area-inset-bottom) + 22px); animation: up .25s ease; }
@keyframes up { from { transform: translateY(40px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
.sheet h3 { margin: 4px 0 14px; font-size: 17px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .dow { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; }
.cal button { border: none; background: #F9FAFB; border-radius: 10px; padding: 10px 0; font-size: 14px; font-weight: 600; color: var(--text); }
.cal button:hover { background: #EDE9FE; }
.cal button.sel { background: var(--primary); color: #fff; }
.cal button:disabled { color: #D1D5DB; background: transparent; cursor: default; }
.cal .pad { visibility: hidden; }
.sheet .month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet .month-nav b { font-size: 15px; }
.sheet .month-nav button { border: none; background: #F3F4F6; width: 34px; height: 34px; border-radius: 10px; font-size: 16px; }

/* helper */
.spacer { height: 14px; }
.hint { display: flex; gap: 8px; align-items: flex-start; background: #FFFBEB; border: 1px solid #FDE68A; color: #92400E; padding: 12px 14px; border-radius: 12px; font-size: 13px; }
@media (min-width: 760px) {
  .topbar { padding-top: 30px; }
  .trip-list-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .trip-list-grid .card { margin-top: 0 !important; }
}
