/* =========================================
   ALL_DAMAS - CLEAN CSS (NO DUPLICATES)
   ========================================= */

/* =========================================
   TELEGRAM SCROLL FIX - #APP TRICK
   ========================================= */

/* Body - Telegram uchun (overflow hidden) */
body {
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    height: 100vh !important;
    position: relative !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* #app - HAQIQIY SCROLL! */
#app {
    position: absolute !important;
    top: 134px !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 80px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100%;
    max-width: 100vw;
}

* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

:root {
    --primary-color: #1DB954;
    --primary-light: #e8f5e9;
    --secondary-color: #191414;
    --text-color: #333;
    --text-secondary: #666;
    --text-light: #999;
    --bg-color: #f5f5f5;
    --white: #ffffff;
    --border-color: #e0e0e0;
    --red: #f44336;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
    --radius: 12px;
    --bottom-nav-height: 60px;
}

/* =========================================
   LOADING SCREEN
   ========================================= */

.loading-screen { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100vh; 
    background: var(--primary-color); 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    z-index: 9999; 
    color: var(--white); 
}

.loader { 
    border: 4px solid rgba(255, 255, 255, 0.3); 
    border-top: 4px solid var(--white); 
    border-radius: 50%; 
    width: 50px; 
    height: 50px; 
    animation: spin 1s linear infinite; 
    margin-bottom: 20px; 
}

@keyframes spin { 
    0% { transform: rotate(0deg); } 
    100% { transform: rotate(360deg); } 
}

/* =========================================
   HEADER - 2 QATORLI
   ========================================= */

.header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 10002 !important;
    background: #fff !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
    max-width: 600px !important;
    margin: 0 auto !important;
    height: 74px;
    transition: all 0.3s ease;
}

.header-top {
    padding: 10px 4px;
    text-align: center;
    border-bottom: 3px solid #eee;
    height: 38px;
    width: 100%;
}

.app-title {
    font-size: 18px;
    font-weight: 700;
    color: #1DB954;
    margin: 0;
}

.header-bottom {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 4px;
    height: 34px;
    width: 100%;
    background: #fff;
    transition: all 0.3s ease;
}

.currency-btn {
    padding: 8px 12px;
    background: #f5f5f5;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    min-width: 55px;
    transition: all 0.3s ease;
}

.header-search-input {
    flex: 1;
    min-width: 100px;
    padding: 6px 10px;
    font-size: 13px;
    height: 30px;
    border: 1px solid #ddd;
    border-radius: 6px;
    outline: none;
    transition: all 0.3s ease;
    background: #fff;
}

.header-search-input:focus {
    border-color: #1DB954;
    box-shadow: 0 0 0 2px rgba(29, 185, 84, 0.1);
}

.cart-btn {
    position: relative;
    padding: 4px 8px;
    background: #1DB954 !important;
    color: white !important;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
    min-width: 36px;
    font-size: 13px;
    transition: all 0.3s ease;
}

.cart-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: #f44336;
    color: white;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 8px;
    min-width: 14px;
}

/* =========================================
   KATEGORIYALAR - HORIZONTAL SCROLL
   ========================================= */

.category-container {
    position: fixed !important;
    top: 74px !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 10001 !important;
    background: #fff !important;
    border-bottom: 1px solid #eee !important;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 600px !important;
    margin: 0 auto !important;
    height: 48px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.category-chips {
    display: flex;
    gap: 8px;
    padding: 6px 3px;
    overflow: visible;
    white-space: nowrap;
}

.category-chip {
    padding: 4px 12px;
    background: #f5f5f5;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.2s;
}

.category-chip:hover {
    background: #e0e0e0;
}

.category-chip.active {
    background: #1DB954;
    color: white;
}

.category-container::-webkit-scrollbar {
    height: 3px;
}

.category-container::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.category-container::-webkit-scrollbar-thumb {
    background: #1DB954;
    border-radius: 2px;
}

/* =========================================
   MAIN CONTENT
   ========================================= */

.main-content {
    padding-top: 134px !important;
    margin-top: -146px !important;
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: 80px;
    overflow-x: hidden !important;
    overflow-y: visible !important;
}

/* =========================================
   PRODUCT GRID
   ========================================= */

.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 16px;
}

