/* Common styles shared by /app/ and /pricing/ pages.
   Variables are duplicated from landing's style.css so the landing remains independent. */

/* Self-hosted Inter (rsms.me/inter v4) — avoids Google Fonts third-party request. */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('fonts/InterVariable.woff2') format('woff2-variations');
}
@font-face {
    font-family: 'Inter';
    font-style: italic;
    font-weight: 100 900;
    font-display: swap;
    src: url('fonts/InterVariable-Italic.woff2') format('woff2-variations');
}

:root {
    --white: #fff;
    --bg: #f5f5f7;
    --card: #fff;
    --border: #e5e5ea;
    --text: #1d1d1f;
    --text2: #6e6e73;
    --text3: #aeaeb2;
    --blue: #007AFF;
    --red: #FF3B30;
    --green: #34C759;
    --orange: #FF9500;
    --purple: #AF52DE;
    --indigo: #5856D6;
    --teal: #5AC8FA;
    --pink: #FF2D55;
    --yellow: #FFCC00;
    --font: 'Inter',-apple-system,BlinkMacSystemFont,sans-serif;
    --r: 16px;
    --rl: 24px;
    --max: 1200px;
    --ease: cubic-bezier(.4,0,.2,1);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,.06), 0 12px 32px rgba(0,0,0,.04);
    --shadow-lg: 0 12px 48px rgba(0,0,0,.12);
}

[data-theme="dark"] {
    --white: #1c1c1e;
    --bg: #000000;
    --card: #1c1c1e;
    --border: #38383a;
    --text: #f5f5f7;
    --text2: #98989d;
    --text3: #636366;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4), 0 2px 8px rgba(0,0,0,.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.3);
    --shadow-lg: 0 12px 48px rgba(0,0,0,.6);
}

/* ===== Reset ===== */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior: smooth; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font-family: inherit; border: none; background: none; outline: none; color: inherit; }
button { cursor: pointer; }
input, textarea, select { color: var(--text); }

.container { max-width: var(--max); margin: 0 auto; padding: 0 24px; width: 100%; }
.hidden { display: none !important; }

/* ===== Header ===== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(245,245,247,.85);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .app-header { background: rgba(0,0,0,.85); }

.app-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    gap: 16px;
}
.app-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.app-logo img { width: 32px; height: 32px; border-radius: 7px; }
.app-logo span { font-weight: 700; font-size: .95rem; }

.app-nav {
    display: flex;
    align-items: center;
    gap: 22px;
    margin-left: auto;
    margin-right: 8px;
}
.app-nav a {
    color: var(--text2);
    font-size: .85rem;
    font-weight: 500;
    transition: color .2s;
}
.app-nav a:hover, .app-nav a.active { color: var(--blue); }

/* Items visible only to authenticated users (toggled by JS via .show). */
.auth-only { display: none !important; }
.auth-only.show { display: inline-flex !important; }

.app-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-btn {
    background: var(--card);
    border: 1px solid var(--border);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: .2s;
    color: var(--text);
    padding: 0;
    font-size: 1rem;
}
.icon-btn:hover { background: var(--bg); }

.lang-btn-sm {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 6px 13px;
    border-radius: 100px;
    font-size: .72rem;
    font-weight: 600;
    color: var(--text);
    transition: background .2s;
}
.lang-btn-sm:hover { background: var(--bg); }

/* Avatar / sign-in */
.avatar-wrap { position: relative; }
.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), var(--indigo));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: transform .15s;
    user-select: none;
}
.avatar:hover { transform: scale(1.05); }

.avatar-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 8px;
    box-shadow: var(--shadow-md);
    min-width: 240px;
    z-index: 60;
    animation: popIn .15s var(--ease);
}
@keyframes popIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

.avatar-menu .menu-info {
    padding: 8px 12px 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}
.avatar-menu .menu-email {
    font-size: .82rem;
    font-weight: 600;
    word-break: break-all;
}
.avatar-menu .menu-balance {
    font-size: .72rem;
    color: var(--text2);
    margin-top: 2px;
}

/* Wider variant — used when the menu hosts the mini-wallet breakdown. */
.avatar-menu-wide { min-width: 320px; }

/* ===== Mini-wallet inside avatar dropdown — mirrors iOS WalletView ===== */
.wallet-mini {
    padding: 12px 12px 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}
