/* ==========================================================================
   BUTTON FORMS POPUP STYLES
   Matches the Models Showcase popover styling
   All class names and keyframes prefixed to avoid conflicts
   ========================================================================== */

/* Popup Overlay - Hidden by default, shown with popup-open class */
.resolutum-form-popup-overlay {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 2147483647 !important; /* Maximum z-index value */
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.resolutum-form-popup-overlay.popup-open {
    display: flex !important;
    animation: resolutumPopupFadeIn 0.3s ease-out;
}

.resolutum-form-popup-overlay.closing {
    animation: resolutumPopupFadeOut 0.3s ease-out forwards;
}

@keyframes resolutumPopupFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes resolutumPopupFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes resolutumPopupSlideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Popup Container */
.resolutum-form-popup-container {
    position: relative;
    background: #FFFFFF;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    z-index: 2;
    animation: resolutumPopupSlideUp 0.3s ease-out;
}

/* Close Button - Matches showcase style */
.resolutum-form-popup-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    color: #000000;
    z-index: 10;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding: 0;
}

.resolutum-form-popup-close:hover {
    background: #FFFFFF;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   MODEL-APPLICABLE POPUP STYLES (with image header like showcase)
   ========================================================================== */

.resolutum-popup-inner {
    display: flex;
    flex-direction: column;
}

.resolutum-popup-image {
    width: 100%;
    height: 175px;
    background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.resolutum-popup-image img {
    width: 100%;
    height: 90%;
    object-fit: contain;
    filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.15));
}

.resolutum-popup-form {
    background: #FFFFFF;
    display: flex;
    flex-direction: column;
}

.resolutum-popup-form > * {
    padding-left: var(--wp--preset--spacing--50, 40px);
    padding-right: var(--wp--preset--spacing--50, 40px);
}

.resolutum-popup-form > form {
    padding: var(--wp--preset--spacing--50, 40px) !important;
    margin: 0 !important;
}

.resolutum-popup-form > *:first-child {
    padding-top: var(--wp--preset--spacing--50, 40px);
}

.resolutum-popup-form > *:last-child {
    padding-bottom: var(--wp--preset--spacing--50, 40px);
}

.resolutum-popup-form h3 {
    margin-top: 0;
    margin-bottom: 0px;
    font-size: var(--wp--preset--font-size--x-large, 1.75rem);
    font-weight: 600;
    text-transform: uppercase;
    color: #1a1a1a;
}

/* ==========================================================================
   STANDARD POPUP STYLES (without model context)
   ========================================================================== */

.resolutum-form-popup-overlay:not(.has-model-context) .resolutum-form-popup-container {
    border-radius: 16px;
}

/* Popup Header */
.resolutum-form-popup-header {
    padding: var(--wp--preset--spacing--40, 1.5rem) var(--wp--preset--spacing--40, 1.5rem) var(--wp--preset--spacing--20, 1rem);
    border-bottom: 1px solid var(--wp--preset--color--contrast-2, #eee);
    margin-right: 50px;
}

.resolutum-form-popup-title {
    margin: 0;
    font-size: var(--wp--preset--font-size--large, 1.25rem);
    font-weight: 600;
    color: var(--wp--preset--color--contrast, #000);
    line-height: 1.4;
}

/* Popup Content */
.resolutum-form-popup-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--wp--preset--spacing--40, 1.5rem);
}

/* ==========================================================================
   FORMINATOR FORM STYLES WITHIN POPUP
   ========================================================================== */

.resolutum-form-popup-overlay .forminator-form,
.resolutum-form-popup-overlay .forminator-custom-form {
    margin: 0;
}

.resolutum-form-popup-overlay .forminator-field {
    margin-bottom: var(--wp--preset--spacing--30, 1rem);
}

/* Force Forminator forms to be visible when popup is open */
.resolutum-form-popup-overlay.popup-open .forminator-custom-form,
.resolutum-form-popup-overlay.popup-open .forminator-ui,
.resolutum-form-popup-overlay.popup-open .forminator-form,
.resolutum-form-popup-overlay.popup-open .forminator-design--default {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Ensure form wrapper is visible */
.resolutum-form-popup-overlay.popup-open .resolutum-popup-form,
.resolutum-form-popup-overlay.popup-open .resolutum-form-popup-content {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* ==========================================================================
   MANUALLY RENDERED FORM STYLES (Fallback when Forminator doesn't render)
   ========================================================================== */

.resolutum-form-popup-overlay .forminator-field {
    margin-bottom: 1.25rem;
}

.resolutum-form-popup-overlay .forminator-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
    font-size: 0.9rem;
}

.resolutum-form-popup-overlay .forminator-required {
    color: #dc3545;
}

.resolutum-form-popup-overlay .forminator-input,
.resolutum-form-popup-overlay .forminator-textarea,
.resolutum-form-popup-overlay .forminator-select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #333;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    box-sizing: border-box;
}

.resolutum-form-popup-overlay .forminator-input:focus,
.resolutum-form-popup-overlay .forminator-textarea:focus,
.resolutum-form-popup-overlay .forminator-select:focus {
    border-color: #0073aa;
    outline: 0;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.15);
}

.resolutum-form-popup-overlay .forminator-textarea {
    min-height: 120px;
    resize: vertical;
}

