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

body {
    font-family: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
}

/* Header styles */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem 2rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><defs><pattern id="grid" width="100" height="100" patternUnits="userSpaceOnUse"><path d="M 100 0 L 0 0 0 100" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="1"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.3;
    pointer-events: none;
}

header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 1.5rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.header-user-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
    z-index: 1;
}

.header-user-area .user-display,
.header-user-area .guest-text {
    color: rgba(255,255,255,0.95);
    font-weight: 500;
    font-size: 0.95rem;
}

.header-user-area .profile-link {
    color: white;
    text-decoration: none;
    font-weight: 600;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.header-user-area .profile-link:hover {
    background: rgba(255,255,255,0.25);
}

.header-auth-btn {
    display: inline-block;
    background: white;
    color: #667eea;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    border: none;
    transition: all 0.3s ease;
}

.header-auth-btn:hover {
    background: rgba(255,255,255,0.95);
    transform: translateY(-2px);
    color: #764ba2;
}

/* Navigation styles */
nav {
    background-color: white;
    padding: 1.2rem 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    backdrop-filter: blur(10px);
}

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

.breadcrumb a {
    color: #667eea;
    text-decoration: none;
    transition: all 0.3s ease;
    font-weight: 500;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
}

.breadcrumb a:hover {
    color: #764ba2;
    background-color: rgba(102, 126, 234, 0.08);
}

.breadcrumb span {
    color: #95a5a6;
    font-weight: 400;
}

.breadcrumb span::before {
    content: " › ";
    margin: 0 0.5rem;
    color: #bdc3c7;
    font-weight: 400;
}

/* Main layout */
main {
    display: flex;
    max-width: 1400px;
    margin: 2.5rem auto;
    padding: 0 1.5rem;
    gap: 2.5rem;
}

/* Categories sidebar */
aside.categories {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    min-width: 220px;
    height: fit-content;
    position: sticky;
    top: 2rem;
    transition: transform 0.3s ease;
}

aside.categories:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
}

aside.categories h2 {
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
    color: #2c3e50;
    font-weight: 600;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f0f0f0;
}

aside.categories ul {
    list-style: none;
}

aside.categories li {
    margin-bottom: 0.5rem;
}

aside.categories a {
    color: #555;
    text-decoration: none;
    display: block;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

aside.categories a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

aside.categories a:hover {
    background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%);
    color: #667eea;
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

aside.categories a:hover::before {
    transform: scaleY(1);
}

/* Products section */
.products-section {
    flex: 1;
}

.products-section h2 {
    margin-bottom: 2rem;
    color: #2c3e50;
    font-size: 1.8rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.products-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Product card */
.product-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    flex: 0 0 calc(25% - 0.75rem);
    min-width: 160px;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(0,0,0,0.05);
    position: relative;
}

.product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transform: scaleX(0);
    transition: transform 0.4s ease;
}

.product-card:hover::before {
    transform: scaleX(1);
}

.product-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.25);
}

.product-thumbnail {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    cursor: pointer;
    transition: transform 0.4s ease;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 12px 12px 0 0;
}

.product-card:hover .product-thumbnail {
    transform: scale(1.03);
}

.product-info {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-name {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    cursor: pointer;
    text-decoration: none;
    display: block;
    transition: color 0.3s ease;
    line-height: 1.4;
}

.product-name:hover {
    color: #667eea;
}

.product-price {
    font-size: 1.1rem;
    color: #e74c3c;
    font-weight: 700;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.add-to-cart-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-top: auto;
}

.add-to-cart-btn:hover {
    background: #764ba2;
    transform: translateY(-2px) scale(1.02);
}

.add-to-cart-btn:active {
    transform: translateY(0) scale(1);
}

/* Shopping list container */
.shopping-list-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.shopping-list-summary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
    font-weight: 600;
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.shopping-list-summary .cart-icon {
    width: 22px;
    height: 22px;
    opacity: 0.95;
}

.shopping-list-summary::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.shopping-list-summary:hover::before {
    opacity: 1;
}

.shopping-list-summary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.5);
}

.shopping-list-expanded {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.75rem;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    min-width: 320px;
    max-width: 420px;
    padding: 1.5rem;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Desktop & Mobile: show on click (avoids hover gap issue) */
.shopping-list-container.active .shopping-list-expanded {
    display: block;
}

.shopping-list-expanded h3 {
    margin-bottom: 1.25rem;
    color: #2c3e50;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 0.75rem;
    font-weight: 600;
    font-size: 1.2rem;
}

.shopping-list-expanded ul {
    list-style: none;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.shopping-list-expanded li {
    padding: 0.75rem 0;
    border-bottom: 1px solid #ecf0f1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.shopping-list-expanded li.empty-message {
    color: #95a5a6;
    justify-content: center;
    border: none;
}

.shopping-list-item-info {
    flex: 1;
}

.shopping-list-item-name {
    font-weight: bold;
    color: #2c3e50;
}

.shopping-list-item-price {
    color: #7f8c8d;
    font-size: 0.9rem;
}

.shopping-list-item-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cart-remove-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: #e74c3c;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    flex-shrink: 0;
}
.cart-remove-btn:hover {
    background: #c0392b;
}

.shopping-list-item-controls input {
    width: 70px;
    padding: 0.5rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    transition: all 0.3s ease;
}

.shopping-list-item-controls input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.checkout-btn {
    width: 100%;
    background: #27ae60;
    color: white;
    border: none;
    padding: 1.1rem;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.checkout-btn:hover {
    background: #229954;
    transform: translateY(-2px);
}

.checkout-btn:active {
    transform: translateY(0);
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 1rem 1.5rem;
    border-radius: 10px;
    font-weight: 500;
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}

.toast-show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-success {
    background: #27ae60;
    color: white;
}

.toast-error {
    background: #e74c3c;
    color: white;
}

/* Footer styles */
footer {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    text-align: center;
    padding: 2rem;
    margin-top: 4rem;
    box-shadow: 0 -4px 15px rgba(0,0,0,0.1);
}

footer p {
    font-weight: 400;
    opacity: 0.9;
}

/* Responsive design */
@media (max-width: 992px) {
    .product-card {
        flex: 0 0 calc(33.333% - 0.67rem);
    }
}

@media (max-width: 768px) {
    main {
        flex-direction: column;
    }

    aside.categories {
        width: 100%;
        min-width: auto;
    }

    .categories-toggle {
        display: block;
        width: 100%;
        padding: 1rem;
        background: #667eea;
        color: white;
        border: none;
        border-radius: 10px;
        font-weight: 600;
        cursor: pointer;
        margin-bottom: 1rem;
    }

    aside.categories.collapsed #categories-list {
        display: none;
    }

    aside.categories.collapsed h2 {
        display: none;
    }

    .product-card {
        flex: 0 0 calc(50% - 0.5rem);
    }

    .shopping-list-container {
        top: 10px;
        right: 10px;
    }

    .shopping-list-expanded {
        right: -10px;
        min-width: calc(100vw - 40px);
        max-width: calc(100vw - 40px);
    }

    header {
        flex-wrap: wrap;
    }

    .header-user-area {
        order: 3;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .product-card {
        flex: 0 0 100%;
    }

    header h1 {
        font-size: 1.4rem;
    }

    .shopping-list-summary {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
}
