/* SUPER APP CSS - V2 (Glassmorphism + Dynamic) */
:root {
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    --card-bg: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --font-fam: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
    background: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-fam);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    overflow-y: auto;
}

/* Glassmorphism Classes */
.glassmorphism {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    margin-bottom: 16px;
}
.pd-lg { padding: 20px; }
.mt-md { margin-top: 16px; }
.mt-sm { margin-top: 8px; }
.text-center { text-align: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.025em; }

/* Header */
.app-header {
    position: sticky; top: 0; z-index: 40;
    padding: 16px 20px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
}
.app-header .user-chip {
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}
.user-chip { display: flex; align-items: center; gap: 12px; }
.avatar-placeholder {
    width: 40px; height: 40px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; color: white;
}
.user-details-mini { display: flex; flex-direction: column; }
.user-name { font-weight: 600; font-size: 15px; }
.user-balance { color: var(--success); font-weight: 700; font-size: 14px; }

/* Main Container */
.content-container {
    padding: 20px; padding-bottom: 90px;
    max-width: 600px;
    margin: 0 auto;
}

/* Views */
.view { display: none; opacity: 0; transition: opacity 0.3s ease; }
.view.active { display: block; opacity: 1; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Hero Card (Home) */
.hero-card {
    border-radius: 20px; padding: 24px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(139, 92, 246, 0.2));
    border: 1px solid rgba(255,255,255,0.15);
    margin-bottom: 24px; text-align: center;
}
.hero-card h1 { font-size: 28px; margin-bottom: 8px; }
.hero-card p { color: var(--text-secondary); font-size: 15px; }

/* Quick Actions */
.quick-actions {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px;
}
.action-btn {
    background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: 16px; padding: 16px 8px;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    color: var(--text-primary); cursor: pointer; transition: all 0.2s; font-size: 12px; font-weight: 600;
}
.action-btn i { font-size: 24px; color: var(--accent-primary); }
.action-btn:active { background: rgba(255,255,255,0.1); transform: scale(0.95); }

/* Buttons */
.btn {
    border: none; border-radius: 12px; padding: 12px 20px; font-weight: 600; font-size: 15px;
    cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-family: inherit;
}
.btn-primary { background: var(--accent-primary); color: white; }
.btn-primary:active { background: var(--accent-hover); transform: scale(0.98); }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-primary); }
.btn-block { width: 100%; }
.btn-lg { padding: 16px; font-size: 16px; }
.btn-sm { padding: 8px 12px; font-size: 13px; }

/* Inputs */
.input-group { margin-bottom: 16px; text-align: left; }
.input-group label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.input-group input {
    width: 100%; background: rgba(0,0,0,0.2); border: 1px solid var(--border-color);
    color: white; padding: 14px; border-radius: 12px; font-size: 15px; transition: border 0.2s;
    font-family: inherit;
}
.input-group input:focus { outline: none; border-color: var(--accent-primary); }

