/* WAPF Modal Styles - Clean Minimal Theme */

/* Font Import */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

/* Base Font */
.wapf-modal-overlay,
.wapf-modal-overlay *,
.wapf-outside-modal-field,
.wapf-outside-modal-field *,
.wapf-field-container,
.wapf-field-container * {
    font-family: 'Montserrat', sans-serif !important;
}

/* Hide required asterisk */
abbr.required {
    display: none;
}

/* Modal Trigger Button */
.wapf-modal-trigger-container {
    margin: 20px 0;
}

.wapf-open-modal-btn {
    background-color: #000;
    color: #fff;
    padding: 14px 32px;
    border: 2px solid #000;
    border-radius: 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
}

.wapf-open-modal-btn:hover {
    background-color: #fff;
    color: #000;
}

.wapf-open-modal-btn:active {
    background-color: #000;
    color: #fff;
}

/* Modal Overlay */
.wapf-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 99999;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* IMPORTANT: Disable clicks when hidden */
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.wapf-modal-overlay.wapf-modal-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* Enable clicks when visible */
}

/* Modal Container */
.wapf-modal-container {
    background: #fff;
    border-radius: 0;
    max-width: 1200px;
    width: 100%;
    max-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    box-shadow: none;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.wapf-modal-visible .wapf-modal-container {
    opacity: 1;
    transform: translateY(0);
}

/* Modal Header */
.wapf-modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid #000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border-radius: 0;
    flex-shrink: 0;
}

.wapf-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #000;
    letter-spacing: 0.3px;
}

/* Modal Close Button */
.wapf-modal-close {
    background: transparent;
    border: 2px solid #000;
    font-size: 24px;
    line-height: 1;
    color: #000;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    transition: all 0.2s ease;
}

.wapf-modal-close:hover {
    background-color: #000;
    color: #fff;
}

.wapf-modal-close:active {
    background-color: #333;
}

/* Modal Body */
.wapf-modal-body {
    padding: 32px;
    overflow-y: auto;
    flex: 1;
    background: #fff;
}

.wapf-modal-body::-webkit-scrollbar {
    width: 6px;
}

.wapf-modal-body::-webkit-scrollbar-track {
    background: #fff;
}

.wapf-modal-body::-webkit-scrollbar-thumb {
    background: #000;
}

.wapf-modal-body::-webkit-scrollbar-thumb:hover {
    background: #333;
}

/* Responsive Design */
@media (max-width: 768px) {
    .wapf-modal-overlay {
        padding: 20px 16px;
    }

    .wapf-modal-container {
        max-width: 100%;
        max-height: calc(100vh - 40px);
    }

    .wapf-modal-header {
        padding: 20px 24px;
    }

    .wapf-modal-header h3 {
        font-size: 14px;
    }

    .wapf-modal-body {
        padding: 24px;
    }
}

/* Additional spacing for fields inside modal */
.wapf-modal-body .wapf-field-container {
    margin-bottom: 24px;
}

.wapf-modal-body .wapf-field-container:last-child {
    margin-bottom: 0;
}

/* Field labels in modal */
.wapf-modal-body .wapf-field-label label {
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.2px;
    color: #000;
}

/* Modal Footer - Sticky Price Summary */
.wapf-modal-footer {
    position: sticky;
    bottom: 0;
    background: #000;
    border-top: none;
    padding: 0;
    border-radius: 0;
    flex-shrink: 0;
    max-height: 45vh;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.wapf-modal-footer.collapsed {
    max-height: 124px;
}

.wapf-modal-footer-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 38px 32px;
    cursor: pointer;
    background: #000;
    border-bottom: 1px solid #333;
    transition: background 0.2s ease;
}

.wapf-modal-footer-toggle:hover {
    background: #1a1a1a;
}

.wapf-modal-footer-toggle-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wapf-modal-footer-toggle-arrow {
    font-size: 12px;
    transition: transform 0.25s ease;
    color: #fff;
}

.wapf-modal-footer.collapsed .wapf-modal-footer-toggle-arrow {
    transform: rotate(180deg);
}

.wapf-modal-footer-title {
    font-weight: 600;
    font-size: 14px;
    color: #fff;
    letter-spacing: 0.2px;
}

.wapf-modal-footer-price {
    font-weight: 600;
    font-size: 18px;
    color: #fff;
}

.wapf-modal-footer-content {
    padding: 24px 32px;
    overflow-y: auto;
    max-height: calc(45vh - 64px);
    background: #fff;
}

.wapf-modal-footer.collapsed .wapf-modal-footer-content {
    display: none;
}

