/* Ultra Mobile-First Cyber & Glassmorphism Design for Telegram Mini App */
@import url('https://fonts.googleapis.com/css2?family=Kantumruy+Pro:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    --bg-main: #0b0f19;
    --bg-card: rgba(18, 24, 38, 0.85);
    --bg-card-hover: rgba(28, 37, 56, 0.95);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(0, 180, 255, 0.35);
    
    --primary: #0088cc;
    --primary-glow: #24a1de;
    --accent-cyan: #00e5ff;
    --accent-gold: #fbbf24;
    --accent-purple: #8b5cf6;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 26px;
    
    --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 0 15px rgba(0, 136, 204, 0.1);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Telegram WebApp Custom Theme Variables support */
body.telegram-mini-app {
    --bg-main: var(--tg-theme-bg-color, #0b0f19);
    --text-primary: var(--tg-theme-text-color, #f8fafc);
    --text-secondary: var(--tg-theme-hint-color, #94a3b8);
    --primary: var(--tg-theme-button-color, #0088cc);
}

[data-theme="light"] {
    --bg-main: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.92);
    --bg-card-hover: #ffffff;
    --border-color: rgba(0, 0, 0, 0.08);
    --border-glow: rgba(0, 136, 204, 0.3);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --shadow-card: 0 8px 20px -4px rgba(0, 0, 0, 0.06);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Kantumruy Pro', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    touch-action: pan-y;
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.45;
    background-image: 
        radial-gradient(circle at 10% 10%, rgba(0, 136, 204, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 90%, rgba(139, 92, 246, 0.1) 0%, transparent 45%);
    background-attachment: fixed;
    padding-bottom: env(safe-area-inset-bottom, 20px);
}

.container {
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header & Mobile Navbar */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(11, 15, 25, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    padding: 0.65rem 0;
    transition: var(--transition);
}

[data-theme="light"] .navbar {
    background: rgba(255, 255, 255, 0.9);
}

.nav-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    text-decoration: none;
    color: var(--text-primary);
}

.brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #0088cc, #00e5ff);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.15rem;
    box-shadow: 0 4px 12px rgba(0, 136, 204, 0.35);
    flex-shrink: 0;
}

.brand-text h1 {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.3px;
    background: linear-gradient(90deg, #fff, #38bdf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.15;
}

[data-theme="light"] .brand-text h1 {
    background: linear-gradient(90deg, #0f172a, #0284c7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text span {
    font-size: 0.68rem;
    color: var(--text-muted);
    display: block;
    line-height: 1;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.45rem 0.65rem;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    height: 36px;
}

.nav-btn:active {
    transform: scale(0.94);
}

.nav-btn.primary {
    background: linear-gradient(135deg, #0088cc, #0284c7);
    border: none;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 136, 204, 0.3);
}

/* User Pill */
.tg-user-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    background: rgba(36, 161, 222, 0.12);
    border: 1px solid rgba(36, 161, 222, 0.25);
    color: #38bdf8;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Hero Section */
.hero-section {
    padding: 1.25rem 0 0.75rem;
    text-align: center;
}

/* Compact hero strip for Telegram Mini App */
.tg-compact-hero {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0 0.5rem;
    text-align: center;
}

.tg-compact-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 600;
    flex-wrap: wrap;
}

.tg-compact-stats span {
    display: flex;
    align-items: center;
    gap: 0.2rem;
}



.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    background: rgba(0, 229, 255, 0.08);
    border: 1px solid rgba(0, 229, 255, 0.25);
    color: var(--accent-cyan);
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.hero-title {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 0.4rem;
    letter-spacing: -0.3px;
}

.hero-title .gradient-text {
    background: linear-gradient(135deg, #38bdf8 0%, #00e5ff 50%, #818cf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin-bottom: 1.25rem;
}

/* Mobile Live Stats */
.hero-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.stat-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0.65rem 0.4rem;
    border-radius: var(--radius-md);
    text-align: center;
}

.stat-num {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--accent-cyan);
}

.stat-label {
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* Mobile Search & Categories */
.filter-bar {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.65rem;
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    box-shadow: var(--shadow-card);
}

.search-input-wrap {
    position: relative;
    width: 100%;
}

.search-input-wrap input {
    width: 100%;
    padding: 0.65rem 0.85rem 0.65rem 2.4rem;
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.88rem;
    outline: none;
}

[data-theme="light"] .search-input-wrap input {
    background: rgba(0, 0, 0, 0.04);
}

.search-input-wrap input:focus {
    border-color: var(--primary-glow);
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Smooth Category Slider (No Scrollbar) */
.category-tabs {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    overflow-x: auto;
    padding-bottom: 0.2rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

.category-tabs::-webkit-scrollbar {
    display: none;
}

.category-tab {
    padding: 0.45rem 0.85rem;
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.category-tab:active {
    transform: scale(0.95);
}

.category-tab.active {
    background: linear-gradient(135deg, #0088cc, #00c6ff);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 10px rgba(0, 136, 204, 0.35);
}

/* Mobile Product Cards */
.product-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 4rem;
}

.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.15rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: var(--transition);
}

.product-card:active {
    transform: scale(0.99);
}

.card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.65rem;
}

.card-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-gold);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.stock-pill {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
}

.stock-pill.in-stock {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.stock-pill.out-stock {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.product-img-wrap {
    position: relative;
    width: calc(100% + 2.3rem);
    margin: -1.15rem -1.15rem 0.85rem -1.15rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, rgba(0,136,204,0.2), rgba(139,92,246,0.15));
}

.product-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
}

.product-card:active .product-img {
    transform: scale(1.03);
}

.product-img-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    background: linear-gradient(135deg, rgba(0,136,204,0.15) 0%, rgba(139,92,246,0.12) 100%);
}

.img-overlay-badges {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    right: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.3rem;
}



.product-title {
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.35rem;
    color: var(--text-primary);
}

.product-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 0.85rem;
}

.product-features {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
}

.feat-tag {
    font-size: 0.68rem;
    padding: 0.18rem 0.45rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.card-bottom {
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    padding-top: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.price-wrap .price-usd {
    font-size: 1.25rem;
    font-weight: 800;
    color: #38bdf8;
    line-height: 1;
}

.price-wrap .price-khr {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: block;
    margin-top: 0.15rem;
}

.btn-buy {
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #0088cc, #00c6ff);
    color: white;
    border: none;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    box-shadow: 0 4px 12px rgba(0, 136, 204, 0.3);
}

.btn-buy:active {
    transform: scale(0.95);
}

.btn-buy:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

/* Floating Cart */
.floating-cart {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 99;
    background: linear-gradient(135deg, #0088cc, #00e5ff);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 0.75rem 1.25rem;
    font-size: 0.88rem;
    font-weight: 700;
    box-shadow: 0 8px 25px rgba(0, 136, 204, 0.5);
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.floating-cart:active {
    transform: scale(0.95);
}

.cart-count {
    background: #ef4444;
    color: white;
    font-size: 0.72rem;
    padding: 0.12rem 0.5rem;
    border-radius: 20px;
}

/* Mobile Bottom Sheet Modals (Slide-up Drawer) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: flex-end; /* Drawer bottom on mobile */
    justify-content: center;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #111827;
    border: 1px solid var(--border-color);
    border-radius: 24px 24px 0 0;
    width: 100%;
    max-width: 580px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 1.5rem 1.25rem 2rem;
    position: relative;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}

[data-theme="light"] .modal-content {
    background: #ffffff;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

/* Drawer Pill Handle on top of modal */
.modal-content::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    margin: -0.5rem auto 1rem;
}

[data-theme="light"] .modal-content::before {
    background: rgba(0, 0, 0, 0.15);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.payment-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
    margin: 1rem 0;
}

.payment-tab {
    padding: 0.65rem 0.4rem;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    text-align: center;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
}

.payment-tab.active {
    border-color: #0088cc;
    background: rgba(0, 136, 204, 0.15);
    color: #38bdf8;
}

.khqr-box {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1rem;
    color: #0f172a;
    text-align: center;
    margin: 1rem 0;
}

.khqr-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px dashed #e2e8f0;
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
}

.khqr-tag {
    font-size: 0.85rem;
    font-weight: 800;
    color: #dc2626;
}

.khqr-code-img {
    width: 190px;
    height: 190px;
    margin: 0 auto 0.65rem;
    background: #f8fafc;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e2e8f0;
}

.khqr-amount-khr {
    font-size: 1.3rem;
    font-weight: 800;
    color: #0f172a;
}

.khqr-amount-usd {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 600;
}

.credential-card {
    background: #090d16;
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin: 0.75rem 0;
    font-family: monospace;
    font-size: 0.82rem;
    color: #38bdf8;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Toast */
.toast-container {
    position: fixed;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    pointer-events: none;
}

.toast {
    background: #1e293b;
    border: 1px solid var(--border-color);
    color: white;
    padding: 0.65rem 1rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    pointer-events: auto;
    animation: slideDown 0.25s ease;
}

.toast.success { border-color: var(--accent-green); }
.toast.error { border-color: var(--accent-red); }

@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.form-group {
    margin-bottom: 0.85rem;
    text-align: left;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
}

[data-theme="light"] .form-control {
    background: rgba(0, 0, 0, 0.04);
}

.form-control:focus {
    border-color: var(--primary-glow);
}

footer {
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ============================================================
   TELEGRAM MINI APP COMPACT MODE
   Applied when body has class "telegram-mini-app"
   Makes the UI ultra-compact so products show immediately
   ============================================================ */

body.telegram-mini-app {
    padding-top: 0;
}

/* Shrink the navbar significantly in Mini App */
body.telegram-mini-app .navbar {
    padding: 0.35rem 0;
}

body.telegram-mini-app .brand-icon {
    width: 28px;
    height: 28px;
    font-size: 0.95rem;
}

body.telegram-mini-app .brand-text h1 {
    font-size: 0.88rem;
}

body.telegram-mini-app .brand-text span {
    display: none; /* hide tagline in mini app */
}

body.telegram-mini-app .nav-btn {
    height: 30px;
    padding: 0.3rem 0.5rem;
    font-size: 0.72rem;
}

/* Collapse hero into a tiny strip in Mini App */
body.telegram-mini-app .hero-section {
    padding: 0.5rem 0 0.35rem;
}

body.telegram-mini-app .hero-badge {
    padding: 0.2rem 0.55rem;
    font-size: 0.68rem;
    margin-bottom: 0.3rem;
}

body.telegram-mini-app .hero-title {
    font-size: 1rem;
    margin-bottom: 0.15rem;
}

body.telegram-mini-app .hero-subtitle {
    font-size: 0.72rem;
    margin-bottom: 0.4rem;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Collapse stats into a small inline row in Mini App */
body.telegram-mini-app .hero-stats {
    gap: 0.3rem;
    margin-bottom: 0.5rem;
}

body.telegram-mini-app .stat-box {
    padding: 0.35rem 0.25rem;
    border-radius: 8px;
}

body.telegram-mini-app .stat-num {
    font-size: 0.9rem;
}

body.telegram-mini-app .stat-label {
    font-size: 0.6rem;
}

/* Compact filter/search bar */
body.telegram-mini-app .filter-bar {
    padding: 0.45rem;
    margin-bottom: 0.6rem;
    border-radius: var(--radius-md);
}

body.telegram-mini-app .search-input-wrap input {
    padding: 0.45rem 0.6rem 0.45rem 2rem;
    font-size: 0.8rem;
}

body.telegram-mini-app .category-tabs {
    gap: 0.3rem;
    margin-top: 0.4rem;
}

body.telegram-mini-app .category-tab {
    padding: 0.3rem 0.65rem;
    font-size: 0.72rem;
    border-radius: 20px;
}

/* Tighter product grid */
body.telegram-mini-app .product-grid {
    gap: 0.65rem;
}

body.telegram-mini-app .product-card {
    padding: 0.75rem;
}

body.telegram-mini-app .product-icon-wrap {
    font-size: 1.75rem;
    margin: 0.35rem 0;
}

body.telegram-mini-app .product-title {
    font-size: 0.85rem;
}

body.telegram-mini-app .product-desc {
    font-size: 0.72rem;
    -webkit-line-clamp: 2;
}

body.telegram-mini-app .product-price-usd {
    font-size: 1.05rem;
}

body.telegram-mini-app .btn-buy {
    padding: 0.55rem;
    font-size: 0.8rem;
}

