/**
 * E-Commerce System - Main Stylesheet
 */

:root {
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --secondary-color: #764ba2;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --dark-color: #1f2937;
    --light-color: #f9fafb;
    --border-color: #e5e7eb;
    --text-color: #374151;
    --text-light: #6b7280;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text-color);
    background: #fff;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-top {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px 0;
}

.logo h1 {
    font-size: 24px;
    color: var(--primary-color);
    font-weight: 700;
}

.logo a {
    text-decoration: none;
}

.search-bar {
    flex: 1;
    display: flex;
    max-width: 600px;
}

.search-bar input {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid var(--border-color);
    border-right: none;
    border-radius: 8px 0 0 8px;
    font-size: 15px;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-bar button {
    padding: 12px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    transition: background 0.3s;
}

.search-bar button:hover {
    background: var(--primary-dark);
}

.header-actions {
    display: flex;
    gap: 15px;
}

.btn-icon {
    position: relative;
    padding: 10px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color);
    transition: color 0.3s;
}

.btn-icon:hover {
    color: var(--primary-color);
}

.btn-icon .badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--danger-color);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
}

/* Navigation */
.nav {
    display: flex;
    align-items: center;
    gap: 30px;
    padding: 15px 0;
    border-top: 1px solid var(--border-color);
}

.nav-categories {
    position: relative;
}

.btn-categories {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s;
}

.btn-categories:hover {
    background: var(--primary-dark);
}

.category-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    border-radius: 8px;
    min-width: 250px;
    margin-top: 10px;
    padding: 10px 0;
    z-index: 100;
}

.category-item {
    position: relative;
}

.category-item > a {
    display: block;
    padding: 12px 20px;
    color: var(--text-color);
    text-decoration: none;
    transition: background 0.3s;
}

.category-item > a:hover {
    background: var(--light-color);
    color: var(--primary-color);
}

.subcategories {
    position: absolute;
    left: 100%;
    top: 0;
    background: white;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    border-radius: 8px;
    min-width: 200px;
    padding: 10px 0;
    display: none;
}

.category-item:hover .subcategories {
    display: block;
}

.subcategories a {
    display: block;
    padding: 10px 20px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 14px;
}

.subcategories a:hover {
    background: var(--light-color);
    color: var(--primary-color);
}

.nav-links {
    display: flex;
    gap: 30px;
    list-style: none;
}

.nav-links a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: var(--primary-color);
}

/* Main Content */
.main-content {
    min-height: calc(100vh - 400px);
    padding: 40px 0;
}

.loading {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Products Section */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.section-header h2 {
    font-size: 28px;
    color: var(--dark-color);
}

.sort-options select {
    padding: 10px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

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

.product-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.product-image {
    position: relative;
    display: block;
    padding-top: 100%;
    overflow: hidden;
}

.product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.product-card:hover .product-image img {
    transform: scale(1.05);
}

.badge-discount,
.badge-featured {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: white;
}

.badge-discount {
    background: var(--danger-color);
}

.badge-featured {
    background: var(--primary-color);
    top: 45px;
}

.product-info {
    padding: 15px;
}

.product-brand {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 5px;
}

.product-name {
    font-size: 15px;
    margin-bottom: 10px;
    line-height: 1.4;
}

.product-name a {
    color: var(--text-color);
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-name a:hover {
    color: var(--primary-color);
}

.product-rating {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 10px;
}

.stars {
    color: #fbbf24;
}

.stars span {
    font-size: 14px;
}

.stars span.filled {
    color: #fbbf24;
}

.rating-count {
    font-size: 12px;
    color: var(--text-light);
}

.product-price {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.old-price {
    text-decoration: line-through;
    color: var(--text-light);
    font-size: 14px;
}

.current-price {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-color);
}

.btn-add-cart {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-add-cart:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-add-cart:disabled {
    background: var(--border-color);
    cursor: not-allowed;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 40px;
}

.pagination button {
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s;
}

.pagination button:hover:not(:disabled) {
    background: var(--primary-dark);
}

.pagination button:disabled {
    background: var(--border-color);
    cursor: not-allowed;
}

.page-info {
    font-weight: 600;
    color: var(--text-color);
}

/* Cart Sidebar */
.cart-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 16px rgba(0,0,0,0.1);
    transition: right 0.3s;
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

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

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

.cart-header h3 {
    font-size: 20px;
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-color);
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.empty-cart {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.cart-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
}

.item-info h4 {
    font-size: 14px;
    margin-bottom: 5px;
}

.item-price {
    font-size: 13px;
    color: var(--text-light);
}

.item-quantity {
    display: flex;
    align-items: center;
    gap: 10px;
}

.item-quantity button {
    width: 30px;
    height: 30px;
    background: var(--light-color);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.item-total {
    font-weight: 700;
    color: var(--primary-color);
}

.btn-remove {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    padding: 5px;
}

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

.cart-summary {
    margin-bottom: 20px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
}

.summary-row.total {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-color);
    border-top: 2px solid var(--border-color);
    padding-top: 15px;
    margin-top: 10px;
}

.btn-checkout {
    display: block;
    width: 100%;
    padding: 15px;
    background: var(--success-color);
    color: white;
    text-align: center;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 700;
    transition: background 0.3s;
}

.btn-checkout:hover {
    background: #059669;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1500;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
}

.toast {
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-bottom: 10px;
    animation: slideIn 0.3s;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Footer */
.footer {
    background: var(--dark-color);
    color: white;
    padding: 40px 0 20px;
    margin-top: 60px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.footer-section h4 {
    margin-bottom: 15px;
    font-size: 18px;
}

.footer-section ul {
    list-style: none;
}

.footer-section a {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    line-height: 2;
    transition: color 0.3s;
}

.footer-section a:hover {
    color: white;
}

.payment-icons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.payment-icons img {
    height: 30px;
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.7);
}

/* Responsive */
@media (max-width: 768px) {
    .header-top {
        flex-direction: column;
    }
    
    .search-bar {
        max-width: 100%;
    }
    
    .nav {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .nav-links {
        flex-wrap: wrap;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .cart-sidebar {
        width: 100%;
        right: -100%;
    }
}