/* ========================================
   ELMFC FRONTEND STYLES v7.3.5
   ======================================== */

/* === Popup Overlay === */
.elmfc-popup-overlay {
    position: fixed;
    top: 0; 
    left: 0; 
    right: 0; 
    bottom: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.elmfc-popup-overlay.active {
    display: flex;
    opacity: 1;
    visibility: visible;
}

/* ========================================
   SHARED CONTAINER STYLES (Popup & Inline)
   ======================================== */

/* Popup content and inline wrapper share same base styles */
.elmfc-popup-content,
.elmfc-inline-wrapper {
    background: #fff;
    padding: 0;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25), 0 0 1px rgba(0,0,0,0.1);
    box-sizing: border-box;
    display: block;
}

/* Popup specific positioning */
.elmfc-popup-content {
    width: 90%;
    max-width: 500px;
    min-width: 320px;
    margin: 0 30px;
    position: relative;
    transform: scale(0.9) translateY(-10px);
    transition: transform 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}

.elmfc-popup-overlay.active .elmfc-popup-content {
    transform: scale(1) translateY(0);
}

/* Inline wrapper specific */
.elmfc-inline-wrapper {
    margin: 0;
    width: 100%;
    max-width: none;
    border: 1px solid #e5e7eb;
}

/* Container width (full width) */
.elmfc-inline-wrapper.elmfc-width-container {
    width: 100% !important;
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-bottom: 30px;
    padding-bottom: 30px;
}

/* Center aligned forms with specific max-widths */
.elmfc-inline-wrapper.elmfc-width-narrow,
.elmfc-inline-wrapper.elmfc-width-default,
.elmfc-inline-wrapper.elmfc-width-wide {
    margin-left: auto;
    margin-right: auto;
    margin-top: 25px;
    margin-bottom: 25px;
}

/* Width options */
.elmfc-inline-wrapper.elmfc-width-narrow {
    max-width: 450px;
}

.elmfc-inline-wrapper.elmfc-width-default {
    max-width: 720px;
}

.elmfc-inline-wrapper.elmfc-width-wide {
    max-width: 1080px;
}

/* Custom Scrollbar (popup only) */
.elmfc-popup-content::-webkit-scrollbar {
    width: 8px;
}

.elmfc-popup-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.elmfc-popup-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

.elmfc-popup-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ========================================
   SHARED HEADER STYLES (Popup & Inline)
   ======================================== */

.elmfc-popup-header,
.elmfc-inline-header {
    margin: 0;
    padding: 20px 30px;
    background: linear-gradient(to bottom, #f8f9fa, #f0f1f2);
    border-bottom: 1px solid #e0e0e0;
    border-radius: 10px 10px 0 0;
    font-weight: 600;
    font-size: 1.25rem;
    color: #2c3e50;
    user-select: none;
}

/* Popup header can be dragged */
.elmfc-popup-header {
    cursor: move;
}

/* === Close Button (Popup only) === */
.elmfc-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    font-size: 24px;
    font-weight: 300;
    line-height: 0;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    z-index: 10;
    color: #666;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 0;
}

.elmfc-popup-close:hover {
    background: #fff;
    color: #d63638;
    transform: rotate(90deg);
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}

/* ========================================
   SHARED FORM STYLES (Popup & Inline)
   ======================================== */

.elmfc-form {
    margin: 0;
    padding: 30px;
    box-sizing: border-box;
}

/* === Messages === */
.elmfc-response {
    margin-top: 15px;
    margin-bottom: 15px;
    order: 999;
}

