/* =============================================
   MyCreds Loyalty PWA — Mobile-first CSS
   Theme: Blue #1a3c6e / Yellow #f5c518
   ============================================= */
:root {
    --blue-dark: #1a3c6e;
    --blue-main: #2563eb;
    --blue-light: #eff6ff;
    --yellow: #f5c518;
    --yellow-dark: #eab308;
    --green: #22c55e;
    --red: #ef4444;
    --white: #ffffff;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-400: #94a3b8;
    --gray-600: #475569;
    --gray-800: #1e293b;
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius: 12px;
    --shadow: 0 4px 16px rgba(26,60,110,.12);
    --shadow-card: 0 8px 32px rgba(26,60,110,.18);

    /* ── White-label brand overrides (set via JS for Builder-plan stores) ── */
    --brand-primary:   #1a3c6e; /* maps to --blue-dark by default */
    --brand-secondary: #2563eb; /* maps to --blue-main by default */
    --brand-accent:    #f5c518; /* maps to --yellow by default    */
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-main);
    background: var(--brand-primary);
    color: var(--gray-800);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: var(--font-main); cursor: pointer; }
input, select, textarea { font-family: var(--font-main); }

/* ── App Shell ── */
.pwa-app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--gray-50);
}
.pwa-header {
    background: var(--brand-primary);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.pwa-header .logo {
    display: flex;
    align-items: center;
    gap: 10px;
}
.pwa-header .logo-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.pwa-header .logo-icon img {
    width: 34px;
    height: 34px;
    object-fit: cover;
    display: block;
    border-radius: 8px;
}
.pwa-header .logo-text {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: .3px;
}
.pwa-content {
    flex: 1;
    padding: 20px 16px 32px;
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
}

/* ── Splash / Loading ── */
.splash {
    min-height: 100vh;
    background: var(--brand-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    gap: 20px;
}
.splash .splash-logo {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(245,197,24,.3);
    animation: pulse 1.5s ease-in-out infinite;
}
.splash .splash-logo img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    display: block;
    border-radius: 20px;
}
@keyframes pulse { 0%,100%{transform:scale(1)}50%{transform:scale(1.06)} }
.splash h1 { font-size: 28px; font-weight: 800; letter-spacing: .5px; }
.splash p { font-size: 14px; color: rgba(255,255,255,.65); }
.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255,255,255,.2);
    border-top-color: var(--yellow);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to{transform:rotate(360deg)} }

/* ── Cards/Panels ── */
.panel {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 1px 6px rgba(0,0,0,.07);
    overflow: hidden;
    margin-bottom: 16px;
}
.panel-header {
    padding: 16px 18px 10px;
    border-bottom: 1px solid var(--gray-100);
}
.panel-header h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--blue-dark);
}
.panel-body { padding: 16px 18px; }

/* ── Setup Steps ── */
.step-indicator {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}
.step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gray-200);
    transition: .3s;
}
.step-dot.active { background: var(--brand-accent, var(--yellow)); transform: scale(1.3); }
.step-dot.done { background: var(--brand-secondary, var(--blue-main)); }

.setup-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 28px 22px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.setup-card h2 {
    font-size: 20px;
    font-weight: 800;
    color: var(--brand-primary, var(--blue-dark));
    margin-bottom: 6px;
}
.setup-card p.subtitle {
    font-size: 13px;
    color: var(--gray-400);
    margin-bottom: 20px;
    line-height: 1.5;
}

