/* ═══════════════════════════════════════════════════════════════
   BluPaya Universal Wallet — POC Stylesheet
   Mobile-first responsive design for PWA + desktop
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Dark theme (default) ──────────────────────────────── */
:root, [data-theme="dark"] {
    --bg-primary: #0F172A;
    --bg-secondary: #1E293B;
    --bg-card: #1E293B;
    --bg-input: #334155;
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --accent: #3B82F6;
    --accent-hover: #60A5FA;
    --accent-glow: rgba(59, 130, 246, 0.15);
    --danger: #EF4444;
    --warning: #F59E0B;
    --info: #3B82F6;
    --success: #10B981;
    --border: #334155;
    --border-light: #475569;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow: 0 4px 24px rgba(0,0,0,0.25);
    --font: 'Aptos', 'Calibri', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --mono: 'JetBrains Mono', monospace;
    --nav-height: 60px;
    --bottom-nav-height: 64px;
    --balance-gradient: linear-gradient(135deg, #1E3A8A 0%, #1D4ED8 50%, #2563EB 100%);
}

/* ── Light theme ───────────────────────────────────────── */
[data-theme="light"] {
    --bg-primary: #F8FAFC;
    --bg-secondary: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-input: #F1F5F9;
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --accent: #2563EB;
    --accent-hover: #1D4ED8;
    --accent-glow: rgba(37, 99, 235, 0.1);
    --danger: #DC2626;
    --warning: #D97706;
    --info: #2563EB;
    --success: #059669;
    --border: #E2E8F0;
    --border-light: #CBD5E1;
    --shadow: 0 4px 24px rgba(0,0,0,0.08);
    --balance-gradient: linear-gradient(135deg, #2563EB 0%, #3B82F6 50%, #60A5FA 100%);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ── Typography ────────────────────────────────────────────── */
h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1.1rem; font-weight: 500; }
.text-muted { color: var(--text-secondary); }
.text-mono { font-family: var(--mono); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

/* ── Layout ────────────────────────────────────────────────── */
.app-container {
    max-width: 480px;
    margin: 0 auto;
    padding-bottom: calc(var(--bottom-nav-height) + 16px);
    min-height: 100vh;
    min-height: 100dvh;
}
@media (min-width: 768px) {
    .app-container { max-width: 960px; padding: 0 24px; padding-bottom: 24px; }
}

.page { display: none; padding: 16px; animation: fadeIn 0.25s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Top Nav ───────────────────────────────────────────────── */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.top-nav .logo {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 8px;
}
.top-nav .logo svg { width: 28px; height: 28px; }
.top-nav .user-badge {
    font-size: 0.8rem;
    background: var(--bg-secondary);
    padding: 4px 12px;
    border-radius: 20px;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

/* ── Bottom Nav (mobile) ───────────────────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    height: var(--bottom-nav-height);
}
.bottom-nav button {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-family: var(--font);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 12px;
    cursor: pointer;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.bottom-nav button.active { color: var(--accent); }
.bottom-nav button svg { width: 22px; height: 22px; stroke-width: 1.5; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

/* ── Balance Card (hero) ───────────────────────────────────── */
.balance-card {
    background: var(--balance-gradient);
    border: none;
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}
.balance-card::after {
    content: '';
    position: absolute;
    top: -40%;
    right: -20%;
    width: 200px;
    height: 200px;
    background: rgba(255,255,255,0.04);
    border-radius: 50%;
}
.balance-card .label { font-size: 0.8rem; color: rgba(255,255,255,0.6); margin-bottom: 4px; }
.balance-card .amount { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; font-family: var(--mono); }
.balance-card .currency { font-size: 0.9rem; font-weight: 400; color: rgba(255,255,255,0.7); margin-left: 4px; }

/* ── Quick Actions Grid ────────────────────────────────────── */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}
.quick-action {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
    color: var(--text-primary);
    font-size: 0.75rem;
    -webkit-tap-highlight-color: transparent;
}
.quick-action:hover, .quick-action:active { border-color: var(--accent); background: var(--accent-glow); }
.quick-action svg { width: 24px; height: 24px; margin-bottom: 6px; stroke: var(--accent); stroke-width: 1.5; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}
.form-control {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 1rem;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }

/* ── Password toggle ───────────────────────────────────── */
.pw-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.pw-input {
    padding-right: 48px !important;
}
.pw-eye {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    margin: 0;
    -webkit-tap-highlight-color: transparent;
}
.pw-eye:hover,
.pw-eye:focus { color: var(--accent); outline: none; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--accent); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 8px 16px; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* ── Transaction List ──────────────────────────────────────── */
.txn-list { list-style: none; }
.txn-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.txn-item:last-child { border-bottom: none; }
.txn-info { flex: 1; }
.txn-type { font-size: 0.85rem; font-weight: 500; text-transform: capitalize; }
.txn-desc { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; }
.txn-date { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }
.txn-amount { font-family: var(--mono); font-size: 0.9rem; font-weight: 600; white-space: nowrap; }
.txn-amount.credit { color: var(--success); }
.txn-amount.credit::before { content: '+'; }
.txn-amount.debit { color: var(--danger); }
.txn-amount.debit::before { content: '-'; }

/* ── Stats Grid ────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
}
.stat-value { font-size: 1.4rem; font-weight: 700; font-family: var(--mono); }
.stat-label { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; }

/* ── Audit Table ───────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
th { text-align: left; padding: 8px 10px; color: var(--text-secondary); border-bottom: 2px solid var(--border); font-weight: 500; white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--text-primary); }
tr:hover td { background: rgba(255,255,255,0.02); }
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
}
.badge-success { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-info { background: rgba(59,130,246,0.15); color: var(--info); }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    align-items: flex-end;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
@media (min-width: 768px) { .modal-overlay.active { align-items: center; } }
.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 24px;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}
@media (min-width: 768px) {
    .modal { border-radius: var(--radius); }
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-close {
    background: none; border: none; color: var(--text-muted); font-size: 1.5rem;
    cursor: pointer; padding: 4px; line-height: 1;
}

/* ── Login Page ────────────────────────────────────────────── */
.login-container {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 24px;
}
.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo h1 { color: var(--accent); margin-top: 12px; font-size: 1.3rem; }
.login-logo p { color: var(--text-secondary); font-size: 0.85rem; margin-top: 4px; }

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-xs);
    margin-bottom: 16px;
    font-size: 0.85rem;
}
.alert-error { background: rgba(239,68,68,0.12); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }
.alert-success { background: rgba(16,185,129,0.12); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }

/* ── Utility ───────────────────────────────────────────────── */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.hidden { display: none !important; }

/* ── PWA Install Banner ────────────────────────────────────── */
.install-banner {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 8px);
    left: 16px;
    right: 16px;
    z-index: 150;
    background: var(--bg-secondary);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: none;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
}
.install-banner.show { display: flex; }
.install-banner p { font-size: 0.85rem; color: var(--text-primary); }
.install-banner .btn { padding: 8px 16px; font-size: 0.8rem; }

/* ── Section Header ────────────────────────────────────────── */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.section-header h2 { font-size: 1rem; }
.section-header a { font-size: 0.8rem; color: var(--accent); text-decoration: none; cursor: pointer; }

/* ── Loading ───────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-input);
    padding: 4px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}
.tab {
    flex: 1;
    padding: 8px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s;
}
.tab.active { background: var(--bg-card); color: var(--text-primary); }

/* ── NFC Tap ───────────────────────────────────────────── */
@keyframes nfcPulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); transform: scale(1); }
    50% { box-shadow: 0 0 0 16px transparent; transform: scale(1.05); }
}
.nfc-pulse { animation: nfcPulse 2s ease-in-out infinite; }

