/* Shopify Headless Styles - Full Card Design + Modal */

:root {
    --sh-card-height: 400px;
    --sh-radius: 12px;
    --sh-overlay-start: rgba(0, 0, 0, 0);
    --sh-overlay-end: rgba(0, 0, 0, 0.8);
    --sh-transition: all 0.3s ease;
    --sh-primary-color: #fff;
    /* Text color on card */
}

/* Grid Layout (updated for 5 items centered) */
.shopify-grid-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    padding: 20px 0;
}

/* Product Card - Full Background */
.shopify-product-card {
    position: relative;
    border-radius: var(--sh-radius);
    overflow: hidden;
    aspect-ratio: 3 / 4;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transition: var(--sh-transition);
    background-color: #f0f0f0;
    
    /* Base width fallback: ~33.333% minus gap */
    flex: 0 1 calc(33.333% - 14px);
    max-width: calc(33.333% - 14px);
    width: 100%;
    min-width: 280px;
}

.shopify-product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
}

/* Background Image */
.shopify-card-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-width: 100%;
    min-height: 100%;
    object-fit: cover;
    object-position: center;
    z-index: 1;
    transition: transform 0.6s ease;
}

.shopify-product-card:hover .shopify-card-bg {
    transform: scale(1.05);
}

/* Gradient Overlay */
.shopify-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, var(--sh-overlay-start) 40%, var(--sh-overlay-end) 100%);
    z-index: 2;
    pointer-events: none;
}

/* Content on Card */
.shopify-card-content {
    position: relative;
    z-index: 3;
    padding: 20px;
    color: #fff;
    width: 100%;
    box-sizing: border-box;
}

.shopify-product-card h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 5px 0;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    line-height: 1.2;
}

.shopify-product-card .price {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: rgba(255, 255, 255, 0.9);
}

/* Buttons */
.shopify-btn {
    width: 100%;
    padding: 12px;
    background-color: #c59d5f;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
}

.shopify-btn:hover {
    background-color: #333333;
    transform: translateY(-2px);
    color: #fff !important;
}

.shopify-btn.disabled {
    background-color: rgba(255, 255, 255, 0.5);
    color: #666;
    cursor: not-allowed;
    transform: none;
}

/* Customize Modal Styles */
.sh-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    animation: fadeIn 0.3s forwards;
    padding: 20px;
    box-sizing: border-box;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

body.sh-modal-open {
    overflow: hidden;
    /* Prevent background scroll */
}

.sh-modal-content {
    background: #fff;
    width: 100%;
    max-width: 900px;
    height: auto;
    max-height: 90vh;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.sh-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    color: #333;
    z-index: 10;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.sh-modal-close:hover {
    background: #f0f0f0;
}

.sh-modal-body {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.sh-modal-image {
    flex: 1 1 50%;
    background: #f8f8f8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 20px;
    overflow-y: auto;
}

.sh-modal-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    flex-shrink: 0;
}

/* Product description below image in modal */
.sh-modal-description {
    width: 100%;
    margin-top: 16px;
    padding: 0 4px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #555;
    box-sizing: border-box;
}

.sh-modal-description p {
    margin: 0 0 8px;
}

.sh-modal-description p:last-child {
    margin-bottom: 0;
}

.sh-modal-description a {
    color: #111;
    text-decoration: underline;
}

.sh-modal-description a:hover {
    color: #555;
}

/* Toggle button - hidden on desktop */
.sh-desc-toggle {
    display: none;
}


.sh-modal-details {
    flex: 1 1 50%;
    padding: 40px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sh-modal-details h2 {
    margin-top: 0;
    font-size: 1.8rem;
    line-height: 1.2;
    margin-bottom: 10px;
    color: #111;
}

.sh-modal-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 30px;
}

.sh-option-group {
    margin-bottom: 25px;
}

.sh-option-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
}

