/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Product Detail Modal */
.product-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: 1rem;
}

.product-modal-content {
    background: #fff;
    width: 100%;
    max-width: 920px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
    animation: modalIn 0.25s ease;
    max-height: 90vh;
}

.product-modal-close {
    position: absolute;
    right: 14px;
    top: 8px;
    border: none;
    background: transparent;
    font-size: 30px;
    color: #666;
    cursor: pointer;
}

.product-modal-body {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 1.2rem;
    padding: 1.2rem;
    overflow: auto;
}

.modal-info {
    display: flex;
    flex-direction: column;
    min-height: 0; /* allow flex child to shrink inside scroll container */
    gap: 0.4rem;
    padding-bottom: 0.6rem; /* space so sticky button doesn't cover last content */
}

.modal-gallery {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.modal-main-image {
    width: 100%;
    height: 360px;
    object-fit: cover;
    border-radius: 8px;
}

.modal-thumbnails {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
}

.modal-thumbnails img {
    width: 100%;
    height: 68px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s ease;
}

.modal-thumbnails img.active,
.modal-thumbnails img:hover {
    border-color: var(--primary-color);
}

.modal-info h3 {
    margin: 0;
    font-size: 1.2rem;
    line-height: 1.25;
    color: var(--text-color);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.modal-rating { color: #ffc107; margin: 0.2rem 0 0.4rem; }

.modal-description { color: var(--light-text); line-height: 1.5; margin-bottom: 0.5rem; }

.modal-price-row { display: flex; align-items: baseline; gap: 0.5rem; margin-bottom: 0.4rem; }
.modal-price { font-size: 1.5rem; font-weight: 800; color: var(--primary-color); }
.modal-original-price { text-decoration: line-through; color: #999; }
.modal-discount { background: #4CAF50; color: #fff; font-weight: 700; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.8rem; }

.modal-sizes { margin: 0.4rem 0 0.6rem; }
.modal-sizes .size-badges { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.modal-sizes .size-badge { cursor: pointer; user-select: none; }

.modal-add-btn {
    width: 100%;
    padding: 0.9rem;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    display: block;
    margin-top: auto; /* push to bottom of column */
    position: sticky;
    bottom: 0;
    z-index: 5;
}

.modal-add-btn:disabled {
    opacity: 0.95;
    cursor: default;
    background-color: #4CAF50;
}

@media (max-width: 768px) {
    .product-modal-content { max-height: 88vh; }
    .product-modal-body { grid-template-columns: 1fr; padding: 0.9rem; }
    .modal-main-image { height: 240px; }
    .modal-thumbnails { grid-template-columns: repeat(4, 1fr); }
    /* Keep Add button visible near bottom as user scrolls */
    .modal-add-btn { bottom: 0; }
}

@media (max-width: 480px) {
    .product-modal-content { max-height: 84vh; border-radius: 10px; }
    .product-modal-body { gap: 0.6rem; padding: 0.7rem; }
    .modal-main-image { height: 180px; }
    .modal-thumbnails { grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
    .modal-thumbnails img { height: 56px; }
    .modal-description { font-size: 0.95rem; margin-bottom: 0.4rem; }
    .modal-price { font-size: 1.3rem; }
    .modal-info h3 { font-size: 1.05rem; }
    .modal-info {gap:0rem;}
}

:root {
    --primary-color: #4a90e2;
    --secondary-color: #f5f5f5;
    --text-color: #333;
    --light-text: #777;
    --white: #ffffff;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

body {
    line-height: 1.6;
    color: var(--text-color);
    background-color: #f9f9f9;
}

/* Header Styles */
header {
    background-color: var(--white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 5%;
    max-width: 1400px;
    margin: 0 auto;
}

.logo {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
}

.logo:hover {
    text-decoration: none;
}

.nav-links a {
    color: var(--text-color);
    text-decoration: none;
    margin: 0 1rem;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary-color);
}

.cart-icon {
    position: relative;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    transition: color 0.3s;
}

/* Orders icon (hidden by default, shown only on small screens) */
.orders-icon {
    display: none;
    position: relative;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-color);
    text-decoration: none;
    display: none;
    align-items: center;
    transition: color 0.3s;
}

.orders-icon:hover {
    color: var(--primary-color);
}

.cart-icon:hover {
    color: var(--primary-color);
}

.cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
}

/* Hero Section */
.hero {
    background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('https://images.unsplash.com/photo-1441986300917-64674bd600d8?ixlib=rb-1.2.1&auto=format&fit=crop&w=1950&q=80');
    background-size: cover;
    background-position: center;
    height: 400px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
    padding: 0 1rem;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.2rem;
    max-width: 700px;
}

/* Products Section */
.products-section {
    padding: 4rem 5%;
    max-width: 1400px;
    margin: 0 auto;
}

.products-section h2 {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 2rem;
    color: var(--text-color);
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.8rem;
    padding: 0 0.5rem;
}

.product-card {
    background: var(--white);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.product-image {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.product-info {
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-title {
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    color: var(--text-color);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 2.2em;
    line-height: 1.1;
}

.price-container {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    margin: 0.3rem 0;
}

.product-price {
    font-weight: bold;
    color: var(--primary-color);
    font-size: 0.95rem;
}

.original-price {
    text-decoration: line-through;
    color: #999;
    font-size: 0.9rem;
    margin-right: 5px;
}

.discount-percent {
    background-color: #4CAF50;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 10px;
    margin-left: 6px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.discount-percent::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: rgba(255,255,255,0.2);
}

.discount-badge {
    position: absolute;
    top: 12px;
    right: -5px;
    background: linear-gradient(135deg, #ff4444, #ff6b6b);
    color: white;
    font-size: 0.75rem;
    font-weight: 800;
    padding: 5px 12px;
    border-radius: 20px 0 0 20px;
    z-index: 1;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    height: 24px;
}

.discount-badge::after {
    content: '';
    position: absolute;
    bottom: -5px;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 5px 5px;
    border-color: transparent transparent #c0392b transparent;
}

.product-sizes {
    margin: 0.4rem 0;
    font-size: 0.75rem;
}

.sizes-label {
    display: block;
    color: #666;
    margin-bottom: 0.3rem;
    font-weight: 500;
}

.size-badges {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.size-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 0.7rem;
    color: #555;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.size-badge:hover {
    border-color: var(--primary-color);
    background-color: #e8f4f8;
}

.size-badge.selected {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    font-weight: 600;
}

.product-rating {
    color: #ffc107;
    font-size: 0.75rem;
    margin: 0.1rem 0 0.5rem;
}

.add-to-cart {
    width: 100%;
    padding: 0.4rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    margin-top: auto;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.add-to-cart:hover:not(:disabled) {
    background-color: var(--primary-dark);
}

.add-to-cart:disabled {
    background-color: #4CAF50;
    cursor: not-allowed;
    opacity: 0.8;
    transform: none;
}

.add-to-cart:disabled:hover {
    background-color: #4CAF50;
}

/* Footer Styles */
footer {
    background-color: #2c3e50;
    color: #ecf0f1;
    padding:0rem 5% 1rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto 2rem;
}

.footer-section h3 {
    color: #ecf0f1;
    margin-bottom: 1.2rem;
    font-size: 1.3rem;
}

.footer-section p, 
.footer-section a {
    color: #bdc3c7;
    margin-bottom: 0.5rem;
    display: block;
    text-decoration: none;
}

.footer-section a:hover {
    color: var(--primary-color);
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-bottom {
    text-align: center;
    padding-top: 1.5rem;
    border-top: 1px solid #34495e;
    max-width: 1400px;
    margin: 0 auto;
}

/* Responsive Design */
@media (max-width: 992px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
    }
    
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.8rem;
        padding: 0 0.5rem;
    }
    
    .hero h1 {
        font-size: 2.2rem;
    }
    
    .hero p {
        font-size: 1rem;
    }
}

/* Price Range Filter */
.price-filter {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    margin: 0.5rem 0 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.category-chips {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 0.3rem 0 0.6rem;
    justify-content: center;
    align-items: center;
}

.chip {
    background: #f1f3f5;
    color: #2c3e50;
    border: 1px solid #e0e0e0;
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
}

.chip:hover { border-color: var(--primary-color); }

.chip-count {
    background: #e9ecef;
    color: #555;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.8rem;
}

.chip.active {
    background: rgba(74,144,226,0.12);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.price-range h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    color: var(--text-color);
}

.price-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.price-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.price-display span:first-child {
    font-weight: 600;
    color: var(--primary-color);
}

#productCount {
    color: var(--light-text);
    font-size: 0.8rem;
}

.slider-container {
    position: relative;
    padding: 0.5rem 0 1.5rem;
}

#priceSlider {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #e0e0e0;
    border-radius: 2px;
    outline: none;
    position: relative;
    z-index: 2;
}

/* Filled portion of the slider */
#priceSlider::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    background: linear-gradient(to right, var(--primary-color) 0%, var(--primary-color) var(--fill-percent, 100%), #e0e0e0 var(--fill-percent, 100%), #e0e0e0 100%);
    border-radius: 2px;
}

#priceSlider::-moz-range-track {
    width: 100%;
    height: 4px;
    background: linear-gradient(to right, var(--primary-color) 0%, var(--primary-color) var(--fill-percent, 100%), #e0e0e0 var(--fill-percent, 100%), #e0e0e0 100%);
    border-radius: 2px;
}

/* Slider Thumb */
#priceSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: white;
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-top: -8px;
}

#priceSlider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: white;
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#priceSlider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb, 0, 119, 204), 0.1);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    color: var(--light-text);
    font-size: 0.75rem;
}

/* Mobile styles */
@media (max-width: 480px) {
    /* Hide nav links and cart on extra small screens */
    .nav-links { display: none; }
    .cart-icon { display: flex; }
    /* allow nav to wrap so injected auth control doesn't overflow */
    nav { flex-wrap: wrap; padding: 0.6rem 0.8rem; }
    .logo { flex: 1 1 auto; }
    #authControl { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; margin-left: 8px; }
    /* Show only orders icon */
    .orders-icon { display: flex; }
    .hero {
        margin-bottom: 0.5rem;
        padding: 1.2rem 0.8rem;
    }
    
    .price-filter {
        padding: 0.6rem 0.8rem;
        margin: 0.3rem 0 0.8rem;
    }
    
    .price-header {
        margin-bottom: 0.6rem;
    }
    
    .price-range h3 {
        font-size: 0.95rem;
        margin-bottom: 0.3rem;
    }
    
    .price-display {
        font-size: 0.85rem;
    }
    
    .slider-container {
        padding: 0.3rem 0 1rem;
    }
    
    .products-section {
        padding: 0.3rem 0.5rem 1rem;
    }
    
    .products-section h2 {
        margin: 0.3rem 0 0.6rem;
        font-size: 1.2rem;
    }
    /* Use single column on very small screens to avoid cramped cards */
    .products-grid {
        grid-template-columns: 1fr;
        gap: 0.6rem;
        padding: 0;
    }
    
    .product-card {
        margin-bottom: 0;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    }
    
    .hero {
        height: 300px;
    }
    
    .hero h1 {
        font-size: 1.8rem;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
    }
}

/* Loading State */
.loading {
    text-align: center;
    padding: 2rem;
    font-size: 1.2rem;
    color: var(--light-text);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    grid-column: 1 / -1;
}

.empty-state i {
    font-size: 3rem;
    color: #bdc3c7;
    margin-bottom: 1rem;
}

.empty-state p {
    color: var(--light-text);
    font-size: 1.1rem;
}
