/**
 * Contact Popup Styles
 * Flat design with site colors
 */

/* ===== CSS Variables ===== */
:root {
    --vm-color-primary: var(--e-global-color-primary, #2A3140);
    --vm-color-secondary: var(--e-global-color-secondary, #FFFFFF);
    --vm-color-text: var(--e-global-color-text, #000000);
    --vm-color-accent: var(--e-global-color-accent, #D69600);
    --vm-color-light-bg: var(--e-global-color-823b90b, #F6F6EE);
}

/* ===== Trigger Button ===== */
.vm-popup-trigger,
.vm-popup-trigger-btn,
.vm-contact-popup-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--vm-color-accent);
    color: var(--vm-color-secondary);
    border: none;
    border-radius: 0;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    transition: background 0.3s, transform 0.2s;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    z-index: 10;
}

.vm-popup-trigger:hover,
.vm-popup-trigger-btn:hover,
.vm-contact-popup-trigger:hover {
    background: var(--vm-color-primary);
    transform: translateY(-2px);
}

.vm-popup-trigger:active,
.vm-popup-trigger-btn:active,
.vm-contact-popup-trigger:active {
    transform: translateY(0);
    opacity: 0.9;
}

.vm-trigger-icon {
    display: flex;
    align-items: center;
    pointer-events: none;
}

.vm-trigger-icon svg {
    fill: currentColor;
    pointer-events: none;
}

.vm-trigger-text {
    pointer-events: none;
}

/* Floating Button */
.vm-popup-floating {
    position: fixed;
    z-index: 9998;
    padding: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.vm-popup-floating .vm-trigger-text {
    display: none;
}

.vm-popup-floating .vm-trigger-icon svg {
    width: 24px;
    height: 24px;
}

.vm-floating-bottom-right {
    bottom: 20px;
    right: 20px;
}

.vm-floating-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Text Link */
.vm-popup-link {
    background: none;
    padding: 0;
    color: var(--vm-color-accent);
    text-decoration: underline;
}

.vm-popup-link:hover {
    background: none;
    color: var(--vm-color-primary);
    transform: none;
}

/* ===== Popup Overlay ===== */
.vm-popup-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    height: 100vh !important;
    height: 100dvh !important; /* Dynamic viewport height for mobile */
    background: rgba(42, 49, 64, 0.9) !important;
    z-index: 2147483647 !important; /* Maximum z-index */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px !important;
    box-sizing: border-box !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    /* Fix for iOS */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.vm-popup-overlay.vm-popup-active {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

/* Prevent body scroll when popup is open */
body.vm-popup-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    top: 0 !important;
    left: 0 !important;
}

/* Popup content should be above overlay */
.vm-popup-content {
    position: relative;
    z-index: 1;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ===== Popup Content ===== */
.vm-popup-content {
    background: var(--vm-color-secondary);
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    transform: translateY(-20px);
    transition: transform 0.3s;
    direction: rtl;
}

.vm-popup-overlay.vm-popup-active .vm-popup-content {
    transform: translateY(0);
}

/* ===== Popup Header ===== */
.vm-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 24px;
    background: var(--vm-color-primary);
    color: var(--vm-color-secondary);
}

.vm-popup-header-content {
    flex: 1;
}

.vm-popup-title {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 700;
}

.vm-popup-subtitle {
    margin: 0;
    font-size: 14px;
    opacity: 0.85;
}

.vm-popup-close {
    background: none !important;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0;
    margin-right: -8px;
    margin-top: -8px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.vm-popup-close:hover {
    opacity: 1;
    background: none !important;
}

/* ===== Popup Form ===== */
.vm-popup-form {
    padding: 24px;
}

.vm-popup-context {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--vm-color-light-bg);
    margin-bottom: 20px;
    font-size: 14px;
}

.vm-context-label {
    color: var(--vm-color-text);
    opacity: 0.7;
}

.vm-context-value {
    font-weight: 600;
    color: var(--vm-color-primary);
}

.vm-popup-field {
    margin-bottom: 16px;
}

.vm-popup-field label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--vm-color-primary);
    margin-bottom: 8px;
}

.vm-popup-field input,
.vm-popup-field textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid rgba(42, 49, 64, 0.15);
    border-radius: 0;
    font-size: 15px;
    font-family: inherit;
    background: var(--vm-color-secondary);
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.vm-popup-field input:focus,
.vm-popup-field textarea:focus {
    outline: none;
    border-color: var(--vm-color-accent);
    box-shadow: 0 0 0 3px rgba(214, 150, 0, 0.15);
}

.vm-popup-field input::placeholder,
.vm-popup-field textarea::placeholder {
    color: rgba(42, 49, 64, 0.4);
}

.vm-popup-field textarea {
    resize: vertical;
    min-height: 80px;
}

/* ===== Privacy Checkbox ===== */
.vm-popup-privacy {
    margin-top: 20px;
}

.vm-privacy-label {
    display: flex !important;
    align-items: flex-start;
    gap: 10px;
    font-weight: 400 !important;
    cursor: pointer;
    line-height: 1.5;
}

.vm-privacy-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 2px 0 0 0;
    flex-shrink: 0;
    accent-color: var(--vm-color-accent);
    cursor: pointer;
}

.vm-privacy-label a {
    color: var(--vm-color-accent);
    text-decoration: underline;
}

.vm-privacy-label a:hover {
    color: var(--vm-color-primary);
}

/* ===== Submit Button ===== */
.vm-popup-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 24px;
    background: var(--vm-color-accent);
    color: var(--vm-color-secondary);
    border: none;
    border-radius: 0;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.3s;
    margin-top: 24px;
}