.sh-option-values {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.sh-option-pill {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #333;
}

.sh-option-pill:hover {
    border-color: #333;
    background: #f8f8f8;
    color: #111;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.sh-option-pill.selected {
    background: #c59d5f;
    color: #fff;
    border-color: #c59d5f;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sh-modal-actions {
    margin-top: auto;
    padding-top: 20px;
}

.sh-modal-actions .shopify-btn {
    background-color: #c59d5f;
    color: #fff;
    padding: 16px;
    font-size: 1rem;
}

.sh-modal-actions .shopify-btn:hover {
    background-color: #333333;
}

.sh-modal-actions .shopify-btn.disabled {
    background-color: #eee;
    color: #aaa;
}

/* Floating Cart Badge */
#sh-cart-badge {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background-color: #111;
    color: #fff;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 9990;
    cursor: pointer;
    transition: transform 0.2s;
    opacity: 0;
    pointer-events: none;
}

#sh-cart-badge.visible {
    opacity: 1;
    pointer-events: auto;
}

#sh-cart-badge:hover {
    transform: scale(1.1);
}

#sh-cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #e53e3e;
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid #fff;
}

/* Toast */
#sh-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background-color: #333;
    color: #fff;
    padding: 12px 24px;
    border-radius: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    font-weight: 600;
}

#sh-toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Mobile Responsive Modal */
@media (max-width: 768px) {
    .sh-modal-body {
        flex-direction: column;
        overflow-y: auto;
    }

    .sh-modal-image {
        flex: 0 0 auto;
        padding: 10px;
    }

    .sh-modal-details {
        padding: 20px;
        flex: 1 0 auto;
    }

    /* Mobile: clamp description text */
    .sh-desc-text {
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .sh-desc-text.expanded {
        display: block;
        -webkit-line-clamp: unset;
        overflow: visible;
    }

    .sh-desc-toggle {
        display: inline-block;
        background: none;
        border: none;
        padding: 4px 0;
        margin-top: 6px;
        font-size: 0.85rem;
        font-weight: 500;
        color: #111;
        cursor: pointer;
        text-decoration: underline;
        font-family: inherit;
    }

    .sh-desc-toggle:hover {
        color: #555;
    }

    .sh-modal-close {
        top: 10px;
        right: 10px;
        background: rgba(255, 255, 255, 0.8);
    }

    #sh-cart-badge {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
    }
}

/* Loading & Error */
.sh-loading,
.sh-error {
    text-align: center;
    padding: 40px;
    color: #666;
}

/* Single Product Styles */
.shopify-product-container {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
    margin: 40px 0;
}

.shopify-product-image {
    flex: 1 1 500px;
    border-radius: var(--sh-radius);
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.shopify-product-details {
    flex: 1 1 400px;
    padding: 10px;
}

.shopify-product-details h2 {
    font-size: 2.5rem;
    margin-bottom: 0.5em;
}

.shopify-product-details .price {
    font-size: 2rem;
    font-weight: bold;
    color: #111;
    margin-bottom: 20px;
}

/* Make single product use standard select for now, or could share modal styles */
.shopify-options select,
.shopify-options input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
}

@media (max-width: 768px) {
    .shopify-grid-container {
        gap: 15px;
    }
    
    .shopify-product-card {
        flex: 0 1 calc(50% - 7.5px);
        max-width: calc(50% - 7.5px);
        min-width: 160px;
        aspect-ratio: 2 / 3;
    }



    .shopify-card-content {
        padding: 15px;
    }

    .shopify-product-card h3 {
        font-size: 0.85rem !important;
    }

    .shopify-product-card .price {
        font-size: 0.85rem;
        margin-bottom: 10px;
    }

    .shopify-btn {
        padding: 10px;
        font-size: 0.8rem;
    }

    /* Fix cart modal horizontal scrolling on mobile */
    .sh-cart-body {
        padding: 15px;
    }

    .sh-cart-item-details {
        min-width: 0; /* allows flex item to shrink below content size */
    }

    .sh-cart-item-header h4 {
        white-space: normal;
        word-wrap: break-word;
        font-size: 0.9rem;
    }

    .sh-cart-item-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* Cart Modal Specifics */
.sh-cart-modal-content {
    max-width: 500px;
    /* Narrower than product modal */
    max-height: 80vh;
}

.sh-cart-body {
    padding: 30px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.sh-cart-body h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.5rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    color: #000;
}

.sh-cart-items-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 20px;
}