/* Deposit Form */
.network-selector { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.net-item {
    background: rgba(0,0,0,0.2); border: 1px solid var(--border-color);
    border-radius: 12px; padding: 14px; text-align: center; cursor: pointer;
    font-weight: 600; transition: all 0.2s; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.net-item.active { background: rgba(59, 130, 246, 0.2); border-color: var(--accent-primary); color: var(--accent-primary); }

/* Shop Grid */
.categories-wrapper { overflow-x: auto; padding-bottom: 12px; margin-bottom: 12px; scrollbar-width: none; }
.categories-wrapper::-webkit-scrollbar { display: none; }
.categories-scroll { display: flex; gap: 10px; width: max-content; }
.cat-badge {
    padding: 8px 16px; background: rgba(255,255,255,0.05); border: 1px solid var(--border-color);
    border-radius: 20px; font-size: 14px; cursor: pointer; transition: 0.2s; white-space: nowrap;
}
.cat-badge.active { background: var(--accent-primary); color: white; border-color: var(--accent-primary); }

.products-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.product-card {
    background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: 16px; padding: 16px; display: flex; flex-direction: column;
    justify-content: space-between; transition: 0.2s; cursor: pointer; gap: 10px;
}
.product-card:active { transform: scale(0.98); }
.product-img { width: 100%; height: 120px; border-radius: 12px; object-fit: cover; background: rgba(0,0,0,0.2); }
.product-img.placeholder { display: flex; align-items: center; justify-content: center; font-size: 32px; color: var(--text-secondary); border: 1px dashed var(--border-color); }
.p-name { font-weight: 600; font-size: 14px; margin-bottom: 8px; line-height: 1.3; }
.p-price { color: var(--success); font-weight: 700; font-size: 16px; }
.p-stock { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.p-out { opacity: 0.5; pointer-events: none; }

/* Modals */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6); z-index: 100;
    display: flex; align-items: flex-end; justify-content: center;
    backdrop-filter: blur(5px); transition: opacity 0.3s;
}
.modal-overlay.hidden { opacity: 0; pointer-events: none; }
.modal-box {
    width: 100%; max-width: 600px; background: #0f172a; border-top-left-radius: 24px; border-top-right-radius: 24px;
    padding: 24px; transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-height: 90vh; overflow-y: auto;
}
.modal-overlay:not(.hidden) .modal-box { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.close-btn { font-size: 24px; cursor: pointer; color: var(--text-secondary); }
#m-prod-banner { width: 100%; height: 160px; object-fit: cover; border-radius: 12px; margin-bottom: 16px; background: rgba(0,0,0,0.2); }
.prod-desc-scroll { max-height: 150px; overflow-y: auto; color: var(--text-secondary); font-size: 14px; line-height: 1.5; padding-right: 10px; }

/* Quantity Controls */
.buy-controls { display: flex; justify-content: space-between; align-items: center; background: rgba(0,0,0,0.2); padding: 12px 16px; border-radius: 12px; }
.price-tag { font-size: 18px; font-weight: 700; color: var(--success); }
.qty-selector { display: flex; align-items: center; gap: 16px; }
.qty-selector button { background: transparent; border: none; color: white; font-size: 20px; cursor: pointer; }
.qty-selector span { font-size: 18px; font-weight: 600; min-width: 20px; text-align: center; }

/* Pending Deposit Box */
.warning-state { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.3); padding: 20px; border-radius: 16px; }
.warning-state h3 { color: var(--warning); margin-bottom: 12px; display: flex; align-items: center; gap: 8px;}
.dep-details { margin: 16px 0; background: rgba(0,0,0,0.2); border-radius: 12px; padding: 12px; }
.dep-row { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 14px; }
.dep-row:last-child { margin-bottom: 0; }
.dep-row span { color: var(--text-secondary); }
.wallet-copy { background: rgba(255,255,255,0.05); padding: 12px; border-radius: 8px; text-align: center; word-break: break-all; font-family: monospace; font-size: 13px; margin-bottom: 16px; border: 1px dashed var(--border-color); cursor:pointer; }
.dep-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Warning Widget */
.warning-widget { background: rgba(245, 158, 11, 0.1) !important; border-color: rgba(245, 158, 11, 0.4) !important; }
.widget-header { display: flex; align-items: center; gap: 8px; color: var(--warning); font-weight: 700; margin-bottom: 8px; }

/* Earn & Profile */
.invite-link-box { background: rgba(0,0,0,0.3); padding: 16px; border-radius: 12px; display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--accent-primary); cursor: pointer; }
.invite-link-box span { font-family: monospace; color: var(--accent-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 90%; }
.icon-lg { font-size: 48px; color: var(--accent-primary); margin-bottom: 12px; }

.profile-stats { margin-bottom: 24px; }
.stat-card { background: var(--card-bg); padding: 16px; border-radius: 16px; border: 1px solid var(--border-color); display: flex; flex-direction: column; align-items: flex-start; }
.stat-card i { font-size: 24px; color: var(--accent-primary); margin-bottom: 8px; }
.stat-lbl { font-size: 13px; color: var(--text-secondary); }
.stat-val { font-size: 20px; color: white; margin-top: 4px; }

.history-list { display: flex; flex-direction: column; gap: 12px; }
.history-item { background: rgba(0,0,0,0.2); padding: 12px; border-radius: 12px; border-left: 4px solid var(--text-secondary); }
.history-item.SUCCESS { border-left-color: var(--success); }
.history-item.FAILED { border-left-color: var(--danger); }
.h-head { display: flex; justify-content: space-between; margin-bottom: 6px; }
.h-stat { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 4px; background: rgba(255,255,255,0.1); }
.h-stat.SUCCESS { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.h-stat.FAILED { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.h-stat.purchase { background: rgba(59, 130, 246, 0.2); color: var(--accent-primary); display: flex; align-items: center; gap: 4px; }
.history-item.purchase { border-left-color: var(--accent-primary); }
.h-date { font-size: 12px; color: var(--text-secondary); }
.h-body { font-size: 13px; line-height: 1.4; }

/* Modal Stock Badge */
.modal-stock-badge {
    display: inline-block; padding: 6px 12px; border-radius: 8px;
    background: rgba(16, 185, 129, 0.15); color: var(--success);
    font-size: 13px; font-weight: 600; margin-top: 8px;
}

/* Bottom Nav */
.bottom-nav {
    position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 600px;
    background: rgba(15, 23, 42, 0.85); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color); display: flex; justify-content: space-around;
    align-items: center; padding: 12px 10px 24px 10px; z-index: 50;
    border-top-left-radius: 16px; border-top-right-radius: 16px;
}
.nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text-secondary); cursor: pointer; transition: 0.2s; font-size: 11px; font-weight: 500;
}
.nav-item i { font-size: 24px; }
.nav-item.active { color: var(--accent-primary); }
.nav-item-center {
    position: relative; top: -15px; pointer-events: auto;
}
.center-btn {
    width: 56px; height: 56px; background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
    border-radius: 50%; display: flex; justify-content: center; align-items: center;
    color: white; font-size: 28px; box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4); border: 4px solid var(--bg-color);
}