.wapf-modal-summary-section {
    margin-bottom: 20px;
}

.wapf-modal-summary-section:last-child {
    margin-bottom: 0;
}

.wapf-modal-summary-title {
    font-weight: 600;
    font-size: 13px;
    color: #666;
    margin-bottom: 12px;
    letter-spacing: 0.2px;
}

.wapf-modal-summary-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.wapf-modal-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #e5e5e5;
    font-size: 13px;
}

.wapf-modal-summary-item:last-child {
    border-bottom: none;
}

.wapf-modal-summary-item-label {
    color: #000;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wapf-modal-summary-item-label strong {
    font-weight: 500;
}

.wapf-modal-summary-item-value {
    color: #666;
    font-weight: 400;
}

.wapf-modal-summary-item-price {
    color: #000;
    font-weight: 500;
    white-space: nowrap;
}

.wapf-modal-summary-totals {
    border-top: 2px solid #000;
    padding-top: 16px;
    margin-top: 16px;
}

.wapf-modal-summary-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
    color: #000;
}

.wapf-modal-summary-total-row.grand-total {
    font-size: 16px;
    font-weight: 600;
    padding-top: 12px;
    color: #000;
}

/* Enhanced Selected States - Clean Black Border */
/* Image swatches */
.wapf-modal-body .wapf-swatch--image.wapf-checked,
.wapf-modal-body .wapf-swatch.wapf-checked {
    border: 2px solid #000 !important;
    outline: 2px solid #000;
    outline-offset: 2px;
}

/* Color swatches */
.wapf-modal-body .wapf-swatch--color.wapf-checked .wapf-color {
    border: 3px solid #fff !important;
    box-shadow: 0 0 0 2px #000;
}

/* Text swatches */
.wapf-modal-body .wapf-swatch--text.wapf-checked {
    border: 2px solid #000 !important;
    background: #000;
    color: #fff;
}

/* Checkbox and radio labels when checked */
.wapf-modal-body input[type="checkbox"]:checked + .wapf-input-label,
.wapf-modal-body input[type="radio"]:checked + .wapf-input-label,
.wapf-modal-body .wapf-checkable input[type="checkbox"]:checked ~ .wapf-label-text,
.wapf-modal-body .wapf-checkable input[type="radio"]:checked ~ .wapf-label-text {
    font-weight: 600;
    color: #000;
}

/* Select dropdown */
.wapf-modal-body select {
    border: 1px solid #000;
    border-radius: 0;
    padding: 12px 16px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
}

.wapf-modal-body select:focus {
    outline: none;
    border-color: #000;
    box-shadow: 0 0 0 1px #000;
}

