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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f6fa;
    color: #1f2937;
    line-height: 1.6;
}

header {
    background: #ffffff;
    color: #1f2937;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 10;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #00b89c;
    letter-spacing: -0.5px;
}

#basket-summary {
    background: #ff6b2b;
    color: white;
    padding: 0.5rem 1.2rem;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

#basket-summary:hover {
    background: #e55a1c;
    transform: scale(1.04);
}

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

#catalogue h2,
#basket h2 {
    margin-bottom: 1.25rem;
    color: #111827;
    font-size: 1.25rem;
    font-weight: 700;
}

#products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
}

.product-card {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(0,0,0,0.07);
    transition: transform 0.2s, box-shadow 0.2s;
    aspect-ratio: 3 / 4;
    cursor: pointer;
}

.item-badge {
    position: absolute;
    bottom: 0.55rem;
    right: 0.55rem;
    background: #ff6b2b;
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    z-index: 1;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.item-badge:empty {
    display: none;
}

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

.product-card img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem 0.75rem 0.75rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.72));
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.product-info h3 {
    font-size: 0.88rem;
    color: #ffffff;
    font-weight: 600;
    line-height: 1.2;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.product-price {
    font-size: 1rem;
    font-weight: 700;
    color: #ff6b2b;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}


#basket {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 6px rgba(0,0,0,0.07);
    border: 1px solid #f0f0f0;
    height: fit-content;
    position: sticky;
    top: 5rem;
}

#basket-items {
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
}

.basket-item {
    display: grid;
    grid-template-columns: 60px 1fr auto;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid #f3f4f6;
    align-items: center;
}

.basket-item img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
}

.basket-item-info h4 {
    font-size: 0.88rem;
    margin-bottom: 0.2rem;
    color: #111827;
    font-weight: 600;
}

.basket-item-info .item-price {
    color: #ff6b2b;
    font-weight: 600;
    font-size: 0.88rem;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.quantity-controls button {
    width: 28px;
    height: 28px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
}

.quantity-controls button:hover {
    background: #ff6b2b;
    border-color: #ff6b2b;
    color: white;
}

.quantity-controls span {
    min-width: 24px;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.empty-basket {
    text-align: center;
    padding: 2rem;
    color: #9ca3af;
    font-size: 0.9rem;
}

#basket-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid #f3f4f6;
}

#total-line {
    display: flex;
    justify-content: space-between;
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #111827;
}

#checkout-btn {
    width: 100%;
    padding: 1rem;
    background: #ff6b2b;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    letter-spacing: 0.01em;
}

#checkout-btn:hover:not(:disabled) {
    background: #e55a1c;
    transform: scale(1.01);
}

#checkout-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    transform: none;
}

#loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem 3rem;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    z-index: 100;
    font-weight: 600;
    color: #00b89c;
}

#loading.hidden {
    display: none;
}

#error-message {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: #ef4444;
    color: white;
    padding: 1rem 2rem;
    border-radius: 8px;
    display: none;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(239,68,68,0.3);
}

#error-message.visible {
    display: block;
}

@media (max-width: 900px) {
    main {
        grid-template-columns: 1fr;
        padding: 1rem;
        gap: 1rem;
    }

    #basket {
        position: static;
    }

    #products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
}