.vm-popup-submit:hover {
    background: var(--vm-color-primary);
}

.vm-popup-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Spinner */
.vm-spinner {
    animation: vm-spin 1s linear infinite;
}

@keyframes vm-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===== Success/Error Message ===== */
.vm-popup-message {
    padding: 16px;
    text-align: center;
    font-size: 15px;
    margin-top: 16px;
}

.vm-popup-message.vm-success {
    background: #f8f9fa;
    color: #2A3140;
    border-right: 4px solid #D69600;
}

.vm-popup-message.vm-error {
    background: #ffebee;
    color: #c62828;
    border-right: 4px solid #c62828;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .vm-popup-overlay {
        padding: 10px;
        align-items: flex-start;
        padding-top: 40px;
    }
    
    .vm-popup-content {
        max-width: 100%;
        max-height: calc(100vh - 80px);
        border-radius: 8px;
    }
    
    .vm-popup-header {
        padding: 16px;
    }
    
    .vm-popup-title {
        font-size: 18px;
    }
    
    .vm-popup-form {
        padding: 16px;
    }
    
    .vm-popup-field input,
    .vm-popup-field textarea {
        font-size: 16px; /* Prevents iOS zoom on focus */
        padding: 14px;
    }
    
    .vm-popup-submit {
        padding: 16px;
        min-height: 50px;
    }
    
    .vm-popup-close {
        padding: 10px;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .vm-popup-floating {
        bottom: 15px;
    }
    
    .vm-floating-bottom-right {
        right: 15px;
    }
    
    .vm-floating-bottom-left {
        left: 15px;
    }
    
    .vm-popup-trigger {
        min-height: 44px;
        padding: 12px 20px;
    }
}

/* ===== Mobile-specific touch fixes ===== */
@media (hover: none) and (pointer: coarse) {
    .vm-popup-trigger,
    .vm-popup-trigger-btn,
    .vm-contact-popup-trigger,
    .vm-popup-close,
    .vm-popup-submit {
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    }
    
    .vm-popup-trigger:active,
    .vm-popup-trigger-btn:active,
    .vm-contact-popup-trigger:active {
        opacity: 0.8;
        transform: scale(0.98);
    }
}

/* Ensure buttons are always clickable */
.vm-popup-trigger,
.vm-popup-trigger-btn,
.vm-contact-popup-trigger,
.vm-popup-close {
    pointer-events: auto !important;
}

/* Fix for Elementor header/sticky issues */
.elementor-element .vm-popup-trigger,
.elementor-element .vm-popup-trigger-btn,
.elementor-element .vm-contact-popup-trigger,
.elementor-widget .vm-popup-trigger,
.elementor-widget .vm-popup-trigger-btn,
.elementor-widget .vm-contact-popup-trigger {
    pointer-events: auto !important;
    position: relative;
    z-index: 10;
}

/* Hash link triggers */
a[href="#contact-popup"],
a[href="#vm-contact-popup"],
a[href="#popup"] {
    cursor: pointer;
}

/* ===== RTL Adjustments ===== */
[dir="rtl"] .vm-popup-content,
.vm-popup-content {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .vm-popup-field input[type="tel"],
[dir="rtl"] .vm-popup-field input[type="email"],
.vm-popup-field input[type="tel"],
.vm-popup-field input[type="email"] {
    direction: ltr;
    text-align: right;
}
