/* =============================================
   Easy Popup Form — Frontend Styles
   Author: Spherlogy
   ============================================= */

/* --- CSS Custom Properties (overridden inline by PHP color settings) --- */
#epf-container {
    --epf-btn-bg:       #2271b1;
    --epf-btn-text:     #ffffff;
    --epf-header-bg:    #2271b1;
    --epf-header-text:  #ffffff;
    --epf-submit-bg:    #2271b1;
    --epf-submit-text:  #ffffff;
    --epf-form-bg:      #ffffff;
    --epf-field-border: #d0d5dd;
    --epf-field-focus:  #2271b1;
}

/* --- Container: anchor point for both button and popup --- */
#epf-container {
    position: fixed;
    z-index: 99999;
}

#epf-container.epf-position-bottom-right {
    bottom: 24px;
    right:  24px;
}

#epf-container.epf-position-bottom-left {
    bottom: 24px;
    left:   24px;
}

/* --- Trigger Button --- */
#epf-trigger-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--epf-btn-bg);
    color: var(--epf-btn-text);
    border: none;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,.25);
    transition: filter .2s, box-shadow .2s, transform .15s;
    white-space: nowrap;
    position: relative;
    z-index: 1;
}
#epf-trigger-btn:hover,
#epf-trigger-btn:focus-visible {
    filter: brightness(.88);
    box-shadow: 0 6px 18px rgba(0,0,0,.32);
    outline: none;
}
#epf-trigger-btn:active { transform: scale(.97); }

#epf-trigger-btn .epf-btn-icon svg {
    display: block;
}

/* --- Popup Box: floats ABOVE the button via absolute positioning --- */
#epf-popup-box {
    position: absolute;
    bottom: calc(100% + 12px); /* 12px gap above the button */
    right: 0;
    width: 340px;
    background: var(--epf-form-bg);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    overflow: hidden;
    animation: epfSlideIn .22s ease;
    transform-origin: bottom right;
}

/* Left-position variant: align popup to the left edge of the button */
.epf-position-bottom-left #epf-popup-box {
    right: auto;
    left:  0;
    transform-origin: bottom left;
}

@keyframes epfSlideIn {
    from { opacity: 0; transform: translateY(12px) scale(.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1);   }
}

#epf-popup-box[hidden] { display: none; }

/* --- Popup Header --- */
.epf-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 12px;
    background: var(--epf-header-bg);
    color: var(--epf-header-text);
}

.epf-popup-title {
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
}

#epf-close-btn {
    background: transparent;
    border: none;
    color: var(--epf-header-text);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    opacity: .8;
    transition: opacity .15s;
}
#epf-close-btn:hover { opacity: 1; }

/* --- Form Wrap --- */
#epf-form-wrap {
    padding: 18px 16px 20px;
    max-height: 70vh;
    overflow-y: auto;
}

/* --- Fields --- */
.epf-field {
    margin-bottom: 12px;
}

.epf-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.epf-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #3c3c3c;
    margin-bottom: 4px;
    font-family: inherit;
}

.epf-required { color: #c0392b; margin-left: 2px; }

.epf-field input,
.epf-field textarea,
.epf-field select {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    border: 1.5px solid var(--epf-field-border);
    border-radius: 8px;
    background: #fafafa;
    color: #1a1a1a;
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
    -webkit-appearance: none;
}

.epf-field input:focus,
.epf-field textarea:focus,
.epf-field select:focus {
    outline: none;
    border-color: var(--epf-field-focus);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--epf-field-focus) 20%, transparent);
    background: #fff;
}

.epf-field input.epf-invalid,
.epf-field textarea.epf-invalid {
    border-color: #c0392b;
    box-shadow: 0 0 0 3px rgba(192,57,43,.12);
}

.epf-field textarea { resize: vertical; min-height: 72px; }

/* --- Honeypot (must stay invisible) --- */
.epf-hp-field {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

/* --- Submit Button --- */
.epf-submit-row { margin-top: 14px; }

#epf-submit-btn {
    width: 100%;
    padding: 11px;
    background: var(--epf-submit-bg);
    color: var(--epf-submit-text);
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: filter .2s;
}
#epf-submit-btn:hover  { filter: brightness(.88); }
#epf-submit-btn:disabled { opacity: .65; cursor: not-allowed; }

/* --- Messages --- */
#epf-form-msg {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.45;
}
#epf-form-msg.epf-msg-success {
    background: #edfaed;
    color: #1d6b1d;
    border: 1px solid #b2dfb2;
}
#epf-form-msg.epf-msg-error {
    background: #fef0ef;
    color: #8a1e1e;
    border: 1px solid #f5c6c6;
}

/* --- Responsive --- */
@media (max-width: 420px) {
    #epf-container.epf-position-bottom-right {
        right: 12px;
        bottom: 12px;
    }
    #epf-container.epf-position-bottom-left {
        left: 12px;
        bottom: 12px;
    }

    #epf-popup-box {
        width: calc(100vw - 24px);
        right: 0;
    }

    .epf-position-bottom-left #epf-popup-box {
        left: 0;
        right: auto;
    }

    .epf-two-col { grid-template-columns: 1fr; }
}
