@import url('/assets/css/tw-design-system.css');

/* ==========================================================================
   TransportWorks PWA Premium Mobile Stylesheet
   ========================================================================== */

:root {
    --pwa-bg: #f0f4f8;
    --pwa-card-bg: #ffffff;
    --pwa-navy: #0b1f3a;
    --pwa-brand: #4f46e5;
    --pwa-brand-soft: #eef2ff;
    --pwa-accent: #f97316;
    --pwa-success: #16a34a;
    --pwa-danger: #dc3f4f;
    --pwa-text: #142033;
    --pwa-muted: #68758a;
    --pwa-line: #e8edf3;
    --pwa-tab-bg: #ffffff;
    --pwa-radius: 16px;
    --pwa-radius-sm: 12px;
}

[hidden] {
    display: none !important;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background-color: var(--pwa-bg);
}

body {
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--pwa-text);
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   App Shell & Main Layout
   ========================================================================== */

#app {
    max-width: 500px;
    margin: 0 auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background-color: var(--pwa-bg);
    position: relative;
}

/* ── Top Bar ────────────────────────────────────────────── */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    background: var(--pwa-navy);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar span {
    font-size: 15px;
    color: rgba(255,255,255,.75);
}

.topbar strong {
    color: #fff;
    font-weight: 700;
}

.link {
    background: none;
    border: none;
    color: rgba(255,255,255,.7);
    font-weight: 600;
    cursor: pointer;
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 8px;
    transition: all .18s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.link:hover {
    color: #fff;
    background: rgba(255,255,255,.1);
}

/* ── Main Content Area ─────────────────────────────────── */
main {
    flex: 1;
    padding: 20px 16px 100px;
    overflow-y: auto;
}

.pad {
    padding: 0 4px 12px;
}

/* ==========================================================================
   Premium Wallet Card
   ========================================================================== */

.wallet-hero {
    background: linear-gradient(145deg, var(--pwa-navy) 0%, #0d2d52 50%, #0a1e38 100%);
    color: #fff;
    border-radius: var(--pwa-radius);
    padding: 28px 24px;
    box-shadow: 0 12px 32px rgba(11, 31, 58, 0.35);
    position: relative;
    overflow: hidden;
}

.wallet-hero::before {
    content: '';
    position: absolute;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(23,105,224,0.2) 0%, transparent 70%);
    top: -60px;
    right: -40px;
    pointer-events: none;
}

.wallet-hero::after {
    content: '';
    position: absolute;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, rgba(249,115,22,0.12) 0%, transparent 70%);
    bottom: -30px;
    left: -20px;
    pointer-events: none;
}

.wallet-hero .muted {
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
}

.big {
    font-size: 36px;
    font-weight: 800;
    margin: 8px 0 20px;
    letter-spacing: -0.03em;
}

.wallet-sub {
    display: flex;
    gap: 28px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 16px;
}

.wallet-sub span {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}

.wallet-sub strong {
    display: block;
    color: #fff;
    font-size: 16px;
    margin-top: 4px;
    font-weight: 700;
}

/* ==========================================================================
   Content Cards & Lists
   ========================================================================== */

.card {
    background: var(--pwa-card-bg);
    border: none;
    border-radius: var(--pwa-radius);
    box-shadow: 0 2px 12px rgba(20, 32, 51, 0.06);
    padding: 22px 20px;
    margin-top: 16px;
    transition: transform .18s ease, box-shadow .18s ease;
}

.card:hover {
    box-shadow: 0 6px 20px rgba(20, 32, 51, 0.1);
}

.card h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--pwa-text);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: none;
    padding-left: 0;
}

.card h3 i, .text-accent-color {
    color: var(--pwa-brand);
    font-size: 18px;
}

.fare-line {
    font-size: 15px;
    padding: 12px 0;
    border-bottom: 1px solid var(--pwa-line);
    display: flex;
    justify-content: space-between;
}

.fare-line:last-of-type {
    border-bottom: none;
}

.fare-line strong {
    color: var(--pwa-accent);
    font-weight: 700;
}

.list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 0;
    padding: 14px 16px;
}