.elmfc-success, 
.elmfc-error {
    font-weight: 600;
    font-size: 15px;
    padding: 13px 18px;
    border-radius: 7px;
    margin: 0 0 18px 0;
    animation: fadeIn 0.4s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.elmfc-success {
    color: #0f5132;
    background: #d4edda;
    border: 1px solid #badbcc;
}

.elmfc-error {
    color: #842029;
    background: #f8d7da;
    border: 1px solid #f1aeb5;
}

@keyframes fadeIn { 
    from {
        opacity: 0; 
        transform: translateY(-12px) scale(0.98);
    } 
    to {
        opacity: 1; 
        transform: translateY(0) scale(1);
    } 
}

/* === Form Fields === */
.elmfc-form label {
    display: block;
    margin-bottom: 7px;
    margin-top: 14px;
    font-weight: 500;
    font-size: 0.95rem;
    color: #2c3e50;
}

.elmfc-form label:first-child {
    margin-top: 0;
}

/* === Input Fields === */
.elmfc-form input[type="text"],
.elmfc-form input[type="email"],
.elmfc-form input[type="tel"],
.elmfc-form input[type="number"],
.elmfc-form input[type="url"],
.elmfc-form input[type="password"],
.elmfc-form input[type="date"],
.elmfc-form input[type="time"],
.elmfc-form textarea,
.elmfc-form select {
    width: 100%;
    padding: 11px 13px;
    border: 1.5px solid #d1d5db;
    border-radius: 7px;
    font-size: 15px;
    font-family: inherit;
    line-height: 1.5;
    transition: all 0.2s ease;
    box-sizing: border-box;
    background-color: #fff;
    color: #2c3e50;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

/* Remove spinner buttons for number inputs */
.elmfc-form input[type="number"]::-webkit-outer-spin-button,
.elmfc-form input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Hover state */
.elmfc-form input:hover:not(:focus):not(:disabled),
.elmfc-form textarea:hover:not(:focus):not(:disabled),
.elmfc-form select:hover:not(:focus):not(:disabled) {
    border-color: #b0b5bc;
}

/* === Focus States === */
.elmfc-form input:focus,
.elmfc-form textarea:focus,
.elmfc-form select:focus {
    outline: none;
    border-color: #0073aa;
    background-color: #fcfdfe;
    box-shadow: 0 0 0 3px rgba(0,115,170,0.12);
}

/* === Invalid/Required States === */
.elmfc-form [required]:invalid {
    border-color: #d1d5db;
}

.elmfc-form input[required]:focus:invalid,
.elmfc-form textarea[required]:focus:invalid,
.elmfc-form select[required]:focus:invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220,53,69,0.12);
}

/* === Placeholder Styling === */
.elmfc-form input::placeholder,
.elmfc-form textarea::placeholder {
    color: #9ca3af;
    opacity: 1;
}

.elmfc-form input:focus::placeholder,
.elmfc-form textarea:focus::placeholder {
    color: #c7cdd4;
}

/* === Textarea === */
.elmfc-form textarea {
    resize: vertical;
    min-height: 110px;
    max-height: 400px;
}