/* Input fields */
.wapf-modal-body input[type="text"],
.wapf-modal-body input[type="number"],
.wapf-modal-body input[type="email"],
.wapf-modal-body input[type="url"],
.wapf-modal-body textarea {
    border: 1px solid #ccc;
    border-radius: 0;
    padding: 12px 16px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.wapf-modal-body input[type="text"]:focus,
.wapf-modal-body input[type="number"]:focus,
.wapf-modal-body input[type="email"]:focus,
.wapf-modal-body input[type="url"]:focus,
.wapf-modal-body textarea:focus {
    outline: none;
    border-color: #000;
}

/* Hover states */
.wapf-modal-body .wapf-swatch--image:hover:not(.wapf-checked),
.wapf-modal-body .wapf-swatch:hover:not(.wapf-checked) {
    border: 1px solid #000;
}

.wapf-modal-body .wapf-swatch--text:hover:not(.wapf-checked) {
    border: 1px solid #000;
    background: #fafafa;
}

/* Swatch base styles override */
.wapf-modal-body .wapf-swatch {
    border: 1px solid #e5e5e5;
    border-radius: 0 !important;
    transition: all 0.15s ease;
}

.wapf-modal-body .wapf-swatch-label {
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.2px;
    padding: 8px 4px;
}

/* Responsive adjustments for modal footer */
@media (max-width: 768px) {
    .wapf-modal-footer {
        max-height: 50vh;
    }

    .wapf-modal-footer-content {
        max-height: calc(50vh - 64px);
        padding: 20px 24px;
    }

    .wapf-modal-footer-toggle {
        padding: 16px 24px;
    }

    .wapf-modal-footer-price {
        font-size: 16px;
    }
}

/* ============================================
   WAPF FIELDS MODERN STYLING
   ============================================ */

/* Section Dividers - Main Category Headers */
.wapf-section-divider,
.wapf-field-container[data-field-type="section"] {
    margin-top: 40px !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
}

.wapf-field-container[data-field-type="section"]:first-child {
    margin-top: 0 !important;
}

.wapf-field-container[data-field-type="section"] .wapf-field-label {
    background: transparent;
    padding: 20px 28px;
    margin: 0;
    border-radius: 0;
    position: relative;
    overflow: hidden;
    text-align: center;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-content: center;
    justify-content: center;
    align-items: center;
}

.wapf-field-container[data-field-type="section"] .wapf-field-label::before {
    display: none;
}

.wapf-field-container[data-field-type="section"] .wapf-field-label label {
    color: #1a1a1a !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    letter-spacing: 0.3px !important;
    margin: 0;
    display: block;
}

.wapf-field-container[data-field-type="section"] .wapf-field-description {
    background: #f8f9fa;
    padding: 14px 28px;
    margin: 0;
    border-left: 0px;
    font-size: 16px;
    color: #161616;
    font-style: normal;
    text-align: center;
}

.wapf-field-container[data-field-type="section"] .wapf-field-description:empty {
    display: none;
}

/* Section End - Hidden */
.wapf-field-container[data-field-type="sectionend"] {
    display: none !important;
}

/* Fields inside sections */
.wapf-field-container[data-field-type="section"] ~ .wapf-field-container:not([data-field-type="section"]):not([data-field-type="sectionend"]) {
    background: #fff;
    border-left: 1px solid #e5e5e5;
    border-right: 1px solid #e5e5e5;
    padding: 24px 28px !important;
    margin-bottom: 0 !important;
    border-bottom: 1px solid #f0f0f0;
}

/* Field Labels - Modern Style */
.wapf-modal-body .wapf-field-label {
    margin-bottom: 14px;
}

.wapf-modal-body .wapf-field-label label {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #1a1a1a !important;
    letter-spacing: 0.2px !important;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wapf-modal-body .wapf-field-label label .wapf-required {
    color: #e74c3c;
    font-weight: 700;
}

/* Field Descriptions */
.wapf-modal-body .wapf-field-description {
    font-size: 12px;
    color: #888;
    margin-top: 6px;
    line-height: 1.5;
}

/* ============================================
   IMAGE SWATCHES - MODERN CARD STYLE
   ============================================ */

.wapf-modal-body .wapf-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 8px;
}

.wapf-modal-body .wapf-swatch {
    position: relative;
    background: #fff;
    border: 2px solid #e5e5e5 !important;
    border-radius: 8px !important;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    min-width: 120px;
    flex: 0 0 auto;
}

.wapf-modal-body .wapf-swatch:hover {
    border-color: #999 !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.wapf-modal-body .wapf-swatch.wapf-checked {
    border-color: #000 !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.wapf-modal-body .wapf-swatch.wapf-checked::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: #000;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    z-index: 10;
}

/* Swatch Image */
.wapf-modal-body .wapf-swatch .wapf-swatch-img,
.wapf-modal-body .wapf-swatch img {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 1;
    object-fit: cover;
}

/* Swatch Label */
.wapf-modal-body .wapf-swatch .wapf-swatch-label {
    padding: 12px 14px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #333;
    text-transform: none;
    letter-spacing: 0.3px;
    background: #fafafa;
    border-top: 1px solid #f0f0f0;
    line-height: 1.3;
}

.wapf-modal-body .wapf-swatch.wapf-checked .wapf-swatch-label {
    background: #000;
    color: #fff;
    border-top-color: #000;
}

/* Pricing Hint on Swatches */
.wapf-modal-body .wapf-swatch .wapf-pricing-hint {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: #27ae60;
    margin-top: 4px;
}

.wapf-modal-body .wapf-swatch.wapf-checked .wapf-pricing-hint {
    color: #a8e6cf;
}

/* ============================================
   MULTI-SELECT SWATCHES (Checkboxes style)
   ============================================ */

.wapf-modal-body .wapf-field-container[data-field-type="multi-image-swatch"] .wapf-swatch.wapf-checked::after {
    content: '✓';
    background: #27ae60;
}

/* ============================================
   CLONE/REPEAT BUTTONS
   ============================================ */

.wapf-modal-body .wapf-clone-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px dashed #e5e5e5;
}

.wapf-modal-body .wapf-add-clone,
.wapf-modal-body .wapf-remove-clone {
    padding: 14px 24px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.2px;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid;
}

.wapf-modal-body .wapf-add-clone {
    background: #000;
    color: #fff;
    border-color: #000;
}

.wapf-modal-body .wapf-add-clone:hover {
    background: #333;
    border-color: #333;
}