/* ── Link accent ───────────────────────────────────────── */
.link-accent { color: var(--accent); text-decoration: none; font-weight: 500; }
.link-accent:hover { text-decoration: underline; }

/* ── Settings rows ─────────────────────────────────────── */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    cursor: default;
}
.setting-row:last-child { border-bottom: none; }

/* ── Toggle switch ─────────────────────────────────────── */
[data-theme="light"] .top-nav { background: var(--bg-secondary); box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
[data-theme="light"] .bottom-nav { background: var(--bg-secondary); box-shadow: 0 -1px 3px rgba(0,0,0,0.06); }
[data-theme="light"] .login-card { box-shadow: 0 8px 32px rgba(0,0,0,0.08); }
[data-theme="light"] .login-container { background: #EFF6FF; }
[data-theme="light"] .balance-card .label { color: rgba(255,255,255,0.75); }
[data-theme="light"] .stat-card { box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
[data-theme="light"] .card { box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
[data-theme="light"] .quick-action { box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
[data-theme="light"] table tr:hover td { background: rgba(0,0,0,0.02); }
[data-theme="light"] .modal { background: var(--bg-card); }

/* ── Settings rows ─────────────────────────────────────── */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-label { font-size: 0.9rem; font-weight: 500; }

/* ── Toggle switch ─────────────────────────────────────── */
.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--bg-input);
    border-radius: 24px;
    transition: background 0.25s, border-color 0.25s;
    border: 1px solid var(--border);
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 2px;
    bottom: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: transform 0.25s, background 0.25s;
}
.toggle input:checked + .toggle-slider {
    background: var(--accent);
    border-color: var(--accent);
}
.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: #fff;
}

/* ── QR scan animation ─────────────────────────────────── */
@keyframes qrScanLine {
    0%, 100% { top: 20%; opacity: 0.3; }
    50% { top: 80%; opacity: 0.8; }
}