.wallet-mini-loading,
.wallet-mini-error {
    font-size: .78rem;
    color: var(--text2);
    text-align: center;
    padding: 8px 4px;
}
.wallet-mini-error { color: var(--red); }

.wallet-total {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 6px;
    margin-bottom: 12px;
}
.wallet-total-amount {
    font-size: 1.85rem;
    font-weight: 800;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}
.wallet-total-unit {
    font-size: .82rem;
    color: var(--text2);
    font-weight: 500;
}

.wallet-sub-card {
    background: var(--bg);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
}
.wallet-sub-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.wallet-sub-title {
    font-size: .82rem;
    font-weight: 700;
    color: var(--text);
}
.wallet-sub-rate {
    font-size: .72rem;
    color: var(--text2);
    font-variant-numeric: tabular-nums;
}
.wallet-progress {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}
.wallet-progress-fill {
    height: 100%;
    background: var(--blue);
    border-radius: 3px;
    transition: width .3s var(--ease);
}
.wallet-sub-meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: .7rem;
    color: var(--text2);
}
.wallet-sub-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-variant-numeric: tabular-nums;
}
.wallet-sub-renewal {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .72rem;
    color: var(--text2);
}

.wallet-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 4px;
    font-size: .82rem;
}
.wallet-row-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
    font-weight: 500;
}
.wallet-row-amount {
    color: var(--text2);
    font-variant-numeric: tabular-nums;
}
.avatar-menu button, .avatar-menu a {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: .85rem;
    color: var(--text);
    background: none;
    border: none;
    cursor: pointer;
    transition: background .15s;
}
.avatar-menu button:hover, .avatar-menu a:hover { background: var(--bg); }
.avatar-menu .menu-danger { color: var(--red); }

/* ===== Buttons ===== */
.btn {
    padding: 11px 22px;
    border-radius: 12px;
    font-size: .92rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all .25s var(--ease);
    border: 1px solid transparent;
    text-align: center;
    white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
    background: var(--blue);
    color: #fff;
    box-shadow: 0 2px 10px rgba(0,122,255,.18);
}
.btn-primary:hover:not(:disabled) {
    background: #0071e3;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0,122,255,.28);
}

.btn-secondary {
    background: var(--card);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--bg);
    border-color: var(--blue);
    color: var(--blue);
}
[data-theme="dark"] .btn-secondary:hover:not(:disabled) {
    background: rgba(255,255,255,.04);
}

.btn-ghost {
    background: transparent;
    color: var(--text);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg); }

.btn-danger {
    background: var(--red);
    color: #fff;
}
.btn-danger:hover:not(:disabled) {
    background: #e0322a;
    box-shadow: 0 4px 14px rgba(255,59,48,.25);
}

.btn-block { width: 100%; }
.btn-lg { padding: 14px 26px; font-size: 1rem; border-radius: 14px; }

/* ===== Forms ===== */
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}
.field label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text2);
}
.field input, .field select, .field textarea {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: .92rem;
    color: var(--text);
    transition: .2s;
    width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--blue);
    background: var(--card);
    box-shadow: 0 0 0 3px rgba(0,122,255,.12);
}
.field input::placeholder { color: var(--text3); }

/* ===== Modal ===== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 16px;
    animation: fadeIn .2s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
    background: var(--card);
    border-radius: 24px;
    padding: 28px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    animation: modalIn .25s var(--ease);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}
@keyframes modalIn { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -.02em;
    margin: 0;
}
.modal-subtitle {
    font-size: .88rem;
    color: var(--text2);
    margin-top: 6px;
    line-height: 1.5;
}
.modal-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg);
    color: var(--text2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: .15s;
    flex-shrink: 0;
}
.modal-close:hover { background: var(--border); color: var(--text); }

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
    pointer-events: none;
}
.toast {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 18px;
    box-shadow: var(--shadow-md);
    font-size: .88rem;
    color: var(--text);
    pointer-events: auto;
    animation: toastIn .25s var(--ease);
    border-left: 3px solid var(--blue);
}
.toast.toast-error { border-left-color: var(--red); }
.toast.toast-success { border-left-color: var(--green); }
.toast.toast-warning { border-left-color: var(--orange); }
.toast.fade-out { animation: toastOut .25s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

/* ===== Footer ===== */
.app-footer {
    background: var(--card);
    border-top: 1px solid var(--border);
    margin-top: auto;
}
.app-footer-inner {
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    max-width: var(--max);
    margin: 0 auto;
}
.app-footer-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: .85rem;
}
.app-footer-brand img { width: 24px; height: 24px; border-radius: 5px; }
.app-footer-links {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}
.app-footer-links a {
    color: var(--text2);
    font-size: .82rem;
    transition: .2s;
}
.app-footer-links a:hover { color: var(--blue); }
.app-footer-copy {
    color: var(--text3);
    font-size: .72rem;
    width: 100%;
    text-align: center;
    margin-top: 6px;
}