.resolutum-form-popup-overlay .forminator-checkbox,
.resolutum-form-popup-overlay .forminator-radio {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    cursor: pointer;
}

.resolutum-form-popup-overlay .forminator-checkbox input,
.resolutum-form-popup-overlay .forminator-radio input {
    margin-right: 0.5rem;
    width: auto;
}

.resolutum-form-popup-overlay .forminator-submit {
    margin-top: 1.5rem;
}

.resolutum-form-popup-overlay .forminator-button-submit {
    display: inline-block;
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    color: #fff;
    background-color: #0073aa;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
    width: 100%;
}

.resolutum-form-popup-overlay .forminator-button-submit:hover {
    background-color: #005a87;
}

.resolutum-form-popup-overlay .forminator-button-submit:focus {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.25);
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

@media (max-width: 1024px) {
    .resolutum-form-popup-close {
        top: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 768px) {
    .resolutum-form-popup-overlay {
        padding: 10px;
    }

    .resolutum-form-popup-container {
        max-width: 100%;
        max-height: 95vh;
    }

    .resolutum-form-popup-header {
        padding: var(--wp--preset--spacing--30, 1rem);
    }

    .resolutum-form-popup-content {
        padding: var(--wp--preset--spacing--30, 1rem);
    }
}

@media (max-width: 640px) {
    .resolutum-form-popup-overlay {
        padding: 10px;
    }

    .resolutum-form-popup-container {
        max-height: 95vh;
    }

    .resolutum-popup-form > * {
        padding-left: var(--wp--preset--spacing--30, 20px);
        padding-right: var(--wp--preset--spacing--30, 20px);
    }

    .resolutum-popup-form > form {
        padding: var(--wp--preset--spacing--30, 20px) !important;
    }

    .resolutum-popup-form > *:first-child {
        padding-top: var(--wp--preset--spacing--30, 20px);
    }

    .resolutum-popup-form > *:last-child {
        padding-bottom: var(--wp--preset--spacing--30, 20px);
    }

    .resolutum-popup-form h3 {
        font-size: var(--wp--preset--font-size--large, 1.5rem);
    }

    .resolutum-form-popup-close {
        top: 10px;
        right: 10px;
        font-size: 28px;
        width: 36px;
        height: 36px;
    }
}

/* Print Styles */
@media print {
    .resolutum-form-popup-overlay {
        display: none !important;
    }
}

/* Button cursor */
.resolutum-form-button {
    cursor: pointer;
}

/* ==========================================================================
   MODEL SELECTOR STYLES
   ========================================================================== */

.resolutum-model-selector {
    margin-bottom: var(--wp--preset--spacing--40, 1.5rem);
    padding: var(--wp--preset--spacing--30, 1rem);
    background: #f9f9f9;
    border-radius: 8px;
    border-left: 4px solid var(--wp--preset--color--accent-1, #e10012);
}

.resolutum-model-selector label {
    display: block;
    font-weight: 600;
    margin-bottom: var(--wp--preset--spacing--20, 0.5rem);
    color: #1a1a1a;
}

.resolutum-model-dropdown {
    width: 100%;
    padding: 12px 40px 12px 12px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    cursor: pointer;
}

.resolutum-model-dropdown:focus {
    outline: none;
    border-color: var(--wp--preset--color--accent-1, #e10012);
    box-shadow: 0 0 0 2px rgba(225, 0, 18, 0.1);
}

/* ==========================================================================
   FINANCE CALCULATOR STYLES (in popup)
   ========================================================================== */

.resolutum-popup-calculator {
    background: #f5f7fa;
    padding: var(--wp--preset--spacing--40, 1.5rem);
    border-radius: 8px;
    margin-bottom: var(--wp--preset--spacing--40, 1.5rem);
}

.resolutum-popup-calculator .calculator-sliders {
    margin-bottom: var(--wp--preset--spacing--30, 1rem);
}

.resolutum-popup-calculator .slider-group {
    margin-bottom: var(--wp--preset--spacing--30, 1rem);
}

.resolutum-popup-calculator .slider-group.retail-hidden {
    display: none;
}

.resolutum-popup-calculator .slider-group label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: #333;
    margin-bottom: 4px;
}

.resolutum-popup-calculator .slider-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
}

.resolutum-popup-calculator .slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--wp--preset--color--accent-1, #e10012);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.resolutum-popup-calculator .slider-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--wp--preset--color--accent-1, #e10012);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.resolutum-popup-calculator .slider-value {
    display: block;
    font-size: 14px;
    color: #666;
    margin-top: 4px;
}

.resolutum-popup-calculator .calculator-results {
    background: #fff;
    padding: var(--wp--preset--spacing--30, 1rem);
    border-radius: 6px;
    border: 2px solid var(--wp--preset--color--accent-1, #e10012);
}

.resolutum-popup-calculator .result-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.resolutum-popup-calculator .result-row:last-child {
    border-bottom: none;
}

.resolutum-popup-calculator .result-label {
    font-weight: 500;
    color: #666;
}

.resolutum-popup-calculator .result-value {
    font-weight: 700;
    color: #1a1a1a;
}

/* Wider popup when calculator is present */
.has-finance-calculator .resolutum-form-popup-container {
    max-width: 700px;
}