/* === Select Dropdown === */
.elmfc-form select {
    cursor: pointer;
    padding-right: 35px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 13 13'%3E%3Cpath fill='%232c3e50' d='M6.5 9.5L1.5 4.5h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 13px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* For IE10+ */
.elmfc-form select::-ms-expand {
    display: none;
}

/* Firefox specific fix */
.elmfc-form select:-moz-focusring {
    color: transparent;
    text-shadow: 0 0 0 #2c3e50;
}

/* === Checkboxes and Radio Buttons === */
.elmfc-form input[type="checkbox"],
.elmfc-form input[type="radio"] {
    width: 17px;
    height: 17px;
    margin-right: 8px;
    vertical-align: middle;
    cursor: pointer;
    accent-color: #0073aa;
}

.elmfc-form input[type="checkbox"] + label,
.elmfc-form input[type="radio"] + label {
    display: inline;
    margin-top: 0;
    margin-left: 4px;
    font-weight: normal;
    cursor: pointer;
}

/* === Disabled State === */
.elmfc-form input:disabled,
.elmfc-form textarea:disabled,
.elmfc-form select:disabled {
    background-color: #f7f8f9;
    border-color: #e1e4e8;
    color: #9ca3af;
    cursor: not-allowed;
    opacity: 0.65;
}

/* === Buttons Container === */
.elmfc-form .elmfc-buttons {
    display: flex;
    gap: 12px;
    margin-top: 22px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* === Custom Plugin Buttons (when enabled) === */
.elmfc-btn {
    background: linear-gradient(135deg, #0073aa, #005c87);
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    padding: 13px 28px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,115,170,0.25);
    transition: all 0.2s ease;
    min-height: 48px;
    min-width: 110px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-family: inherit;
    line-height: 1.4;
}

.elmfc-btn:hover {
    background: linear-gradient(135deg, #0096dd, #006fa8);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,115,170,0.3);
}

.elmfc-btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 3px 8px rgba(0,115,170,0.25);
}

.elmfc-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Cancel Button (Custom Style) */
.elmfc-cancel.elmfc-btn {
    background: #fff;
    color: #495057;
    border: 1.5px solid #d1d5db;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.elmfc-cancel.elmfc-btn:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}

.elmfc-cancel.elmfc-btn:active {
    transform: translateY(0) scale(0.98);
}

/* === Theme Buttons (default - wp-block-button__link class) === */
.elmfc-popup-wrapper .wp-block-button__link,
.elmfc-form .wp-block-button__link {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    line-height: 1.4;
    padding: 10px 20px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #f0f0f0;
    color: #333;
    font-size: 14px;
    transition: all 0.2s ease;
    min-height: 40px;
    box-sizing: border-box;
}

.elmfc-form .wp-block-button__link:hover {
    background: #e0e0e0;
    border-color: #999;
}

.elmfc-form .wp-block-button__link:active {
    transform: scale(0.98);
}

.elmfc-form .wp-block-button__link:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ========================================
   PAGE BUILDER OVERRIDES
   ======================================== */

.elementor-widget-container > .elmfc-inline-wrapper.elmfc-width-container,
.elementor-column > .elmfc-inline-wrapper.elmfc-width-container,
.fl-module-content > .elmfc-inline-wrapper.elmfc-width-container,
.et_pb_module > .elmfc-inline-wrapper.elmfc-width-container,
.wp-block-column > .elmfc-inline-wrapper.elmfc-width-container,
[class*="container"] > .elmfc-inline-wrapper.elmfc-width-container,
[class*="row"] > .elmfc-inline-wrapper.elmfc-width-container,
[class*="col"] > .elmfc-inline-wrapper.elmfc-width-container {
    width: 100% !important;
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* === Required Indicator === */
.elmfc-form .required {
    color: #dc3545;
    font-weight: bold;
    margin-left: 3px;
}

/* === Form Field Groups === */
.elmfc-form-fields {
    margin: 0;
    padding: 0;
}

.elmfc-form-fields > p {
    margin: 0 !important;
}

.elmfc-form-fields > p:first-child {
    margin-top: 0 !important;
}

/* === Input Field Sizing Options === */
.elmfc-form input.short-input {
    max-width: 150px;
}

.elmfc-form input.medium-input {
    max-width: 300px;
}

.elmfc-form input[type="number"].small {
    max-width: 120px;
}

/* ========================================
   CAPTCHA STYLING
   ======================================== */

.elmfc-captcha {
    width: 100%;
    margin: 15px 0;
    padding: 12px;
    background: #f8f9fa;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    box-sizing: border-box;
}

.elmfc-captcha label {
    display: block !important;
    margin-bottom: 8px !important;
    margin-top: 0 !important;
    font-weight: 500;
    font-size: 0.95rem;
    color: #2c3e50;
}

.elmfc-captcha input[type="number"] {
    width: 100%;
    max-width: 150px;
}

/* ========================================
   FIELDSET & LEGEND STYLING
   ======================================== */

.elmfc-form fieldset {
    margin: 18px 0;
    padding: 20px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    background: #fafbfc;
    box-sizing: border-box;
}

.elmfc-form fieldset:first-child {
    margin-top: 0;
}

.elmfc-form fieldset:last-of-type {
    margin-bottom: 0;
}

.elmfc-form legend {
    padding: 0 12px;
    font-weight: 600;
    font-size: 1.05rem;
    color: #2c3e50;
    background: #fff;
    border-radius: 4px;
    margin-bottom: 0;
}

.elmfc-form fieldset label {
    margin-top: 12px !important;
    margin-bottom: 6px !important;
}

.elmfc-form fieldset label:first-of-type {
    margin-top: 0 !important;
}

/* Nested fieldsets */
.elmfc-form fieldset fieldset {
    background: #fff;
    border-color: #e5e7eb;
    margin: 15px 0;
    padding: 15px;
}

.elmfc-form fieldset fieldset legend {
    font-size: 0.95rem;
    background: #fafbfc;
}

/* Remove excessive paragraph margins in fieldsets */
.elmfc-form fieldset p {
    margin: 0 !important;
}

/* ========================================
   IMPROVED FORM SPACING & LAYOUT
   ======================================== */

/* Remove spacing from paragraphs containing only hidden inputs */
.elmfc-form > p:first-child,
.elmfc-form > p:has(> input[type="hidden"]) {
    margin: 0 !important;
    padding: 0 !important;
    line-height: 0 !important;
}

/* Remove spacing from empty paragraphs */
.elmfc-form p:empty,
.elmfc-form-fields > p:empty {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Hide BR tags in configuration paragraphs */
.elmfc-form > p:first-child br,
.elmfc-form p:has(input[type="hidden"]) br {
    display: none !important;
}

/* First visible fieldset should have no margin */
.elmfc-form-fields > fieldset:first-of-type,
.elmfc-form > div > fieldset:first-child {
    margin-top: 0 !important;
}

/* Input/textarea/select spacing */
.elmfc-form-fields input,
.elmfc-form-fields textarea,
.elmfc-form-fields select {
    margin-bottom: 12px;
}

.elmfc-form-fields input:last-child,
.elmfc-form-fields textarea:last-child,
.elmfc-form-fields select:last-child {
    margin-bottom: 0;
}

/* Radio buttons styling */
.radio-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    padding: 12px 15px;
    margin: 8px 0 !important;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
}

.radio-label:hover {
    border-color: #0073aa;
    background: #f8fcff;
}

.radio-label:first-of-type {
    margin-top: 0 !important;
}

.radio-label:last-of-type {
    margin-bottom: 0 !important;
}

.radio-label input[type="radio"] {
    margin: 0;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.radio-label input[type="radio"]:checked + span {
    font-weight: 600;
    color: #0073aa;
}

.radio-label span {
    flex: 1;
    line-height: 1.4;
}

/* Checkbox styling for terms */
.terms-container {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e1e8ed;
}

.checkbox-label {
    display: flex !important;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    margin: 0 !important;
}

.checkbox-label input[type="checkbox"] {
    margin: 0;
    margin-top: 3px;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.checkbox-label span {
    flex: 1;
    line-height: 1.6;
    font-size: 14px;
}

.checkbox-label a {
    color: #0073aa;
    text-decoration: underline;
    font-weight: 500;
}

.checkbox-label a:hover {
    color: #005c87;
}

/* Textarea optimal height */
.elmfc-form textarea {
    min-height: 90px;
}

/* Better button container spacing */
.elmfc-form .elmfc-buttons {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

/* Consistent label spacing */
.elmfc-form label + input,
.elmfc-form label + textarea,
.elmfc-form label + select {
    margin-top: 0 !important;
}

/* Legend spacing fix */
.elmfc-form legend + label {
    margin-top: 0 !important;
}

.elmfc-form legend + .radio-label {
    margin-top: 0 !important;
}

/* ========================================
   RESPONSIVE STYLES
   ======================================== */

@media (max-width: 768px) {
    .elmfc-popup-content {
        width: 95%;
        margin: 0 10px;
    }
    
    .elmfc-form {
        padding: 25px;
    }
}

@media (max-width: 480px) {
    .elmfc-popup-content {
        margin: 0 12px;
        min-width: auto;
        max-height: 95vh;
        border-radius: 9px;
    }
    
    .elmfc-form {
        padding: 20px;
    }
    
    .elmfc-popup-header,
    .elmfc-inline-header {
        padding: 16px 20px;
        font-size: 1.1rem;
    }
    
    .elmfc-popup-close {
        top: 10px;
        right: 10px;
        width: 30px;
        height: 30px;
        font-size: 22px;
    }
    
    .elmfc-form .elmfc-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .elmfc-btn,
    .elmfc-form .wp-block-button__link {
        width: 100%;
    }
    
    .elmfc-form input[type="number"].small {
        max-width: 100%;
    }
    
    .elmfc-form fieldset {
        padding: 15px;
        margin: 15px 0;
    }
    
    .elmfc-form legend {
        font-size: 1rem;
        padding: 0 8px;
    }
    
    .radio-label {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .terms-container {
        padding: 12px;
    }
    
    .checkbox-label span {
        font-size: 13px;
    }
    
    /* Prevent iOS zoom */
    .elmfc-form input,
    .elmfc-form textarea,
    .elmfc-form select {
        font-size: 16px;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .elmfc-popup-overlay,
    .elmfc-popup-wrapper {
        display: none !important;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.elmfc-form input:focus-visible,
.elmfc-form textarea:focus-visible,
.elmfc-form select:focus-visible,
.elmfc-btn:focus-visible,
.elmfc-form .wp-block-button__link:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 3px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .elmfc-form input,
    .elmfc-form textarea,
    .elmfc-form select {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .elmfc-popup-overlay,
    .elmfc-popup-content,
    .elmfc-btn,
    .elmfc-success,
    .elmfc-error {
        transition: none;
        animation: none;
    }
}

/* ========================================
   FIX GUTENBERG PARAGRAPH SPACING DIFFERENCES
   ======================================== */

/* Target paragraphs inside fieldsets (Gutenberg wraps content in <p> tags) */
.elmfc-inline-wrapper .elmfc-form fieldset > p {
    margin: 0 !important;
    padding: 0 !important;
}

/* Labels inside paragraphs in inline forms */
.elmfc-inline-wrapper .elmfc-form fieldset > p > label {
    margin-top: 12px !important;
    margin-bottom: 6px !important;
    display: block;
}

.elmfc-inline-wrapper .elmfc-form fieldset > p:first-of-type > label {
    margin-top: 0 !important;
}

/* Inputs/textareas/selects inside paragraphs */
.elmfc-inline-wrapper .elmfc-form fieldset > p > input,
.elmfc-inline-wrapper .elmfc-form fieldset > p > textarea,
.elmfc-inline-wrapper .elmfc-form fieldset > p > select {
    margin-bottom: 0 !important;
}

/* Remove line breaks that Gutenberg adds */
.elmfc-inline-wrapper .elmfc-form fieldset > p > br {
    display: none !important;
}

/* Radio labels inside paragraphs */
.elmfc-inline-wrapper .elmfc-form fieldset > p > .radio-label {
    margin: 8px 0 !important;
}

.elmfc-inline-wrapper .elmfc-form fieldset > p:first-of-type > .radio-label:first-child {
    margin-top: 0 !important;
}

/* Terms container spacing */
.elmfc-inline-wrapper .terms-container {
    margin: 20px 0 !important;
}

/* Checkbox label inside paragraphs */
.elmfc-inline-wrapper .terms-container > p {
    margin: 0 !important;
}

.elmfc-inline-wrapper .terms-container .checkbox-label > br {
    display: none !important;
}