:root {
    --bg-color: #000000;
    --surface-color: #1c1c1e;
    --surface-hover: #2c2c2e;
    --primary-color: #0a84ff; /* iOS Blue */
    --text-primary: #ffffff;
    --text-secondary: #8e8e93;
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-bg: rgba(28, 28, 30, 0.7);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    min-height: calc(100vh - 160px); /* Adjust for header and nav */
    position: relative;
    padding: 20px;
    padding-bottom: 90px;
}

/* Glass Header */
.glass-header {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-balance {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(10, 132, 255, 0.1);
    border: 1px solid rgba(10, 132, 255, 0.2);
    color: var(--text-primary);
    padding: 6px 12px 6px 6px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.user-balance:active {
    transform: scale(0.95);
}
.balance-icon {
    width: 24px;
    height: 24px;
    border-radius: 12px;
    background: linear-gradient(135deg, #34c759, #30b050); /* Green gradient for money */
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo-icon {
    background: linear-gradient(135deg, #0a84ff, #5e5ce6);
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    position: relative;
    padding: 4px;
}

.badge {
    position: absolute;
    top: -4px;
    right: -6px;
    background: #ff453a;
    color: white;
    font-size: 11px;
    font-weight: bold;
    height: 18px;
    min-width: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

main {
    /* Padding now moved to app-container if needed, or kept 0 */
}

/* Search Bar */
.search-container {
    margin-bottom: 24px;
}

.search-bar {
    background: var(--surface-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    padding: 10px 16px;
    gap: 12px;
    color: var(--text-secondary);
}

.search-bar input {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    width: 100%;
    outline: none;
}

.search-bar input::placeholder {
    color: var(--text-secondary);
}

/* Sections */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.text-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

.product-card {
    background: var(--surface-color);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, background 0.2s;
    cursor: pointer;
}

.product-card:active {
    transform: scale(0.97);
    background: var(--surface-hover);
}

.product-logo {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    background: var(--surface-hover);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-logo .fallback-icon {
    font-size: 24px;
    color: var(--text-secondary);
}

.product-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.product-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-color);
}

.buy-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    z-index: 100;
}

.nav-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-around;
    padding: 12px 0 24px 0; /* Extra padding for iOS home indicator */
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-item.active, .nav-item:hover {
    color: var(--primary-color);
}

/* Bottom Sheet */
.bottom-sheet {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: none;
    flex-direction: column;
    justify-content: flex-end;
}

.bottom-sheet.active {
    display: flex;
}

.sheet-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s;
}

.bottom-sheet.active .sheet-overlay {
    opacity: 1;
}

.sheet-content {
    background: var(--surface-color);
    border-radius: 24px 24px 0 0;
    padding: 24px;
    position: relative;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1);
    max-height: 90vh;
    overflow-y: auto;
}

.bottom-sheet.active .sheet-content {
    transform: translateY(0);
}

.sheet-handle {
    width: 36px;
    height: 5px;
    background: var(--text-secondary);
    border-radius: 3px;
    margin: 0 auto 20px auto;
    opacity: 0.5;
}

.sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.sheet-header h3 {
    font-size: 20px;
    font-weight: 700;
}

.close-btn {
    background: var(--surface-hover);
    border: none;
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Product Details Sheet */
.detail-body {
    text-align: center;
    padding: 10px 0 20px 0;
}
.detail-logo {
    width: 100px;
    height: 100px;
    border-radius: 24px;
    background: var(--surface-hover);
    margin: 0 auto 20px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 40px;
}
.detail-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.detail-price {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 12px;
}
.detail-desc {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 30px;
    line-height: 1.6;
}

/* Form Styles */
.input-group {
    margin-bottom: 16px;
}

.input-group input, .input-group textarea {
    width: 100%;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus, .input-group textarea:focus {
    border-color: var(--primary-color);
}

.primary-btn {
    width: 100%;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 14px;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

.primary-btn:active {
    opacity: 0.8;
}

/* Lists & Transactions */
.transactions-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.transaction-list { display: flex; flex-direction: column; gap: 12px; }
.transaction-item { background: var(--surface-color); border-radius: 16px; padding: 16px; display: flex; justify-content: space-between; align-items: center; }
.tx-left { display: flex; align-items: center; gap: 16px; }
.tx-icon { width: 44px; height: 44px; border-radius: 22px; display: flex; align-items: center; justify-content: center; }
.tx-icon.deposit { background: rgba(52, 199, 89, 0.15); color: #34c759; }
.tx-icon.purchase { background: rgba(255, 69, 58, 0.15); color: #ff453a; }
.tx-title { font-weight: 600; font-size: 16px; margin-bottom: 4px; }
.tx-date { font-size: 13px; color: var(--text-secondary); }
.tx-amount { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.tx-amount.positive { color: #34c759; }

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
}
.page-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}
.page-btn:not(.disabled):active {
    background: var(--surface-hover);
}
.page-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Center Modal */
.center-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}
.center-modal.active {
    visibility: visible;
    opacity: 1;
}
.center-modal .sheet-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}
.center-modal-content {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 32px 24px;
    width: 90%;
    max-width: 340px;
    position: relative;
    z-index: 1001;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
}
.center-modal.active .center-modal-content {
    transform: scale(1);
}
.captcha-box {
    margin: 24px 0 16px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.captcha-box canvas {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
}

/* Payment UI Styles */
.container-narrow { max-width: 550px; margin: 0 auto; padding: 0; }
.step-container { animation: fadeIn 0.4s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.step-title { margin-bottom: 8px; font-size: 28px; font-weight: 800; letter-spacing: -0.5px; color: var(--text-primary); }
.step-desc { color: var(--text-secondary); margin-bottom: 30px; font-size: 15px; }
.selection-card { background: var(--surface-color); border: 1px solid var(--border-color); border-radius: 16px; padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); margin-bottom: 15px; }
.selection-card:hover { border-color: #0a84ff; transform: translateY(-2px); }
.card-info { display: flex; align-items: center; gap: 16px; }
.card-icon { width: 44px; height: 44px; border-radius: 50%; }
.card-name { font-weight: 600; font-size: 17px; color: var(--text-primary); }
.premium-panel { background: var(--surface-color); border-radius: 20px; padding: 40px 30px; text-align: center; border: 1px solid var(--border-color); }
.amount-wrapper { position: relative; max-width: 280px; margin: 0 auto 25px auto; }
.currency-symbol { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); font-size: 28px; color: var(--text-secondary); font-weight: 500; pointer-events: none; }
.amount-input { width: 100%; padding: 15px 15px 15px 45px; font-size: 36px; border: 2px solid var(--border-color); border-radius: 14px; text-align: center; font-weight: 700; color: white; background: var(--bg-color); transition: all 0.2s; outline: none; box-sizing: border-box; }
.amount-input:focus { border-color: #0a84ff; }
.btn-primary-lg { background: linear-gradient(135deg, #0a84ff 0%, #5e5ce6 100%); color: white; border: none; width: 100%; padding: 16px; font-size: 16px; font-weight: 600; border-radius: 12px; cursor: pointer; transition: all 0.2s; }
.btn-primary-lg:hover { transform: translateY(-1px); opacity: 0.9; }
.btn-primary-lg:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-back { background: none; border: none; cursor: pointer; color: var(--text-secondary); margin-top: 20px; font-size: 14px; font-weight: 500; transition: color 0.2s; display: inline-flex; align-items: center; justify-content: center; width: 100%; }
.btn-back:hover { color: var(--text-primary); }
.payment-screen { background: var(--surface-color); padding: 40px; border-radius: 24px; border: 1px solid var(--border-color); text-align: center; max-width: 480px; margin: 0 auto; }
.timer-box { font-variant-numeric: tabular-nums; background: rgba(255, 69, 58, 0.1); color: #ff453a; padding: 8px 16px; border-radius: 50px; font-weight: 700; font-size: 18px; margin-bottom: 20px; display: inline-block; }
.progress-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 40px; font-size: 13px; color: var(--text-secondary); justify-content: center; }
.progress-step.active { color: var(--text-primary); font-weight: 600; }
#qrcode { display: flex; justify-content: center; margin: 25px auto; padding: 15px; background: white; border-radius: 16px; width: fit-content; }
#qrcode img { border-radius: 8px; display: block; }
.address-box { background: var(--bg-color); padding: 16px; border: 1px solid var(--border-color); border-radius: 12px; font-family: 'Monaco', 'Menlo', monospace; font-size: 13px; color: var(--text-primary); word-break: break-all; margin: 20px 0; position: relative; text-align: left; }
.copy-btn-floating { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: var(--surface-color); border: 1px solid var(--border-color); padding: 6px 12px; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer; color: white; transition: all 0.2s; }
.copy-btn-floating:hover { border-color: #0a84ff; color: #0a84ff; }

/* Modal Override */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 9999; animation: fadeIn 0.2s; }
.modal-overlay.show { display: flex; }
.modal-content { background: var(--surface-color); border-radius: 16px; padding: 32px; max-width: 500px; width: 90%; color: white; animation: slideUp 0.3s; border: 1px solid var(--border-color); }
.modal-header { font-size: 20px; font-weight: 600; margin-bottom: 20px; color: white; }
.modal-body { margin-bottom: 24px; line-height: 1.6; color: var(--text-secondary); }
.modal-buttons { display: flex; gap: 12px; justify-content: flex-end; }
.modal-btn { padding: 10px 24px; border-radius: 24px; font-weight: 600; cursor: pointer; border: none; transition: all 0.2s; font-size: 15px; }
.modal-btn-ok { background: #0a84ff; color: white; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
