:root {
    --primary-color: #007BFF;
    --secondary-color: #6c757d;
    --background-color: #f8f9fa;
    --surface-color: #ffffff;
    --text-color: #212529;
    --border-color: #dee2e6;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --transition-speed: 0.3s;
}

[data-theme="dark"] {
    --primary-color: #0d6efd;
    --secondary-color: #adb5bd;
    --background-color: #212529;
    --surface-color: #343a40;
    --text-color: #f8f9fa;
    --border-color: #495057;
    --shadow-color: rgba(255, 255, 255, 0.1);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

nav {
    background-color: var(--surface-color);
    box-shadow: 0 2px 4px var(--shadow-color);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-right {
    display: flex;
    gap: 1rem;
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color var(--transition-speed);
}

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

.theme-toggle, .cart-toggle {
    background: none;
    color: var(--text-color);
    font-size: 1.2rem;
    position: relative;
}

.cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: var(--primary-color);
    color: white;
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

main {
    max-width: 1200px;
    margin: 80px auto 2rem;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
}

.products-section {
    width: 100%;
}

.search-container {
    margin: 2rem 0;
}

#search-input {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--surface-color);
    color: var(--text-color);
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
    padding: 1rem 0;
}

.product-card {
    background-color: var(--surface-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px var(--shadow-color);
    transition: transform var(--transition-speed);
}

.product-card:hover {
    transform: translateY(-5px);
}

.product-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.product-info {
    padding: 1rem;
}

.product-title {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.product-price {
    font-weight: bold;
    color: var(--primary-color);
}

.cart-sidebar {
    position: sticky;
    top: 80px;
    height: calc(100vh - 80px);
    width: 400px;
    background-color: var(--surface-color);
    box-shadow: -2px 0 4px var(--shadow-color);
    display: flex;
    flex-direction: column;
    border-radius: 8px;
}

.cart-sidebar.open {
    right: 0;
}

.close-cart {
    display: none;
}

.cart-toggle {
    display: none;
}

.cart-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-header-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.cart-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-weight: bold;
}

.clear-cart {
    width: 100%;
    background-color: var(--secondary-color);
    color: white;
    padding: 0.8rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 1rem;
}

.clear-cart:hover {
    background-color: #dc3545;
}

.checkout-btn {
    width: 100%;
}

.cart-items {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
}

.cart-item {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.cart-item-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
}

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

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

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

.modal.open {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--surface-color);
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--surface-color);
    color: var(--text-color);
}

@media (max-width: 1200px) {
    main {
        grid-template-columns: 1fr;
        max-width: 800px;
    }

    .cart-sidebar {
        position: relative;
        top: 0;
        width: 100%;
        height: auto;
        margin-top: 2rem;
    }

    .cart-items {
        max-height: 400px;
        overflow-y: auto;
    }

    .cart-toggle {
        display: none;
    }

    .close-cart {
        display: none;
    }
}

@media (max-width: 768px) {
    .cart-sidebar {
        width: 100%;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1rem;
    }
}

#cart-count {
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
    position: absolute;
    top: -5px;
    right: -5px;
}

.cart-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cart-title h2 {
    margin: 0;
    display: inline;
}

.cart-item-count {
    color: var(--secondary-color);
    font-size: 1rem;
}

.nav-cart-btn {
    background: none;
    color: var(--text-color);
    font-size: 1.2rem;
    border: none;
    cursor: pointer;
    position: relative;
    padding: 0.5rem;
}

.nav-cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--primary-color);
    color: white;
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}