.product-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    min-height: 320px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.product-card.in-cart {
    border-color: var(--primary-color);
}

.product-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.product-image-wrapper {
    position: relative;
    width: 100%;
    height: 180px;
    background: var(--bg-color);
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-dots {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
}

.product-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
}

.product-dot.active {
    background: var(--white);
    width: 20px;
    border-radius: 3px;
}

.product-info {
    padding: 14px;
}

.product-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    min-height: 42px;
    line-height: 1.4;
}

.product-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.product-price {
    font-size: 17px;
    font-weight: 700;
    color: #0088cc;
}

.currency-badge {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-color);
    padding: 2px 8px;
    border-radius: 4px;
}

.product-status {
    font-size: 12px;
    margin-bottom: 8px;
}

.product-status.in-stock {
    color: var(--primary-color);
}

.product-status.out-of-stock {
    color: var(--red);
}

/* =========================================
   PRODUCT ACTIONS
   ========================================= */

.product-actions {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.product-actions::-webkit-scrollbar {
    display: none;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-color);
    border-radius: 8px;
    padding: 4px 6px;
    flex-shrink: 0;
    min-width: 110px;
}

.qty-btn {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-color);
    cursor: pointer;
    padding: 4px 8px;
    font-weight: bold;
    min-width: 32px;
}

.qty-input {
    width: 38px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    border: none;
    background: none;
    outline: none;
    padding: 2px;
    -moz-appearance: textfield;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.qty-input:focus {
    background: var(--white);
    border-radius: 4px;
}

.cart-action-btn {
    flex-shrink: 0;
    padding: 8px 12px;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 45px;
    white-space: nowrap;
}

.cart-action-btn i {
    font-size: 14px;
}

.cart-action-btn.remove {
    background: var(--red);
}

.cart-action-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* =========================================
   PRODUCT MODAL
   ========================================= */

#product-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 999999 !important;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    overflow: hidden !important;
    -webkit-overflow-scrolling: touch;
}

#product-modal.active {
    opacity: 1;
    pointer-events: all;
}

.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.85) !important;
    display: flex !important;
    align-items: flex-end !important;
    justify-content: center !important;
    z-index: 1000000 !important;
    overflow: hidden !important;
    padding: 0 !important;
}

.modal-content {
    background: var(--white);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUpModal 0.3s ease;
    box-shadow: 0 -5px 30px rgba(0,0,0,0.3);
    -webkit-overflow-scrolling: touch;
}

@keyframes slideUpModal {
    0% { transform: translateY(100%); }
    100% { transform: translateY(0); }
}

.modal-close {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    background: rgba(0, 0, 0, 0.7) !important;
    color: var(--white) !important;
    border: none !important;
    font-size: 20px !important;
    cursor: pointer !important;
    z-index: 100 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s !important;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.9) !important;
    transform: scale(1.1) !important;
}

.modal-images-container {
    position: relative;
    width: 100%;
    height: 300px;
    background: var(--bg-color);
    overflow: hidden;
    flex-shrink: 0;
}

.modal-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-image.active {
    opacity: 1;
    z-index: 1;
}

.modal-no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--text-light);
    font-size: 18px;
}

.modal-dots {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 2;
}

.modal-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.3s;
}

.modal-dot.active {
    background: var(--white);
    width: 24px;
    border-radius: 4px;
}

.modal-info {
    padding: 24px;
}

.modal-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-color);
    line-height: 1.4;
}

