/**
 * Nekko Modals CSS
 * Quick Preview Modal & Cart Confirmation Modal
 * @package Nekko
 */

/* =================================================================
   CSS Variables
   ================================================================= */
:root {
    --nekko-primary: #443E25;
    --nekko-primary-light: #5a5335;
    --nekko-bg-warm: #FCF9EE;
    --nekko-border: #e5e0d1;
    --nekko-text: #443E25;
    --nekko-text-light: #6b6550;
}

/* =================================================================
   Body lock
   ================================================================= */
body.nekko-modal-open {
    overflow: hidden !important;
}

/* =================================================================
   Modal Base - Full screen overlay
   ================================================================= */
#nekko-quick-preview-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 999999 !important;
    display: none;
}

#nekko-quick-preview-modal.is-open {
    display: block !important;
}

/* Backdrop - full screen, no radius */
#nekko-quick-preview-modal .nekko-modal__backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.5) !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* =================================================================
   Desktop Modal - Centered
   ================================================================= */
#nekko-quick-preview-modal .nekko-modal__container--desktop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: none;
    align-items: center !important;
    justify-content: center !important;
    padding: 2rem !important;
    box-sizing: border-box !important;
}

@media (min-width: 768px) {
    #nekko-quick-preview-modal .nekko-modal__container--desktop {
        display: flex !important;
    }
    #nekko-quick-preview-modal .nekko-modal__container--mobile {
        display: none !important;
    }
}

/* Modal content box */
#nekko-quick-preview-modal .nekko-modal__container--desktop .nekko-modal__content {
    position: relative !important;
    background: #fff !important;
    border-radius: 2rem !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
    max-width: 550px !important;
    width: 100% !important;
    max-height: 90vh !important;
    overflow: hidden !important;
    margin: 0 auto !important;
}

/* =================================================================
   Mobile Bottom Sheet
   ================================================================= */
#nekko-quick-preview-modal .nekko-modal__container--mobile {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 10000 !important;
    display: block;
}

@media (min-width: 768px) {
    #nekko-quick-preview-modal .nekko-modal__container--mobile {
        display: none !important;
    }
}

#nekko-quick-preview-modal .nekko-modal__content--bottom-sheet {
    background: #fff !important;
    border-radius: 2rem 2rem 0 0 !important;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15) !important;
    max-height: 90vh !important;
    overflow: hidden !important;
}

/* Drag Handle */
.nekko-modal__drag-handle {
    display: flex;
    justify-content: center;
    padding: 1rem 0 0.5rem;
}

.nekko-modal__drag-handle span {
    width: 40px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
}

/* =================================================================
   Modal Header
   ================================================================= */
.nekko-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--nekko-border);
}

.nekko-modal__title {
    font-family: 'Encode Sans', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--nekko-text);
    margin: 0;
}

.nekko-modal__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--nekko-text-light);
    cursor: pointer;
}

.nekko-modal__close:hover {
    background: var(--nekko-bg-warm);
    color: var(--nekko-text);
}

/* =================================================================
   Modal Body
   ================================================================= */
.nekko-modal__body {
    padding: 2rem;
    overflow-y: auto;
}

#nekko-quick-preview-modal .nekko-modal__container--desktop .nekko-modal__body {
    max-height: calc(90vh - 180px);
}

#nekko-quick-preview-modal .nekko-modal__container--mobile .nekko-modal__body {
    max-height: calc(70vh - 140px);
}

/* =================================================================
   Quick Preview Layout - Desktop Grid
   ================================================================= */
#nekko-quick-preview-modal .nekko-modal__container--desktop .nekko-quick-preview {
    display: grid !important;
    grid-template-columns: 160px 1fr !important;
    gap: 2rem !important;
    align-items: start !important;
}

#nekko-quick-preview-modal .nekko-modal__container--mobile .nekko-quick-preview {
    display: block !important;
}

/* Image */
.nekko-quick-preview__image {
    background: var(--nekko-bg-warm);
    border-radius: 1.5rem;
    overflow: hidden;
    aspect-ratio: 1;
}

.nekko-quick-preview__img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    padding: 1rem;
}

#nekko-quick-preview-modal .nekko-modal__container--mobile .nekko-quick-preview__image {
    max-width: 160px;
    margin: 0 auto 1.5rem;
}