/* ==========================================================================
   Form Elements (PWA-specific overrides)
   ========================================================================== */

.tw-form-group {
    margin-bottom: 16px;
}

.tw-label {
    display: block;
    font-size: 11px;
    font-weight: 800;
    color: var(--pwa-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 7px;
}

.tw-input, .tw-select {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    border: 1.5px solid var(--pwa-line);
    border-radius: var(--pwa-radius-sm);
    background: #fff;
    color: var(--pwa-text);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease;
    box-sizing: border-box;
    -webkit-appearance: none;
}

.tw-input:focus, .tw-select:focus {
    border-color: var(--pwa-brand);
    box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.1);
}

.tw-input::placeholder {
    color: #a0aec0;
}

/* ── Buttons ───────────────────────────────────────────── */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 50px;
    border: none;
    border-radius: var(--pwa-radius-sm);
    font-size: 14px;
    font-weight: 750;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    font-family: inherit;
    transition: all .18s ease;
}

.btn-primary, .btn.btn-primary {
    background: var(--pwa-brand);
    color: #fff;
    box-shadow: 0 4px 14px rgba(23, 105, 224, 0.3);
}

.btn-primary:hover {
    background: #1459c0;
    box-shadow: 0 6px 20px rgba(23, 105, 224, 0.35);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn.ghost {
    background: var(--pwa-brand-soft);
    color: var(--pwa-brand);
    border: none;
    box-shadow: none;
    font-weight: 700;
    padding: 10px 16px;
    border-radius: var(--pwa-radius-sm);
    height: auto;
    width: auto;
    text-transform: none;
    letter-spacing: 0;
    font-size: 13px;
}

.btn.ghost:hover {
    background: #d6e4fa;
}

/* ==========================================================================
   Booking & Picker
   ========================================================================== */

.day-add {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 8px;
}

.day-add input {
    flex: 1;
    padding: 12px 14px;
    border: 1.5px solid var(--pwa-line);
    border-radius: var(--pwa-radius-sm);
    font-family: inherit;
    font-size: 14px;
    background: #fff;
    outline: none;
    transition: border-color .18s;
}

.day-add input:focus {
    border-color: var(--pwa-brand);
}

.quick {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.chip-btn {
    border: 1.5px solid var(--pwa-line);
    background: #fff;
    color: var(--pwa-muted);
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    transition: all .18s ease;
}

.chip-btn:hover {
    border-color: var(--pwa-brand);
    color: var(--pwa-brand);
    background: var(--pwa-brand-soft);
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--pwa-brand-soft);
    color: var(--pwa-brand);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 700;
    border: none;
    animation: chipIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.chip a {
    color: var(--pwa-brand);
    text-decoration: none;
    font-weight: 800;
    font-size: 16px;
    line-height: 1;
    transition: color .15s;
}

.chip a:hover {
    color: var(--pwa-danger);
}

.quote {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: var(--pwa-radius-sm);
    background: #f0f4f8;
    color: var(--pwa-muted);
    font-size: 13px;
    border-left: 3px solid #cbd5e1;
}

.quote .ok-txt {
    color: var(--pwa-success);
    font-weight: 700;
    font-size: 14px;
}

.quote .err-txt {
    color: var(--pwa-danger);
    font-weight: 700;
}

/* ==========================================================================
   QR Pass Card
   ========================================================================== */

.qr-box {
    margin: 24px auto;
    display: flex;
    justify-content: center;
}

.qr-box img {
    display: block;
    width: 200px;
    max-width: 70%;
    height: auto;
    background: #fff;
    padding: 14px;
    border-radius: var(--pwa-radius-sm);
    border: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.qr-token {
    display: block;
    word-break: break-all;
    background: #0f172a;
    color: #38bdf8;
    padding: 14px;
    border-radius: var(--pwa-radius-sm);
    margin-top: 16px;
    font-size: 11px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    text-align: left;
    max-height: 80px;
    overflow-y: auto;
    border: none;
}

.center {
    text-align: center;
}

/* ==========================================================================
   Premium Bottom Tab Navigation
   ========================================================================== */

.tabbar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 500px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: var(--pwa-tab-bg);
    border-top: 1px solid rgba(0,0,0,.06);
    z-index: 10;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 16px rgba(0,0,0,.05);
}

.tab {
    border: none;
    background: none;
    padding: 12px 4px 10px;
    font-size: 11px;
    color: var(--pwa-muted);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all .18s ease;
    position: relative;
    font-family: inherit;
}

.tab::before {
    content: '';
    position: absolute;
    top: 0;
    left: 25%;
    width: 50%;
    height: 3px;
    background: var(--pwa-brand);
    border-radius: 0 0 4px 4px;
    transform: scaleX(0);
    transition: transform .22s cubic-bezier(.4,0,.2,1);
}

.tab i {
    font-size: 20px;
    margin-bottom: 2px;
    transition: transform .2s ease;
}

.tab:active i {
    transform: scale(0.85);
}

.tab.active {
    color: var(--pwa-brand);
    font-weight: 700;
}

.tab.active::before {
    transform: scaleX(1);
}

/* ==========================================================================
   Premium Toast Notifications
   ========================================================================== */

.toast {
    position: fixed;
    left: 50%;
    top: 24px;
    transform: translateX(-50%) translateY(-150%);
    background: var(--pwa-navy);
    color: #fff;
    padding: 14px 24px;
    border-radius: 999px;
    z-index: 100;
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: 90vw;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.ok {
    background: var(--pwa-success);
}

.toast.err {
    background: var(--pwa-danger);
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.muted { color: var(--pwa-muted); }
.small { font-size: 12px; }
.text-center { text-align: center; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 20px; }
.mb-2 { margin-bottom: 12px; }
.w-full { width: 100%; }

/* Password toggle */
.password-wrapper {
    position: relative;
}
.password-wrapper .tw-input {
    padding-right: 60px;
}
.toggle-password {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    font-weight: 700;
    color: var(--pwa-brand);
    cursor: pointer;
    font-style: normal;
    user-select: none;
}

/* ==========================================================================
   Auth Screen (legacy classes still referenced)
   ========================================================================== */

.auth {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, #1e3a8a 0%, #0f172a 100%);
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.auth-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    border: none;
    border-radius: var(--pwa-radius);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    padding: 36px 28px;
    width: 100%;
    max-width: 400px;
}

.auth-card h1 {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    color: var(--pwa-brand);
    margin-bottom: 6px;
}

.auth-card p.muted {
    text-align: center;
    font-size: 14px;
    margin-bottom: 24px;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

/* ── Very small phones ── */
@media (max-width: 360px) {
    main { padding: 16px 12px 100px; }
    .wallet-hero { padding: 22px 18px; }
    .big { font-size: 30px; }
    .card { padding: 18px 16px; }
    .tw-input, .tw-select { font-size: 16px; height: 46px; } /* prevent iOS zoom */
}

/* ── Tablets & Desktop: card-style centered ── */
@media (min-width: 500px) {
    body { background: #e2e8f0; }
    #app {
        border-radius: 24px;
        margin: 24px auto;
        min-height: calc(100dvh - 48px);
        box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
        overflow: hidden;
    }
    main { padding: 24px 24px 110px; }
    .wallet-hero { padding: 32px 28px; }
    .big { font-size: 40px; }
}

/* ── Tablet 768px+ ── */
@media (min-width: 768px) {
    #app { max-width: 540px; }
    .tab { padding: 14px 8px; font-size: 12px; }
}

/* ── Landscape phone ── */
@media (max-height: 500px) and (orientation: landscape) {
    .tabbar { padding-bottom: 0; }
    .tab { padding: 8px 4px; font-size: 11px; }
    main { padding-bottom: 80px; }
    .wallet-hero { padding: 16px 20px; }
    .big { font-size: 24px; margin-bottom: 10px; }
}

/* ── Safe area inset (iPhone notch / Dynamic Island) ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .tabbar {
        padding-bottom: env(safe-area-inset-bottom);
    }
    main {
        padding-bottom: calc(90px + env(safe-area-inset-bottom));
    }
}