.wapf-modal-body .wapf-remove-clone {
    background: #fff;
    color: #e74c3c;
    border-color: #e74c3c;
}

.wapf-modal-body .wapf-remove-clone:hover {
    background: #e74c3c;
    color: #fff;
}

/* Clone Instance Wrapper */
.wapf-modal-body .wapf-clone-instance {
    position: relative;
    background: #f8f9fa;
    border: 2px solid #e5e5e5;
    border-radius: 0;
    padding: 24px;
    margin-bottom: 20px;
}

.wapf-modal-body .wapf-clone-instance::before {
    content: attr(data-clone-index);
    position: absolute;
    top: -12px;
    left: 20px;
    background: #000;
    color: #fff;
    padding: 4px 16px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

/* ============================================
   OUTSIDE MODAL FIELD (Color Palette)
   ============================================ */

.wapf-outside-modal-field {
    margin-bottom: 24px;
}

.wapf-outside-modal-field .wapf-field-label label {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    letter-spacing: 0.2px;
    margin-bottom: 8px;
    display: block;
}

.wapf-outside-modal-field .wapf-field-description {
    font-size: 13px;
    color: #666;
    margin-bottom: 16px;
}

.wapf-outside-modal-field .wapf-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.wapf-outside-modal-field .wapf-swatch {
    width: 100%;
    height: 120px;
    border-radius: 0px !important;
    overflow: hidden;
    transition: all 0.25s ease;
    cursor: pointer;
    object-fit: contain;
}

.wapf-outside-modal-field .wapf-swatch:hover {
    border-color: #999 !important;
    transform: scale(1.1);
}

.wapf-outside-modal-field .wapf-swatch.wapf-checked {
    border-color: #000 !important;
    box-shadow: 0 0 0 3px #fff, 0 0 0 5px #000;
    transform: scale(1.1);
}

.wapf-outside-modal-field .wapf-swatch img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0px;
}

.wapf-outside-modal-field .wapf-swatch .wapf-swatch-label {
    display: none;
}

/* ============================================
   PRODUCT TOTALS
   ============================================ */

.wapf-product-totals {
    background: #f8f9fa;
    border: 0px;
    padding: 20px 24px;
    margin-top: 24px;
}

.wapf-product-totals .wapf-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 14px;
}

.wapf-product-totals .wapf-total-row.wapf-grand-total {
    border-top: 2px solid #000;
    margin-top: 12px;
    padding-top: 16px;
    font-size: 18px;
    font-weight: 700;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
    .wapf-modal-body .wapf-swatches {
        gap: 10px;
    }

    .wapf-modal-body .wapf-swatch {
        min-width: 100px;
        flex: 1 1 calc(50% - 10px);
        max-width: calc(50% - 5px);
    }

    .wapf-field-container[data-field-type="section"] .wapf-field-label {
        padding: 16px 20px;
    }

    .wapf-field-container[data-field-type="section"] .wapf-field-label label {
        font-size: 14px !important;
        letter-spacing: 0.2px !important;
    }

    .wapf-field-container[data-field-type="section"] .wapf-field-description {
        padding: 12px 20px;
        font-size: 12px;
    }

    .wapf-outside-modal-field .wapf-swatch {
        width: 50px;
        height: 50px;
    }

    .wapf-modal-body .wapf-clone-actions {
        flex-direction: column;
    }

    .wapf-modal-body .wapf-add-clone,
    .wapf-modal-body .wapf-remove-clone {
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .wapf-modal-body .wapf-swatch {
        flex: 1 1 100%;
        max-width: 100%;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */

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

.wapf-field-container {
    animation: fadeInUp 0.3s ease forwards;
}

.wapf-field-container:nth-child(1) { animation-delay: 0.05s; }
.wapf-field-container:nth-child(2) { animation-delay: 0.1s; }
.wapf-field-container:nth-child(3) { animation-delay: 0.15s; }
.wapf-field-container:nth-child(4) { animation-delay: 0.2s; }
.wapf-field-container:nth-child(5) { animation-delay: 0.25s; }
.wapf-field-container:nth-child(6) { animation-delay: 0.3s; }
.wapf-field-container:nth-child(7) { animation-delay: 0.35s; }
.wapf-field-container:nth-child(8) { animation-delay: 0.4s; }

/* ============================================
   SECTION VISIBILITY FIX
   ============================================ */

/* Ensure section containers are visible */
.wapf-field-container[data-field-type="section"] {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Section wrapper styling */
.wapf-section-wrap {
    display: block !important;
}