/* Utils */
.hidden { display: none !important; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.badge { display: inline-block; padding: 4px 8px; border-radius: 6px; background: rgba(255,255,255,0.1); font-size: 12px; font-weight: 600; }

/* Loading & Toast */
.overlay { position: fixed; inset: 0; background: var(--bg-color); z-index: 9999; display: flex; justify-content: center; align-items: center; transition: 0.3s; }
.overlay.active { opacity: 1; pointer-events: auto; }
.overlay:not(.active) { opacity: 0; pointer-events: none; }
.spinner { width: 40px; height: 40px; border: 4px solid rgba(255,255,255,0.1); border-top-color: var(--accent-primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#toast-container { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; width: 90%; max-width: 400px; pointer-events: none; }
.toast { background: var(--card-bg); backdrop-filter: blur(8px); border: 1px solid var(--border-color); color: white; padding: 12px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); display: flex; align-items: center; gap: 10px; opacity: 0; transform: translateY(-20px); animation: toastIn 0.3s forwards; }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.fade-out { animation: toastOut 0.3s forwards; }
@keyframes toastIn { to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-20px); } }

/* Media Queries for Sizing and Placement Compatibility */
@media (max-width: 380px) {
    .content-container { padding: 12px; }
    .hero-card { padding: 16px; margin-bottom: 16px; }
    .hero-card h1 { font-size: 22px; }
    .quick-actions { gap: 8px; margin-bottom: 16px; }
    .action-btn { padding: 12px 4px; font-size: 11px; border-radius: 12px; }
    .action-btn i { font-size: 20px; }
    .grid-3 { gap: 6px; }
    .stat-card { padding: 12px 8px; border-radius: 12px; }
    .stat-lbl { font-size: 11px; }
    .stat-val { font-size: 15px; }
    .products-grid { gap: 8px; }
    .product-card { padding: 12px; border-radius: 12px; }
    .p-name { font-size: 13px; }
    .p-price { font-size: 14px; }
    .bottom-nav { padding: 8px 6px 16px 6px; }
    .nav-item { font-size: 10px; }
    .nav-item i { font-size: 20px; }
    .center-btn { width: 48px; height: 48px; font-size: 24px; }
    .nav-item-center { top: -12px; }
}

@media (max-width: 330px) {
    .products-grid { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
}