/* ===== Consent checkbox (signup) ===== */
.auth-consent {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color .2s var(--ease), background .2s var(--ease);
}
.auth-consent:hover { border-color: var(--text3); }
.auth-consent input[type="checkbox"] {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    accent-color: var(--blue);
    cursor: pointer;
}
.auth-consent-text {
    font-size: .82rem;
    line-height: 1.45;
    color: var(--text2);
}
.auth-consent-text a {
    color: var(--blue);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.auth-consent-text a:hover { text-decoration-thickness: 2px; }
.auth-consent-shake {
    animation: consentShake .42s var(--ease);
    border-color: var(--red);
}
@keyframes consentShake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(3px); }
    30%, 50%, 70% { transform: translateX(-5px); }
    40%, 60% { transform: translateX(5px); }
}

/* ===== Provider buttons ===== */
.provider-btn {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: .92rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all .2s var(--ease);
    border: 1px solid transparent;
    margin-bottom: 8px;
}
.provider-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.provider-apple {
    background: #000;
    color: #fff;
}
.provider-apple:hover { background: #1a1a1a; }
.provider-google {
    background: #fff;
    color: #1f1f1f;
    border-color: #dadce0;
}
.provider-google:hover { background: #f8f9fa; }
[data-theme="dark"] .provider-google { background: #fff; color: #1f1f1f; }
.provider-email {
    background: var(--blue);
    color: #fff;
}
.provider-email:hover { background: #0071e3; }

.divider-or {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text3);
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .1em;
    margin: 14px 0;
}
.divider-or::before, .divider-or::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ===== Tabs ===== */
.tabs-pill {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border-radius: 12px;
    padding: 3px;
    margin-bottom: 16px;
}
.tab-pill {
    flex: 1;
    padding: 8px 0;
    border-radius: 10px;
    font-size: .84rem;
    font-weight: 600;
    color: var(--text2);
    text-align: center;
    transition: .2s;
    background: none;
    border: none;
}
.tab-pill.active {
    background: var(--card);
    color: var(--text);
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
[data-theme="dark"] .tab-pill.active { box-shadow: 0 1px 4px rgba(0,0,0,.4); }

/* ===== Mobile ===== */
@media (max-width: 768px) {
    .app-header-inner { height: 56px; gap: 8px; }
    .app-nav { display: none; }
    .app-logo span { font-size: .9rem; }
    .modal { padding: 22px; border-radius: 18px; }
    .toast-container { right: 12px; left: 12px; max-width: none; }
    .app-footer-inner { flex-direction: column; text-align: center; }
}

/* ===== Info banner (limited-feature notice) ===== */
.info-banner {
    background: #fff8e6;
    border-bottom: 1px solid #f0e0a8;
    color: var(--text);
    font-size: .82rem;
    line-height: 1.4;
}
[data-theme="dark"] .info-banner {
    background: #2a2114;
    border-bottom-color: #4a3c20;
}
.info-banner-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
}
.info-banner .info-icon {
    flex-shrink: 0;
    color: #b78700;
    display: inline-flex;
    align-items: center;
}
[data-theme="dark"] .info-banner .info-icon { color: #e0b14a; }
.info-banner .info-text { flex: 1; }
.info-banner .info-link {
    color: var(--blue);
    font-weight: 500;
    margin-left: 6px;
    white-space: nowrap;
}
.info-banner .info-link:hover { text-decoration: underline; }
.info-banner .info-close {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: transparent;
    color: var(--text2);
    font-size: 1.4rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.info-banner .info-close:hover { background: rgba(0,0,0,.06); }
[data-theme="dark"] .info-banner .info-close:hover { background: rgba(255,255,255,.08); }

/* ===== Insufficient balance modal ===== */
.balance-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

@media (max-width: 600px) {
    .info-banner-inner { padding: 10px 16px; gap: 8px; }
    .info-banner .info-link { display: block; margin-left: 0; margin-top: 2px; }
}
