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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    padding-bottom: 80px;
}

/* HEADER */
header {
    background-color: #fff;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 { font-size: 1.5rem; }

.cart-button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    position: relative;
    transition: background-color 0.2s;
}

.cart-button:hover {
    background-color: #0056b3;
}

.cart-button:focus {
    outline: 2px solid #0056b3;
    outline-offset: 2px;
}

.cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: #dc3545;
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.75rem;
    min-width: 20px;
    text-align: center;
}

/* GRID */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* CARD */
.product-card {
    background-color: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* CAROUSEL */
.carousel-container {
    position: relative;
    width: 100%;
    height: 150px;
    background: #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.carousel-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.carousel-image.active { display: block; }

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
    cursor: pointer;
    transition: all 0.3s;
}

.dot:hover {
    background: #999;
}

.dot.active {
    background: #007bff;
    width: 24px;
    border-radius: 4px;
}

/* PRODUCT INFO */
.product-name {
    font-weight: bold;
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

.product-price {
    color: #28a745;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.add-to-cart {
    width: 100%;
    background-color: #007bff;
    color: white;
    border: none;
    padding: 0.5rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.add-to-cart:hover {
    background-color: #0056b3;
}

.add-to-cart:focus {
    outline: 2px solid #0056b3;
    outline-offset: 2px;
}

.add-to-cart:active { 
    background-color: #004085; 
}

/* MODALS */
.modal { 
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background-color: rgba(0,0,0,0.5); 
    z-index: 200; 
}

.modal.active { 
    display: flex; 
    align-items: flex-start; 
    padding-top: 2rem; 
    overflow-y: auto; 
}

.modal-content {
    background-color: white;
    margin: 0 auto 2rem auto;
    padding: 1.5rem;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    transition: color 0.2s;
}

.close-modal:hover {
    color: #000;
}

.close-modal:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* CART ITEMS */
.cart-item { 
    display: flex; 
    gap: 1rem; 
    padding: 1rem 0; 
    border-bottom: 1px solid #e0e0e0; 
}

.cart-item-image { 
    width: 60px; 
    height: 60px; 
    background-color: #e0e0e0; 
    border-radius: 5px; 
    flex-shrink: 0;
    overflow: hidden;
}

.cart-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cart-item-details { flex-grow: 1; }

.cart-item-name { 
    font-weight: bold; 
    margin-bottom: 0.25rem; 
}

.cart-item-price { 
    color: #28a745; 
    font-size: 0.9rem; 
}

.cart-item-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.5rem;
}

.qty-button { 
    background-color: #f0f0f0; 
    border: none; 
    padding: 0.25rem 0.5rem; 
    border-radius: 3px; 
    cursor: pointer;
    transition: background-color 0.2s;
}

.qty-button:hover {
    background-color: #e0e0e0;
}

.qty-button:focus {
    outline: 2px solid #007bff;
    outline-offset: 1px;
}

.cart-total {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid #e0e0e0;
    font-size: 1.25rem;
    font-weight: bold;
    text-align: right;
}

.checkout-button {
    width: 100%;
    background-color: #28a745;
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 1rem;
    transition: background-color 0.2s;
}

.checkout-button:hover {
    background-color: #218838;
}

.checkout-button:focus {
    outline: 2px solid #218838;
    outline-offset: 2px;
}

/* CHECKOUT FORM */
.checkout-form { display: none; }
.checkout-form.active { display: block; }

.form-group { margin-bottom: 1rem; }

.form-group label { 
    display: block; 
    margin-bottom: 0.25rem; 
    font-weight: bold; 
}

.form-group input { 
    width: 100%; 
    padding: 0.5rem; 
    border: 1px solid #ddd; 
    border-radius: 5px; 
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.1);
}

.empty-cart { 
    text-align: center; 
    padding: 2rem; 
    color: #999; 
}

/* PRODUCT MODAL GALLERY */
.product-gallery .gallery-main {
    margin-bottom: 0.5rem;
}

.product-gallery .gallery-main img {
    width: 100%; 
    height: auto; 
    border-radius: 6px; 
    background: #f0f0f0;
}

.gallery-thumbnails {
    display: flex; 
    gap: .5rem; 
    margin-top: .5rem; 
    flex-wrap: wrap;
}

.gallery-thumbnail { 
    border: 2px solid transparent; 
    border-radius: 6px; 
    overflow: hidden; 
    cursor: pointer;
    transition: border-color 0.2s;
}

.gallery-thumbnail:hover {
    border-color: #999;
}

.gallery-thumbnail.active { 
    border-color: #007bff; 
}

.gallery-thumbnail img { 
    width: 60px; 
    height: 60px; 
    object-fit: cover; 
    display: block; 
}

/* RESPONSIVE */
@media (min-width: 768px) {
    .products-grid { 
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); 
    }
    
    .carousel-container { 
        height: 200px; 
    }
    
    .modal-content {
        padding: 2rem;
    }
}