/* General Styling */
body {
    font-family: 'Arial', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
    color: #333;
}

/* Header */
.main-header {
    background-color: #333;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
}

.site-name {
    margin: 0;
    margin-left: 15px;
    font-size: 1.8em;
    font-weight: bold;
}

.menu-toggle, .cart-icon-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    padding: 5px 10px;
}

.cart-icon-btn {
    position: relative;
    margin-left: 15px;
}

.cart-count {
    background-color: red;
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.7em;
    position: absolute;
    top: -5px;
    right: -5px;
}

.cart-total-price {
    font-size: 1.1em;
    margin-right: 10px;
}

/* Sidebar */
.sidebar {
    height: 100%;
    width: 0; /* Initially hidden */
    position: fixed;
    z-index: 1001;
    top: 0;
    left: 0;
    background-color: #222;
    overflow-x: hidden;
    transition: 0.5s;
    padding-top: 60px;
    box-shadow: 2px 0 5px rgba(0,0,0,0.3);
    color: white;
}

.sidebar.open {
    width: 250px; /* Width when open */
}

.sidebar .close-sidebar {
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 36px;
    color: #f1f1f1;
    background: none;
    border: none;
    cursor: pointer;
}

.category-nav h2 {
    color: #f1f1f1;
    padding: 8px 15px;
    margin-top: 0;
    font-size: 1.3em;
}

.sidebar ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.sidebar ul li {
    padding: 0;
}

.sidebar ul li a {
    padding: 10px 15px;
    text-decoration: none;
    font-size: 1.1em;
    color: #e1e1e1;
    display: block;
    transition: 0.3s;
}

.sidebar ul li a:hover {
    background-color: #575757;
    color: white;
}

.sub-categories {
    list-style-type: none;
    padding-left: 20px;
    background-color: #3a3a3a;
    display: none; /* Initially hidden */
}

.category-item.active + .sub-categories {
    display: block;
}

.sub-categories li a {
    font-size: 0.95em;
    padding: 8px 15px;
    color: #bbb;
}

.sub-categories li a:hover {
    background-color: #4a4a4a;
    color: white;
}

/* Overlay for sidebar */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none; /* Hidden by default */
}

/* Main Content */
.main-content {
    padding: 20px;
    margin-left: 0; /* No margin when sidebar closed */
    transition: margin-left 0.5s;
}

.main-content.shifted {
    margin-left: 250px; /* Margin when sidebar open */
}

.main-content h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    max-width: 1200px;
    margin: 0 auto;
}

.product-item {
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.product-item:hover {
    transform: translateY(-5px);
}

.product-item img {
    max-width: 100%;
    height: 150px;
    object-fit: contain;
    margin-bottom: 10px;
}

.product-item h3 {
    font-size: 1.3em;
    margin: 10px 0;
    color: #0056b3;
}

.product-item p {
    font-size: 0.9em;
    color: #666;
    height: 40px; /* Fixed height for description */
    overflow: hidden;
}

.product-item .price {
    font-size: 1.2em;
    color: #e67e22;
    font-weight: bold;
    display: block;
    margin: 10px 0;
}

.add-to-cart {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease;
}

.add-to-cart:hover {
    background-color: #218838;
}

/* Modal Styling (Cart & Checkout) */
.cart-modal, .checkout-modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 2000; /* Higher than sidebar */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    justify-content: center;
    align-items: center;
}

.cart-content, .checkout-content {
    background-color: #fefefe;
    margin: auto;
    padding: 30px;
    border: 1px solid #888;
    width: 80%;
    max-width: 600px;
    border-radius: 10px;
    position: relative;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.close-button {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.cart-content h2, .checkout-content h2 {
    text-align: center;
    margin-top: 0;
    color: #333;
}

.cart-items-container {
    max-height: 300px;
    overflow-y: auto;
    border-bottom: 1px solid #eee;
    margin-bottom: 15px;
    padding-bottom: 10px;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dashed #eee;
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-info {
    flex-grow: 1;
}

.cart-item-name {
    font-weight: bold;
}

.cart-item-details {
    font-size: 0.9em;
    color: #666;
}

.cart-item-price {
    font-weight: bold;
    color: #e67e22;
}

.cart-item-remove {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 5px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    margin-left: 10px;
}

.cart-item-remove:hover {
    background-color: #c82333;
}

.empty-cart-message {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 20px;
}

.cart-summary {
    text-align: right;
    font-size: 1.2em;
    font-weight: bold;
    margin-top: 15px;
}

.order-now-btn, .place-order-btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1em;
    margin-top: 20px;
    display: block;
    width: 100%;
    text-align: center;
    transition: background-color 0.3s ease;
}

.order-now-btn:hover, .place-order-btn:hover {
    background-color: #0056b3;
}

/* Checkout Form */
.checkout-form .form-group {
    margin-bottom: 15px;
}

.checkout-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.checkout-form input[type="text"],
.checkout-form input[type="tel"],
.checkout-form input[type="email"],
.checkout-form textarea,
.checkout-form select {
    width: calc(100% - 20px);
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
    box-sizing: border-box; /* Include padding in width */
}

.order-confirmation-message {
    text-align: center;
    margin-top: 20px;
    font-weight: bold;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .main-header {
        padding: 10px 15px;
    }

    .site-name {
        font-size: 1.5em;
        margin-left: 10px;
    }

    .sidebar.open {
        width: 200px;
    }

    .main-content.shifted {
        margin-left: 0; /* No shift on smaller screens */
    }

    .product-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 15px;
    }

    .cart-content, .checkout-content {
        width: 95%;
        padding: 20px;
    }
}