.modal-description {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

.modal-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-price {
    font-size: 28px;
    font-weight: 700;
    color: #0088cc;
}

.modal-stock {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.modal-stock.in-stock {
    background: var(--primary-light);
    color: var(--primary-color);
}

.modal-stock.out-of-stock {
    background: #ffebee;
    color: var(--red);
}

.modal-cart-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.modal-cart-actions .quantity-controls {
    flex: 1;
    min-width: 140px;
    padding: 6px 10px;
}

.modal-remove-btn {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--red);
    color: var(--white);
    border: none;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.modal-remove-btn:hover {
    background: #d32f2f;
    transform: scale(1.05);
}

.modal-add-btn {
    width: 100%;
    padding: 16px;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
}

.modal-add-btn:hover {
    background: #1aa34a;
    transform: scale(1.02);
}

.modal-add-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.modal-add-btn i {
    font-size: 18px;
}

/* =========================================
   BOTTOM NAVIGATION
   ========================================= */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 600px;
    margin: 0 auto;
    height: var(--bottom-nav-height);
    background: var(--white);
    display: flex;
    justify-content: space-around;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    padding: 8px 4px;
    transition: all 0.3s;
    gap: 4px;
}

.nav-item i {
    font-size: 20px;
}

.nav-item.active {
    color: var(--primary-color);
    font-weight: 600;
}

/* =========================================
   TOAST NOTIFICATIONS
   ========================================= */

.toast-container {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    max-width: 90%;
}

.toast {
    background: var(--secondary-color);
    color: var(--white);
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}

.toast.success { 
    background: var(--primary-color); 
}

.toast.error { 
    background: var(--red); 
}

/* =========================================
   EMPTY STATE
   ========================================= */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

/* =========================================
   LOADING SPINNER
   ========================================= */

.loading {
    text-align: center;
    padding: 40px 20px;
}

.loading-spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

/* =========================================
   PAGINATION
   ========================================= */

.pagination-container {
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--white);
    border-top: 1px solid var(--border-color);
}

.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.page-btn {
    min-width: 40px;
    height: 40px;
    padding: 8px 12px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-btn.active {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.page-btn:not(:disabled):not(.active):hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
}

.page-dots {
    padding: 8px;
    color: var(--text-secondary);
}

.page-jump {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-jump input {
    width: 60px;
    height: 40px;
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    outline: none;
}

.page-jump input:focus {
    border-color: var(--primary-color);
}

.page-jump button {
    height: 40px;
    padding: 0 16px;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.pagination-info {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
}

.items-per-page {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.items-per-page span {
    font-size: 14px;
    color: var(--text-secondary);
}

.items-per-page select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    background: var(--white);
    cursor: pointer;
    outline: none;
}

.items-per-page select:focus {
    border-color: var(--primary-color);
}

/* =========================================
   UTILITY CLASSES
   ========================================= */

.p-16 { 
    padding: 16px; 
}

.currency-toggle {
    padding: 8px 16px;
    background: #f0f0f0;
    color: var(--text-color);
    height: 40px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 60px;
}

.currency-toggle:hover {
    opacity: 0.9;
    background: #e0e0e0;
    transform: scale(1.05);
}

.currency-toggle:active {
    transform: scale(0.95);
}

/* =========================================
   MOBILE RESPONSIVE
   ========================================= */

@media (max-width: 480px) {
    .category-container {
        height: 34px;
    }
    
    .main-content {
        padding-top: 120px;
    }
    
    .header-top {
        padding: 8px 12px;
        height: 40px;
    }
    
    .app-title {
        font-size: 16px;
    }
    
    .header-bottom {
        padding: 6px 10px;
        gap: 6px;
        height: 42px;
    }
    
    .currency-btn {
        padding: 6px 10px;
        font-size: 12px;
        min-width: 50px;
    }
    
    .header-search-input {
        padding: 6px 10px;
        font-size: 13px;
        height: 28px;
    }
    
    .cart-btn {
        padding: 6px 10px;
        min-width: 40px;
        font-size: 14px;
    }
    
    .category-chip {
        padding: 4px 10px;
        font-size: 11px;
    }

    .modal-images-container {
        height: 250px;
    }
}

@media (min-width: 768px) {
    .modal-images-container {
        height: 400px;
    }
}