/**
 * TSW Popup Form Styles
 *
 * Ported from static site, adapted to use theme CSS custom properties.
 *
 * @package TSW
 * @since   1.0.0
 */

/* ---------- Overlay ---------- */
.pf-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.pf-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ---------- Popup Container ---------- */
.pf-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.92);
    z-index: 9999;
    width: 92%;
    max-width: 440px;
    background: var(--tsw-white, #fff);
    border-radius: var(--tsw-radius-xl, 16px);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease, transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}
.pf-popup.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* ---------- Top Accent Bar ---------- */
.pf-accent {
    height: 4px;
    background: linear-gradient(90deg, var(--tsw-primary, #1a3a2a), var(--tsw-teal, #0d9488), var(--tsw-accent, #2ecc71));
}

/* ---------- Close Button ---------- */
.pf-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--tsw-light, #f5f5f5);
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--tsw-text-muted, #666);
    transition: all var(--tsw-transition, 0.3s ease);
    z-index: 2;
}
.pf-close:hover {
    background: var(--tsw-dark, #1a1a2e);
    color: #fff;
}

/* ---------- Header ---------- */
.pf-header {
    padding: 20px 24px 0;
    text-align: center;
}
.pf-header-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tsw-accent-light, rgba(46, 204, 113, 0.1));
    border-radius: 12px;
    color: var(--tsw-accent, #2ecc71);
    font-size: 1.1rem;
}
.pf-header h3 {
    font-family: var(--tsw-font-display, 'Qilka', serif);
    font-size: 1.2rem;
    color: var(--tsw-dark, #1a1a2e);
    margin-bottom: 4px;
}
.pf-header p {
    font-size: 0.8rem;
    color: #888;
    line-height: 1.4;
    margin: 0;
}

/* ---------- Form ---------- */
.pf-form {
    padding: 14px 24px 20px;
}
.pf-field {
    margin-bottom: 10px;
}
.pf-field label {
    display: block;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--tsw-text-muted, #666);
    margin-bottom: 3px;
    letter-spacing: 0.02em;
}
.pf-field label .pf-req {
    color: #dc3545;
    margin-left: 2px;
}
.pf-field input,
.pf-field select,
.pf-field textarea {
    width: 100%;
    padding: 9px 12px;
    font-size: 0.85rem;
    font-family: var(--tsw-font-body, 'Inter', sans-serif);
    color: var(--tsw-dark, #1a1a2e);
    background: var(--tsw-light, #f5f5f5);
    border: 1.5px solid var(--tsw-border, #e0e0e0);
    border-radius: var(--tsw-radius-sm, 8px);
    outline: none;
    transition: border-color var(--tsw-transition, 0.3s ease), box-shadow var(--tsw-transition, 0.3s ease);
}
.pf-field input:focus,
.pf-field select:focus,
.pf-field textarea:focus {
    border-color: var(--tsw-accent, #2ecc71);
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.1);
    background: #fff;
}
.pf-field input::placeholder,
.pf-field textarea::placeholder {
    color: #aaa;
}
.pf-field textarea {
    resize: vertical;
    min-height: 56px;
    max-height: 110px;
}

/* intl-tel-input inside popup */
.pf-field .iti {
    width: 100%;
}
.pf-field .iti__selected-dial-code {
    font-size: 0.84rem;
}
.pf-field .iti input[type="tel"] {
    width: 100%;
    padding-left: 90px;
}
.pf-field select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}

/* Error state */
.pf-field.has-error input,
.pf-field.has-error select,
.pf-field.has-error textarea {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.08);
}
.pf-error-text {
    color: #dc3545;
    font-size: 0.75rem;
    margin-top: 4px;
    display: none;
}
.pf-field.has-error .pf-error-text {
    display: block;
}

/* Submit Button */
.pf-submit {
    width: 100%;
    padding: 11px;
    font-size: 0.92rem;
    font-weight: 700;
    font-family: var(--tsw-font-body, 'Inter', sans-serif);
    color: #fff;
    background: var(--tsw-primary, #1a3a2a);
    border: none;
    border-radius: var(--tsw-radius-sm, 8px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--tsw-transition, 0.3s ease);
    margin-top: 4px;
}
.pf-submit:hover {
    background: var(--tsw-primary-dark, #0f2a1c);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(26, 58, 42, 0.3);
}
.pf-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Loader spinner */
.pf-loader {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: pfSpin 0.6s linear infinite;
}
.pf-submit.loading .pf-loader {
    display: inline-block;
}
.pf-submit.loading .pf-submit-text {
    display: none;
}

@keyframes pfSpin {
    to { transform: rotate(360deg); }
}

/* Footer note */
.pf-note {
    text-align: center;
    font-size: 0.72rem;
    color: #aaa;
    margin-top: 8px;
    padding: 0 24px 14px;
}
.pf-note i {
    color: var(--tsw-accent, #2ecc71);
    margin-right: 3px;
}

/* ---------- Success State ---------- */
.pf-success {
    display: none;
    text-align: center;
    padding: 30px 24px;
}
.pf-success.show {
    display: block;
}
.pf-success-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tsw-accent-light, rgba(46, 204, 113, 0.1));
    border-radius: 50%;
    color: var(--tsw-accent, #2ecc71);
    font-size: 1.6rem;
}
.pf-success h4 {
    font-family: var(--tsw-font-display, 'Qilka', serif);
    font-size: 1.2rem;
    color: var(--tsw-dark, #1a1a2e);
    margin-bottom: 8px;
}
.pf-success p {
    font-size: 0.88rem;
    color: #888;
    line-height: 1.5;
}

/* ---------- Floating Trigger Button ---------- */
.pf-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 22px;
    background: var(--tsw-primary, #1a3a2a);
    color: #fff;
    border: none;
    border-radius: var(--tsw-radius-full, 50px);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 700;
    font-family: var(--tsw-font-body, 'Inter', sans-serif);
    box-shadow: 0 6px 24px rgba(26, 58, 42, 0.35);
    transition: all var(--tsw-transition, 0.3s ease);
    animation: pfPulse 3s ease-in-out infinite;
}
.pf-trigger:hover {
    background: var(--tsw-primary-dark, #0f2a1c);
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 10px 32px rgba(26, 58, 42, 0.4);
    animation: none;
}
.pf-trigger i {
    font-size: 1.05rem;
}

@keyframes pfPulse {
    0%, 100% { box-shadow: 0 6px 24px rgba(26, 58, 42, 0.35); }
    50% { box-shadow: 0 6px 32px rgba(26, 58, 42, 0.55), 0 0 0 8px rgba(26, 58, 42, 0.08); }
}

/* ---------- Responsive ---------- */
@media (max-width: 575px) {
    .pf-trigger {
        padding: 14px;
        border-radius: 50%;
        bottom: 16px;
        right: 16px;
    }
    .pf-trigger-label {
        display: none;
    }
    .pf-popup {
        width: 96%;
        max-width: none;
    }
    .pf-header {
        padding: 24px 20px 0;
    }
    .pf-form {
        padding: 18px 20px 22px;
    }
    .pf-note {
        padding: 0 20px 16px;
    }
}