/* ── Form elements ── */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 6px;
}
.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: 10px;
    font-size: 16px; /* 16px prevents iOS zoom */
    color: var(--gray-800);
    outline: none;
    transition: border-color .2s;
    background: #fff;
}
.form-input:focus { border-color: var(--brand-secondary, var(--blue-main)); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-input.error { border-color: var(--red); }
.form-input.tel { letter-spacing: 1.5px; font-size: 18px; font-weight: 600; text-align: center; }

/* PIN Input */
.pin-row {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 8px 0;
}
.pin-box {
    width: 46px;
    height: 56px;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    color: var(--brand-primary, var(--blue-dark));
    outline: none;
    transition: .2s;
    background: #fff;
    caret-color: transparent;
}
.pin-box:focus { border-color: var(--brand-secondary, var(--blue-main)); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.pin-box.filled { background: var(--blue-light); border-color: var(--brand-secondary, var(--blue-main)); }

/* ── Buttons ── */
.btn-pwa {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    transition: .2s;
}
.btn-pwa:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary-pwa { background: var(--brand-primary, var(--blue-dark)); color: #fff; }
.btn-primary-pwa:not(:disabled):active { background: var(--brand-secondary, var(--blue-main)); }
.btn-yellow { background: var(--brand-accent); color: var(--brand-primary); }
.btn-yellow:not(:disabled):active { background: var(--yellow-dark); }
.btn-outline-pwa { background: transparent; color: var(--brand-primary, var(--blue-dark)); border: 2px solid var(--gray-200); }
.btn-sm-pwa { padding: 8px 16px; font-size: 13px; border-radius: 8px; }

/* ── Virtual Loyalty Card ── */
.loyalty-card {
    border-radius: 16px;
    padding: 20px;
    width: 100%;
    max-width: 380px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    min-height: 200px;
    display: flex;
    flex-direction: column;
    color: #fff;
    cursor: pointer;
    transition: transform .15s;
    user-select: none;
}
.loyalty-card:active { transform: scale(.98); }
.loyalty-card .card-bg-pattern {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}
.loyalty-card .card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    position: relative;
}
.loyalty-card .store-logo {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    object-fit: cover;
    background: rgba(255,255,255,.2);
}
.loyalty-card .store-name-badge {
    font-size: 11px;
    font-weight: 700;
    opacity: .85;
    letter-spacing: .6px;
    text-transform: uppercase;
}
.loyalty-card .card-number {
    font-size: 12px;
    font-family: 'Courier New', monospace;
    opacity: .65;
    letter-spacing: 1px;
    font-variant-numeric: slashed-zero;
}
.loyalty-card .stamp-grid {
    display: grid;
    grid-template-columns: repeat(var(--stamp-cols, 5), 1fr);
    gap: 10px;
    margin: 3px 0 12px;
    justify-items: center;
}
.loyalty-card .stamp {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: .2s;
    background: rgba(255,255,255,.1);
}
.loyalty-card .stamp.filled {
    background: var(--brand-accent);
    border-color: var(--brand-accent);
}
.loyalty-card .points-display {
    font-size: 32px;
    font-weight: 800;
    line-height: 1;
    margin: 8px 0;
}
.loyalty-card .points-label { font-size: 12px; opacity: .75; }
.loyalty-card .card-footer-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: auto;
}
.loyalty-card .reward-tag {
    background: var(--yellow);
    color: var(--blue-dark);
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 12px;
    opacity: .95;
}

/* QR Container */
.qr-section {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.qr-section canvas, .qr-section img { border-radius: 8px; }

/* ── Store Selector ── */
.store-list { display: flex; flex-direction: column; gap: 10px; }
.store-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    cursor: pointer;
    transition: .2s;
    background: #fff;
}
.store-item:hover, .store-item.selected {
    border-color: var(--blue-main);
    background: var(--blue-light);
}
.store-item .store-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--blue-dark);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 17px;
    flex-shrink: 0;
}
.store-item .store-info { flex: 1; min-width: 0; }
.store-item .store-info strong { display: block; font-size: 14px; color: var(--gray-800); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.store-item .store-info span { font-size: 12px; color: var(--gray-400); }
.store-item .check { color: var(--blue-main); opacity: 0; }
.store-item.selected .check { opacity: 1; }
.store-item.already-claimed {
    border-color: #bbf7d0;
    background: #f0fdf4;
    cursor: default;
    pointer-events: none;
    opacity: .85;
}
.store-item.already-claimed:hover,
.store-item.already-claimed.selected {
    border-color: #bbf7d0;
    background: #f0fdf4;
}
.store-item.already-claimed .store-icon {
    background: #16a34a;
}

/* ── Card Tabs ── */
.card-tabs {
    display: flex;
    gap: 0;
    background: var(--gray-100);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 16px;
    overflow-x: auto;
    scrollbar-width: none;
}
.card-tabs::-webkit-scrollbar { display: none; }
.card-tab {
    flex-shrink: 0;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    cursor: pointer;
    transition: .2s;
    border: none;
    background: transparent;
    white-space: nowrap;
}
.card-tab.active {
    background: #fff;
    color: var(--blue-dark);
    box-shadow: 0 1px 4px rgba(0,0,0,.1);
}

/* ── PWA Install Banner ── */
#_pwaBanner,
#_iosHint {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    padding: 0 16px 16px;
    transform: translateY(110%);
    transition: transform .32s cubic-bezier(.32,1,.45,1);
    pointer-events: none;
}
#_pwaBanner._pwa-banner-show,
#_iosHint._pwa-banner-show {
    transform: translateY(0);
    pointer-events: auto;
}
#_pwaBannerInner,
#_iosHintInner {
    background: #ffffff;
    border-radius: 16px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 -2px 12px rgba(0,0,0,.06), 0 8px 32px rgba(26,60,110,.16);
    border: 1.5px solid #e2e8f0;
    position: relative;
    max-width: 480px;
    margin: 0 auto;
}
#_iosHintInner { flex-direction: column; align-items: flex-start; }

/* ── Alert / Toast ── */
.pwa-alert {
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.4;
}
.pwa-alert.error { background: #fef2f2; color: #dc2626; }
.pwa-alert.success { background: #f0fdf4; color: #15803d; }
.pwa-alert.info { background: var(--blue-light); color: var(--blue-dark); }
.pwa-alert.warning { background: #fefce8; color: #92400e; }

/* ── Reward Banner ── */
.reward-banner {
    background: linear-gradient(135deg, var(--yellow), #f59e0b);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    box-shadow: 0 4px 16px rgba(245,197,24,.3);
}
.reward-banner .reward-emoji { font-size: 28px; }
.reward-banner .reward-text strong { display: block; font-size: 14px; font-weight: 700; color: var(--blue-dark); }
.reward-banner .reward-text span { font-size: 12px; color: rgba(26,60,110,.75); }

/* ── Coming from splash (fade in) ── */
@keyframes fadeInUp {
    from { opacity:0; transform:translateY(16px); }
    to   { opacity:1; transform:translateY(0); }
}
.fade-in { animation: fadeInUp .35s ease-out; }

/* ── Bottom nav (for card.html) ── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid var(--gray-200);
    display: flex;
    height: 60px;
    z-index: 200;
    box-shadow: 0 -2px 12px rgba(0,0,0,.06);
}
.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--gray-400);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: color .2s;
    border: none;
    background: none;
}
.bottom-nav-item.active { color: var(--brand-primary); }
.bottom-nav-item svg { width: 20px; height: 20px; }
.has-bottom-nav { padding-bottom: 72px; }

/* ── Misc ── */
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 18px 0; }
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26,60,110,.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}
.badge-pwa {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
}
.badge-blue { background: var(--blue-light); color: var(--blue-dark); }
.badge-yellow { background: #fefce8; color: #92400e; }
.badge-green { background: #f0fdf4; color: #15803d; }
