/* === 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;
}

/* === Popup Content === */
.elmfc-popup-content {
    background: #fff;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    min-width: 320px;
    margin: 0 30px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25), 0 0 1px rgba(0,0,0,0.1);
    transform: scale(0.9) translateY(-10px);
    transition: transform 0.3s ease;
    box-sizing: border-box;
    max-height: 90vh;
    overflow-y: auto;
}

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

/* Custom Scrollbar */
.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;
}

/* === Draggable Header === */
.elmfc-popup-header {
    cursor: move;
    margin: -30px -30px 20px;
    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;
}

/* === Close Button === */
.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);
}

/* === Messages === */
.elmfc-response {
    margin-top: 15px;
    margin-bottom: 15px;
    order: 999; /* Ensures it appears after captcha in flex layouts */
}

.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 {
    margin: 0;
}

.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;
}

.elmfc-form-fields label {
    padding-top: 15px;
}

/* === 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;
}

/* === 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) === */
/* Provide fallback styling that looks good if theme doesn't style buttons */
.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;
}

/* If theme has its own .wp-block-button__link styles, they will override these fallbacks */

/* === Inline Form Wrapper === */
.elmfc-inline-wrapper {
    margin: 25px 0;
    padding: 32px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    border: 1px solid #e5e7eb;
}

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

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

.elmfc-form-fields > p {
    margin: 0 0 5px 0;
}

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

/* === 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 === */
.elmfc-captcha {
    margin-top: 15px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e1e8ed;
}

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

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

/* === Responsive === */
@media (max-width: 768px) {
    .elmfc-popup-content {
        width: 95%;
        margin: 0 10px;
    }
    
    .elmfc-inline-wrapper {
        padding: 25px;
    }
}

@media (max-width: 480px) {
    .elmfc-popup-content {
        padding: 20px;
        margin: 0 12px;
        min-width: auto;
        max-height: 95vh;
        border-radius: 9px;
    }
    
    .elmfc-popup-header {
        margin: -20px -20px 18px;
        padding: 16px 20px;
        font-size: 1.1rem;
        border-radius: 9px 9px 0 0;
    }
    
    .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-inline-wrapper {
        padding: 20px;
        margin: 20px 0;
    }
    
    .elmfc-form input[type="number"].small {
        max-width: 100%;
    }
    
    /* 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;
    }
}

/* elmfc.css - Add to bottom */
.elmfc-captcha {
    width: 100%;
    margin: 15px 0;
    padding: 12px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
}

.elmfc-captcha label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.elmfc-captcha input[type="number"] {
    width: 100%;
    max-width: 200px;
    padding: 10px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    transition: border 0.2s;
}

.elmfc-captcha input[type="number"]:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0,115,170,0.2);
}