/* Price */
.nekko-quick-preview__price {
    font-family: 'Encode Sans', sans-serif;
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--nekko-text);
    margin-bottom: 0.5rem;
}

.nekko-quick-preview__price del {
    color: var(--nekko-text-light);
    font-size: 1.8rem;
    margin-right: 0.5rem;
}

.nekko-quick-preview__price ins {
    text-decoration: none;
}

.nekko-quick-preview__price-per-kg {
    font-size: 1.4rem;
    color: var(--nekko-text-light);
    margin-bottom: 1.5rem;
}

/* =================================================================
   Attributes (Pills)
   ================================================================= */
.nekko-quick-preview__attributes {
    margin-bottom: 1.5rem;
}

.nekko-quick-preview__attr-group {
    margin-bottom: 1.5rem;
}

.nekko-quick-preview__attr-group:last-child {
    margin-bottom: 0;
}

.nekko-quick-preview__attr-label {
    display: block;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--nekko-text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.nekko-quick-preview__attr-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.nekko-quick-preview__attr-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    padding: 1rem 1.5rem;
    background: #fff;
    border: 2px solid var(--nekko-border);
    border-radius: 4rem;
    font-family: inherit;
    font-size: 1.4rem;
    font-weight: 500;
    color: var(--nekko-text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.nekko-quick-preview__attr-pill:hover:not(.is-unavailable) {
    border-color: var(--nekko-primary);
    background: var(--nekko-bg-warm);
}

.nekko-quick-preview__attr-pill.is-selected {
    border-color: #443E25 !important;
    background: #443E25 !important;
    background-color: #443E25 !important;
    color: #fff !important;
}

.nekko-quick-preview__attr-pill.is-unavailable {
    opacity: 0.4;
    cursor: not-allowed;
    text-decoration: line-through;
}

/* =================================================================
   Quantity Selector
   ================================================================= */
.nekko-quick-preview__quantity {
    margin-top: 1.5rem;
}

.nekko-quick-preview__quantity-label {
    display: block;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--nekko-text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.nekko-quick-preview__quantity-controls {
    display: inline-flex;
    align-items: center;
    border: 2px solid var(--nekko-border);
    border-radius: 4rem;
    overflow: hidden;
}

.nekko-quick-preview__qty-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: #fff;
    border: none;
    color: var(--nekko-text);
    cursor: pointer;
}

.nekko-quick-preview__qty-btn:hover {
    background: var(--nekko-bg-warm);
}

.nekko-quick-preview__qty-input {
    width: 50px;
    height: 44px;
    border: none;
    border-left: 1px solid var(--nekko-border);
    border-right: 1px solid var(--nekko-border);
    text-align: center;
    font-family: inherit;
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--nekko-text);
    -moz-appearance: textfield;
}

.nekko-quick-preview__qty-input::-webkit-outer-spin-button,
.nekko-quick-preview__qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* =================================================================
   Modal Footer
   ================================================================= */
.nekko-modal__footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--nekko-border);
    background: var(--nekko-bg-warm);
}

.nekko-quick-preview__add-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem 2rem;
    background: var(--nekko-primary);
    border: none;
    border-radius: 4rem;
    font-family: inherit;
    font-size: 1.6rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease;
}

.nekko-quick-preview__add-btn:hover:not([disabled]) {
    background: var(--nekko-primary-light);
}

.nekko-quick-preview__add-btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.nekko-quick-preview__add-btn.is-out-of-stock {
    background: #9ca3af;
    opacity: 1;
}

.nekko-quick-preview__add-btn.is-loading .nekko-quick-preview__add-btn-text,
.nekko-quick-preview__add-btn.is-loading .nekko-quick-preview__add-btn-price {
    visibility: hidden;
}

/* Remove old CSS-based spinner - we use SVG now */
.nekko-quick-preview__add-btn.is-loading-old::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: nekko-spin 0.8s linear infinite;
}

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

/* =================================================================
   Loading State
   ================================================================= */
.nekko-quick-preview {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease;
}


/* =================================================================
   iPhone Safe Area Support
   ================================================================= */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .nekko-quick-preview__footer {
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    }
    
    .nekko-cart-modal__footer {
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    }
}
