/* --- SECURITY & RESET --- */
body { overflow-x: hidden; user-select: none; -webkit-user-select: none; }

/* --- MARKET HEADER --- */
.market-header { text-align: center; padding: 100px 20px 40px; background: linear-gradient(to bottom, #f8f9fa, #fff); border-bottom: 1px solid #eee; }
.market-header h1 { font-size: 2.5rem; color: #2d3436; margin-bottom: 10px; }
.market-header p { color: #636e72; margin-bottom: 30px; }
.filter-scroll { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.filter-pill { background: white; border: 1px solid #eee; color: #636e72; padding: 10px 20px; border-radius: 30px; font-weight: 600; cursor: pointer; transition: 0.3s; display: flex; align-items: center; gap: 8px; }
.filter-pill:hover, .filter-pill.active { background: #0070ba; color: white; border-color: #0070ba; box-shadow: 0 5px 15px rgba(0, 112, 186, 0.2); }

/* --- GRID LAYOUT --- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 30px; padding: 50px 0 100px; }

/* --- PRODUCT CARD DESIGN --- */
.store-card { background: white; border: 1px solid #eee; border-radius: 12px; overflow: hidden; transition: 0.3s; display: flex; flex-direction: column; }
.store-card:hover { transform: translateY(-5px); box-shadow: 0 15px 30px rgba(0,0,0,0.08); border-color: #0070ba; }

/* Visual Top Half */
.card-visual { height: 180px; position: relative; display: flex; overflow: hidden; background: white; border-bottom: 1px solid #eee; }
.visual-left { flex: 1.5; padding: 25px; display: flex; flex-direction: column; justify-content: center; z-index: 2; }
.visual-left h3 { font-size: 1.4rem; font-weight: 800; line-height: 1; margin-bottom: 5px; color: #222; text-transform: uppercase; }
.visual-left h4 { font-size: 1.2rem; font-weight: 800; color: #222; text-transform: uppercase; margin-bottom: 0; opacity: 0.8; }
.visual-right { flex: 1; background: var(--coin-color); clip-path: polygon(30% 0, 100% 0, 100% 100%, 0% 100%); display: flex; align-items: flex-end; justify-content: flex-end; padding: 20px; }
.icon-circle { width: 50px; height: 50px; background: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: 0 5px 15px rgba(0,0,0,0.2); }
.icon-circle img { width: 30px; height: 30px; object-fit: contain; }

/* Controls Bottom Half */
.card-body { padding: 20px; }
.price-select { width: 100%; padding: 10px; border-radius: 6px; border: 1px solid #ddd; margin-bottom: 15px; font-size: 1rem; cursor: pointer; }
.btn-group { display: flex; gap: 10px; }
.btn-cart { flex: 1; background: #ff9900; color: white; border: none; padding: 10px; border-radius: 6px; font-weight: 700; cursor: pointer; transition: 0.2s; }
.btn-cart:hover { background: #e68a00; }
.btn-buy { flex: 1; background: #0070ba; color: white; border: none; padding: 10px; border-radius: 6px; font-weight: 700; cursor: pointer; transition: 0.2s; }
.btn-buy:hover { background: #005a9c; }

/* --- CART DRAWER --- */
.cart-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 2000; display: none; backdrop-filter: blur(5px); }
.cart-overlay.open { display: block; }

.cart-drawer { position: fixed; top: 0; right: -400px; width: 380px; height: 100%; background: white; z-index: 2001; transition: right 0.3s; display: flex; flex-direction: column; box-shadow: -5px 0 20px rgba(0,0,0,0.1); }
.cart-drawer.open { right: 0; }
.cart-header { padding: 20px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; background: #f8f9fa; }
.cart-header h3 { margin: 0; }
.icon-btn { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #555; padding: 8px; border-radius: 50%; transition: 0.2s; display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: #eee; color: #000; }

.cart-content-wrapper { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.cart-items { flex: 1; overflow-y: auto; padding: 20px; }

/* 3D CART ITEM (Rectangular) */
.cart-item-row { display: flex; align-items: center; padding-bottom: 15px; border-bottom: 1px solid #eee; margin-bottom: 15px; }
.cart-item-visual { 
    width: 60px; height: 38px; /* Rectangular aspect ratio */
    border-radius: 6px; /* Not circular */
    display: flex; align-items: center; justify-content: center; 
    box-shadow: 2px 2px 5px rgba(0,0,0,0.15); margin-right: 15px; 
    position: relative; overflow: hidden; flex-shrink: 0; 
    border: 1px solid rgba(255,255,255,0.3);
}
.cart-item-visual::after { 
    content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; 
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.25), transparent); 
    transform: rotate(45deg); pointer-events: none; 
}
.cart-item-visual img { width: 22px; height: 22px; object-fit: contain; z-index: 2; }

.cart-item-info { flex: 1; }
.cart-item-info h5 { margin: 0; font-size: 0.95rem; font-weight: 700; color: #333; }
.cart-item-info span { font-size: 0.8rem; color: #00c851; font-weight: bold; }

/* PROMO SECTION */
.promo-container { padding: 20px; background: #f8f9fa; border-top: 1px solid #eee; }
.promo-container label { display: block; font-size: 0.85rem; color: #666; margin-bottom: 8px; font-weight: 600; }
.promo-input-group { display: flex; gap: 10px; }
.promo-input { flex: 1; padding: 12px; border: 1px solid #ccc; border-radius: 8px; font-size: 0.95rem; }
.promo-input:focus { border-color: #0070ba; outline: none; }
.btn-apply { background: #0070ba; color: white; border: none; padding: 0 20px; border-radius: 8px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.promo-msg { font-size: 0.85rem; margin-top: 8px; min-height: 1.2em; font-weight: 500; }

.cart-footer { padding: 20px; background: #f9f9f9; border-top: 1px solid #eee; }
.cart-total { display: flex; justify-content: space-between; font-weight: bold; font-size: 1.1rem; margin-bottom: 15px; }
.btn-checkout { width: 100%; background: #ffd814; border: 1px solid #fcd200; padding: 15px; border-radius: 8px; font-weight: 700; cursor: pointer; font-size: 1rem; }

/* --- CHECKOUT VIEW --- */
.checkout-container { display: grid; grid-template-columns: 1fr 350px; gap: 30px; padding: 120px 20px 60px; }
.checkout-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; border-bottom: 1px solid #eee; padding-bottom: 10px; }
.btn-keep-shopping { background: white; border: 1px solid #ddd; padding: 8px 16px; border-radius: 20px; cursor: pointer; font-weight: 600; color: #555; display: flex; align-items: center; gap: 8px; transition: 0.2s; }
.btn-keep-shopping:hover { background: #f0f0f0; color: #333; border-color: #aaa; }

.checkout-step { margin-bottom: 30px; border: 1px solid #ddd; border-radius: 8px; padding: 20px; background: white; }
.step-title { display: flex; align-items: center; gap: 15px; margin-bottom: 15px; }
.step-num { width: 30px; height: 30px; background: #333; color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; flex-shrink: 0; }
.step-title h3 { margin: 0; font-size: 1.1rem; color: #333; }

.input-modern { display: flex; align-items: center; border: 1px solid #ccc; border-radius: 6px; padding: 0 15px; background: #fff; }
.input-modern.error { border-color: #ff4757; background: #fff0f1; }
.input-modern input { border: none; padding: 12px 0; width: 100%; outline: none; font-size: 1rem; }
.error-text { color: #ff4757; font-size: 0.85rem; margin-top: 5px; font-weight: 600; }

.payment-grid-complex { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; }
.pay-card { border: 2px solid #eee; border-radius: 8px; padding: 15px; display: flex; align-items: center; gap: 10px; cursor: pointer; transition: 0.2s; }
.pay-card:hover { background: #f9f9f9; }
.pay-card:has(input:checked) { border-color: #e77600; background: #fff8f0; }
.pay-card img { width: 30px; height: 30px; object-fit: contain; }
.pay-info { display: flex; flex-direction: column; }
.pay-info strong { font-size: 0.9rem; color: #333; }
.pay-info span { font-size: 0.75rem; color: #666; }

.review-cards-list { display: grid; gap: 15px; }
.physical-card-row { display: flex; justify-content: space-between; align-items: center; background: #f8f9fa; border: 1px solid #eee; border-radius: 8px; padding: 15px; }
.plastic-card { width: 80px; height: 50px; background: linear-gradient(135deg, #333, #000); border-radius: 6px; color: white; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 0.7rem; position: relative; overflow: hidden; box-shadow: 2px 2px 5px rgba(0,0,0,0.2); flex-shrink: 0; }
.plastic-card::before { content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background: linear-gradient(45deg, transparent, rgba(255,255,255,0.1), transparent); transform: rotate(45deg); }
.plastic-card img { width: 20px; margin-right: 5px; }
.item-meta { margin-left: 15px; flex: 1; }
.item-price { font-weight: bold; font-size: 1.1rem; white-space: nowrap; }

.order-summary-box { background: #f3f3f3; padding: 20px; border-radius: 8px; border: 1px solid #ddd; position: sticky; top: 100px; }
.btn-place-order { width: 100%; background: #ffd814; border: 1px solid #fcd200; border-radius: 8px; padding: 12px; font-weight: 700; cursor: pointer; margin-bottom: 10px; font-size: 1rem; }
.summary-row { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 0.9rem; }
.summary-row.total { font-size: 1.2rem; font-weight: 700; color: #b12704; margin-top: 15px; border-top: 1px solid #ddd; padding-top: 15px; }

/* --- MODALS & OVERLAYS (CENTERED) --- */
.modal-overlay, .payment-portal-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.7); z-index: 5000; 
    display: none; /* JS toggles to flex */
    align-items: center; justify-content: center; 
    backdrop-filter: blur(5px); 
}
.modal-overlay.open, .payment-portal-overlay.open { display: flex; }

/* Generic Modal */
.modal-box { background: white; border-radius: 12px; padding: 30px; width: 90%; max-width: 420px; box-shadow: 0 20px 50px rgba(0,0,0,0.3); animation: slideUp 0.3s; position: relative; }
.small-modal { max-width: 400px; }
.text-center { text-align: center; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { margin: 0; font-size: 1.2rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 25px; }

/* Email Confirmation Style */
.email-display-box { background: #f0f8ff; border: 1px solid #b3d7ff; padding: 15px; border-radius: 8px; margin: 15px 0; color: #0056b3; font-weight: bold; font-size: 1.1rem; word-break: break-all; }
.warning-text { font-size: 0.85rem; color: #856404; background: #fff3cd; padding: 10px; border-radius: 6px; border: 1px solid #ffeeba; display: flex; align-items: center; gap: 8px; justify-content: center; }

/* PAYMENT PORTAL */
.payment-portal-box { width: 95%; max-width: 900px; height: 600px; max-height: 90vh; background: white; border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,0.5); position: relative; }
.portal-header { background: #f8f9fa; padding: 15px 20px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; }
.header-left { display: flex; gap: 15px; align-items: center; }
.portal-logo { height: 25px; }
.timer-badge { background: #fff0f0; color: #d63031; padding: 5px 12px; border-radius: 20px; font-weight: bold; border: 1px solid #ffcccc; display: flex; gap: 8px; align-items: center; font-size: 0.9rem; }

.portal-body { flex: 1; display: flex; overflow-y: auto; }
.portal-left { width: 40%; background: #f4f6f8; display: flex; flex-direction: column; align-items: center; justify-content: center; border-right: 1px solid #eee; padding: 20px; }
.portal-right { width: 60%; padding: 30px; display: flex; flex-direction: column; justify-content: center; }

.network-selector { margin-bottom: 20px; text-align: center; }
.network-selector label { font-weight: bold; font-size: 0.9rem; display: block; margin-bottom: 8px; }
.network-toggle { display: inline-flex; background: #eee; border-radius: 8px; padding: 4px; }
.net-btn { border: none; background: transparent; padding: 8px 20px; border-radius: 6px; cursor: pointer; font-weight: 600; color: #666; transition: 0.2s; }
.net-btn.active { background: white; color: #0070ba; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }

.qr-wrapper { position: relative; background: white; padding: 15px; border-radius: 12px; box-shadow: 0 5px 20px rgba(0,0,0,0.05); }
.qr-logo-overlay { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 40px; background: white; padding: 3px; border-radius: 50%; }
.scan-text { margin-top: 15px; color: #555; font-size: 0.9rem; font-weight: 500; }

.pay-details-group { margin-bottom: 20px; }
.pay-details-group label { display: block; font-size: 0.85rem; color: #666; margin-bottom: 8px; font-weight: 600; text-transform: uppercase; }
.copy-box { background: #f9f9f9; border: 1px solid #ddd; padding: 12px; border-radius: 6px; display: flex; justify-content: space-between; align-items: center; font-family: monospace; font-size: 1rem; word-break: break-all; }
.copy-box button { border:none; background: transparent; color: #0070ba; cursor: pointer; margin-left: 10px; font-size: 1.1rem; }
.network-warning { margin-top: 8px; font-size: 0.8rem; color: #d63031; background: #fff0f0; padding: 8px; border-radius: 4px; display: inline-block; font-weight: 600; }

.payment-status { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; }
.status-step { display: flex; flex-direction: column; align-items: center; gap: 5px; color: #ccc; }
.status-step.active { color: #0070ba; }
.status-step .dot { width: 12px; height: 12px; background: currentColor; border-radius: 50%; }
.status-step span { font-size: 0.75rem; font-weight: 600; }
.payment-status .line { height: 2px; flex: 1; background: #eee; margin: 0 10px; margin-bottom: 15px; }

.portal-footer { padding: 15px 30px; border-top: 1px solid #eee; display: flex; justify-content: flex-end; gap: 15px; background: #fff; }
.btn-cancel { background: transparent; border: none; color: #666; cursor: pointer; font-weight: 600; }
.btn-paid { background: #00c851; color: white; border: none; padding: 10px 25px; border-radius: 6px; font-weight: 600; cursor: pointer; }

/* Payment Overlays */
.status-overlay { position: absolute; top: 50px; left: 0; width: 100%; height: calc(100% - 50px); background: white; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.spinner { width: 50px; height: 50px; border: 5px solid #f3f3f3; border-top: 5px solid #0070ba; border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 20px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.error-icon { font-size: 4rem; color: #ff4757; margin-bottom: 20px; }
.error-actions { margin-top: 20px; display: flex; gap: 15px; }
.btn-retry { background: #0070ba; color: white; border: none; padding: 10px 20px; border-radius: 6px; cursor: pointer; }
.btn-support { background: #5865F2; color: white; text-decoration: none; padding: 10px 20px; border-radius: 6px; display: flex; align-items: center; gap: 8px; }

@keyframes slideUp { from { transform: translateY(50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* --- RESPONSIVE --- */
@media (max-width: 850px) {
    .checkout-container { grid-template-columns: 1fr; padding: 80px 15px 40px; gap: 20px; }
    .checkout-sidebar { grid-row: 1; margin-bottom: 10px; }
    .payment-grid-complex { grid-template-columns: 1fr; }
    .payment-portal-box { width: 100%; height: 100%; border-radius: 0; }
    .portal-body { flex-direction: column; }
    .portal-left, .portal-right { width: 100%; border-right: none; border-bottom: 1px solid #eee; padding: 20px; }
    .cart-drawer { width: 100%; right: -100%; }
    .physical-card-row { flex-direction: column; align-items: flex-start; gap: 10px; }
    .plastic-card { align-self: flex-start; }
    .item-meta { margin-left: 0; }
    .item-price { margin-left: auto; }
}