.sh-cart-item {
    display: flex;
    gap: 15px;
    padding: 15px 0;
    border-bottom: 1px solid #f5f5f5;
}

.sh-cart-item:last-child {
    border-bottom: none;
}

.sh-cart-item-image {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    background: #f0f0f0;
    flex-shrink: 0;
}

.sh-cart-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sh-cart-item-details {
    flex: 1;
}

.sh-cart-item-details h4 {
    margin: 0 0 5px;
    font-size: 1rem;
    color: #333;
}

.sh-cart-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.sh-remove-item {
    background: none;
    border: none;
    font-size: 1.2rem;
    line-height: 1;
    color: #999;
    cursor: pointer;
    padding: 0 5px;
    transition: color 0.2s;
}

.sh-remove-item:hover {
    color: #e53e3e;
}

.sh-variant-title {
    margin: 0 0 10px;
    font-size: 0.85rem;
    color: #777;
}

.sh-cart-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 600;
}

.sh-qty-control {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.sh-qty-btn {
    background: #f9f9f9;
    border: none;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: 500;
    color: #333;
    transition: background 0.2s;
}

.sh-qty-btn:hover:not(:disabled) {
    background: #eee;
}

.sh-qty-btn:disabled {
    color: #ccc;
    cursor: default;
}

.sh-qty-input {
    width: 30px;
    height: 28px;
    border: none;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    -moz-appearance: textfield;
}

.sh-qty-input::-webkit-outer-spin-button,
.sh-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.sh-cart-footer {
    border-top: 1px solid #eee;
    padding-top: 20px;
}

/* Configurator Styles */
#sh-configurator-container {
    margin: 20px 0;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

#sh-configurator-container h3 {
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: #111;
}

.sh-config-field {
    margin-bottom: 25px;
}

.sh-config-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
}

.sh-required {
    color: #e53e3e;
}

.sh-config-text,
.sh-config-select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    box-sizing: border-box;
}

.sh-config-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.sh-radio-pill {
    cursor: pointer;
}

.sh-radio-pill input {
    display: none;
}

.sh-radio-pill span {
    display: block;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 40px;
    padding: 10px 20px;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    color: #333;
}

.sh-radio-pill input:checked+span {
    background: #111;
    color: #fff;
    border-color: #111;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sh-config-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    cursor: pointer;
}

.sh-config-checkbox input {
    width: 20px;
    height: 20px;
    accent-color: #111;
}

.sh-config-error {
    color: #e53e3e;
    font-size: 0.85rem;
    margin-top: 5px;
}

.sh-cart-attributes {
    margin-bottom: 10px;
    font-size: 0.85rem;
    background: #f9f9f9;
    padding: 8px;
    border-radius: 4px;
}

.sh-cart-attr {
    margin-bottom: 2px;
}

.sh-attr-key {
    font-weight: 600;
    color: #555;
}

.sh-attr-val {
    color: #333;
}

.sh-cart-subtotal {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #111;
}

.sh-checkout-btn {
    display: block;
    text-align: center;
    text-decoration: none;
    background-color: #c59d5f;
    color: #fff;
    padding: 15px;
    border-radius: 6px;
    font-weight: 500;
    transition: background 0.2s;
}

.sh-checkout-btn:hover {
    background-color: #333333;
    color: #fff;
}

.sh-empty-cart {
    text-align: center;
    color: #666;
    margin-top: 40px;
    font-size: 1.1rem;
}

/* Bundle Wizard Styles */
.sh-bundle-progress {
    font-size: 0.9rem;
    font-weight: 600;
    color: #666;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.shopify-btn.secondary {
    background-color: #fff;
    color: #333;
    border: 1px solid #ddd;
}

.shopify-btn.secondary:hover {
    background-color: #333333;
    border-color: #333333;
}

/* Ensure actions can hold multiple buttons */
.sh-modal-actions {
    display: flex;
    gap: 15px;
}

.sh-modal-actions .shopify-btn {
    flex: 1;
}

/* Bundle Button in Grid */
.shopify-btn.bundle-btn {
    background-color: #c59d5f;
    color: #fff!important;
}

.shopify-btn.bundle-btn:hover {
    background-color: #333333;
}