/**
 * PopUp LeadGen - Frontend Styles
 * 
 * Complete Phase 3 implementation with all customization support
 * 
 * @package PopUpLeadGen
 * @since 2.1.0
 */

/* ============================================
   TRIGGER BUTTON
   ============================================ */
.plg-trigger-btn {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    /* Background, color, padding applied inline from settings */
}

.plg-trigger-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    opacity: 0.95;
}

.plg-trigger-btn:active {
    transform: translateY(0);
}

.plg-trigger-btn:focus {
    outline: 2px solid currentColor;
    outline-offset: 3px;
}

/* ============================================
   TRIGGER WRAPPER (for images, custom content)
   ============================================ */
.plg-trigger-wrapper {
    display: inline-block;
    cursor: pointer;
    transition: opacity 0.3s ease, transform 0.2s ease;
    line-height: 0; /* Prevents extra spacing around images */
    vertical-align: middle;
}

.plg-trigger-wrapper:hover {
    opacity: 0.85;
    transform: scale(1.02);
}

.plg-trigger-wrapper:active {
    transform: scale(0.98);
}

.plg-trigger-wrapper img {
    display: block; /* Removes inline spacing */
    max-width: 100%;
    height: auto;
}

.plg-trigger-wrapper:focus {
    outline: 2px solid #667eea;
    outline-offset: 3px;
}

/* ============================================
   OVERLAY
   ============================================ */
.plg-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.plg-overlay.plg-active {
    display: flex !important;
}

/* ============================================
   MODAL CONTAINER
   ============================================ */
.plg-modal {
    position: relative;
    width: 90%;
    max-width: 500px; /* Default, overridden by inline style */
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 16px;
    background: #ffffff !important; /* Default, overridden by inline style */
    /* Max-width, background color and shadow applied inline from settings */
}

/* Force background on all child elements to inherit or be transparent */
.plg-modal > * {
    background: transparent;
}

/* ============================================
   CLOSE BUTTON
   ============================================ */
.plg-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    color: #718096;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
    padding: 0;
}

.plg-close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: rotate(90deg);
    color: #2d3748;
}

.plg-close-btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ============================================
   MODAL CONTENT
   ============================================ */
.plg-modal-content {
    padding: 50px 40px 40px;
}

/* ============================================
   HEADER
   ============================================ */
.plg-modal-header {
    margin-bottom: 30px;
}

.plg-headline {
    margin: 0 0 12px 0;
    line-height: 1.3;
    /* Font size, color, weight, align applied inline */
}

.plg-subheadline {
    margin: 0 0 0 0;
    line-height: 1.6;
    /* Font size, color, weight, align applied inline */
}

/* ============================================
   FORM CONTAINER
   ============================================ */
.plg-form-container {
    margin: 25px 0;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.plg-form {
    width: 100%;
}

.plg-form-group {
    margin-bottom: 20px;
}

.plg-form-group label {
    display: block;
    margin-bottom: 8px;
    /* Font size, color, weight, align applied inline */
}

.plg-required {
    color: #ef4444;
    margin-left: 3px;
}

.plg-form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid;
    border-radius: 8px;
    transition: all 0.3s ease;
    /* Font size, color, border-color applied inline */
}

.plg-form-group input:focus {
    outline: none;
    /* Border color and box-shadow applied inline */
}

.plg-form-group input::placeholder {
    color: #a0aec0;
}

/* ============================================
   SUBMIT BUTTON
   ============================================ */
.plg-submit-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.2;
    /* Background, color, font-size, font-weight applied inline */
}

.plg-submit-btn:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.plg-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================
   EXTERNAL FORM
   ============================================ */
.plg-external-form {
    /* External form code from ConvertKit, Mailchimp, etc. */
}

.plg-external-form form {
    width: 100%;
}

.plg-external-form label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
}

.plg-external-form input[type="text"],
.plg-external-form input[type="email"],
.plg-external-form input[type="tel"] {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 15px;
    margin-bottom: 15px;
    transition: all 0.3s ease;
    background: #ffffff;
}

.plg-external-form input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.plg-external-form button,
.plg-external-form input[type="submit"] {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 8px;
    background: #3b82f6;
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
    line-height: normal;
    /* Remove browser-specific padding */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.plg-external-form button:hover,
.plg-external-form input[type="submit"]:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

/* ============================================
   FOOTER
   ============================================ */
.plg-footer {
    margin: 20px 0 0 0;
    line-height: 1.5;
    /* Font size, color, weight, align applied inline */
}

/* ============================================
   NO FORM FALLBACK
   ============================================ */
.plg-no-form {
    text-align: center;
    padding: 40px 20px;
    border-radius: 8px;
    color: #718096;
}

/* ============================================
   ANIMATIONS
   ============================================ */

/* Fade Animation */
.plg-anim-fade .plg-modal {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.plg-anim-fade.plg-active .plg-modal {
    opacity: 1;
}

/* Slide Animation */
.plg-anim-slide .plg-modal {
    transform: translateY(-50px);
    opacity: 0;
    transition: all 0.4s ease;
}

.plg-anim-slide.plg-active .plg-modal {
    transform: translateY(0);
    opacity: 1;
}

/* Zoom Animation */
.plg-anim-zoom .plg-modal {
    transform: scale(0.7);
    opacity: 0;
    transition: all 0.3s ease;
}

.plg-anim-zoom.plg-active .plg-modal {
    transform: scale(1);
    opacity: 1;
}

/* No Animation */
.plg-anim-none .plg-modal {
    transition: none;
}

/* ============================================
   FORM VALIDATION STATES
   ============================================ */
.plg-form-group input.plg-error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

.plg-form-group input.plg-success {
    border-color: #10b981 !important;
}

.plg-error-message {
    display: block;
    color: #ef4444;
    font-size: 13px;
    margin-top: 5px;
}

/* ============================================
   LOADING STATE
   ============================================ */
.plg-submit-btn.plg-loading {
    position: relative;
    color: transparent !important;
}

.plg-submit-btn.plg-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: plg-spin 0.6s linear infinite;
    color: white;
}

@keyframes plg-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   SUCCESS MESSAGE
   ============================================ */
.plg-success-message {
    display: none;
    text-align: center;
    padding: 40px 20px;
    background: #d1fae5;
    border: 2px solid #10b981;
    border-radius: 12px;
    color: #065f46;
}

.plg-success-message.plg-show {
    display: block;
}

.plg-success-message h3 {
    margin: 0 0 10px 0;
    font-size: 24px;
    color: #065f46;
}

.plg-success-message p {
    margin: 0;
    color: #059669;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .plg-overlay {
        padding: 10px;
    }
    
    .plg-modal-content {
        padding: 40px 25px 30px;
    }
    
    .plg-close-btn {
        width: 35px;
        height: 35px;
        font-size: 20px;
    }
    
    .plg-headline {
        font-size: 22px !important;
    }
    
    .plg-subheadline {
        font-size: 14px !important;
    }
    
    .plg-form-group input {
        padding: 12px 14px;
        font-size: 14px !important;
    }
    
    .plg-submit-btn {
        padding: 14px;
        font-size: 14px !important;
    }
}

@media (max-width: 480px) {
    .plg-modal {
        max-width: 100% !important;
        border-radius: 12px;
    }
    
    .plg-modal-content {
        padding: 35px 20px 25px;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.plg-overlay:focus {
    outline: none;
}

.plg-modal:focus {
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
}

/* Screen reader only */
.plg-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================
   PRINT
   ============================================ */
@media print {
    .plg-overlay {
        display: none !important;
    }
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */
@media (prefers-contrast: high) {
    .plg-form-group input {
        border-width: 3px;
    }
    
    .plg-submit-btn {
        border: 2px solid currentColor;
    }
    
    .plg-close-btn {
        border: 2px solid currentColor;
        background: white;
    }
}

/* ============================================
   SUCCESS MESSAGE SCREEN
   ============================================ */
.plg-success-container {
    padding: 50px 40px 40px;
    text-align: center;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.plg-success-headline {
    font-size: 32px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 12px;
    line-height: 1.2;
}

.plg-success-subheadline {
    font-size: 16px;
    color: #718096;
    margin-bottom: 30px;
    line-height: 1.6;
    max-width: 400px;
}

.plg-success-content {
    margin: 25px 0;
    line-height: 1.6;
    color: #4a5568;
    max-width: 500px;
}

.plg-success-content p {
    margin-bottom: 15px;
}

.plg-success-content a {
    color: #667eea;
    text-decoration: underline;
}

.plg-success-content a:hover {
    color: #5568d3;
}

.plg-success-image {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 20px 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.plg-success-video {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    margin: 20px 0;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    max-width: 560px;
    width: 100%;
}

.plg-success-video iframe,
.plg-success-video video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 12px;
}

.plg-success-button {
    display: inline-block;
    padding: 16px 32px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s ease;
    margin-top: 20px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.plg-success-button:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.plg-success-button:active {
    transform: translateY(0);
}

.plg-countdown-message {
    font-size: 16px;
    color: #4a5568;
    margin-top: 20px;
    font-weight: 500;
    padding: 15px 25px;
    background: #f7fafc;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

/* Modal content transition */
.plg-modal-content {
    transition: opacity 0.3s ease;
}

/* Success/Error alerts */
.plg-success-alert,
.plg-error-alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-top: 15px;
    text-align: center;
    font-weight: 500;
    animation: slideDown 0.3s ease;
}

.plg-success-alert {
    background: #48bb78;
    color: white;
}

.plg-error-alert {
    background: #fc8181;
    color: white;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading state */
.plg-submit-btn.plg-loading {
    opacity: 0.7;
    cursor: not-allowed;
    position: relative;
}

.plg-submit-btn.plg-loading::after {
    content: '';
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* Mobile responsiveness for success screen */
@media (max-width: 768px) {
    .plg-success-container {
        padding: 40px 25px 30px;
    }
    
    .plg-success-headline {
        font-size: 24px;
    }
    
    .plg-success-subheadline {
        font-size: 14px;
    }
    
    .plg-success-button {
        padding: 14px 28px;
        font-size: 15px;
    }
    
    .plg-countdown-message {
        font-size: 14px;
        padding: 12px 20px;
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .plg-overlay,
    .plg-modal,
    .plg-close-btn,
    .plg-submit-btn,
    .plg-form-group input {
        transition: none !important;
        animation: none !important;
    }
}

/* Honeypot Field - Hidden from humans, visible to bots */
/* Using generic class name to avoid bot detection */
.plg-form-group.plg-field-alt,
.plg-form-group[data-field-alt="1"] {
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}


/* External Form Cleanup - Hide problematic elements */
.plg-external-form br {
    display: none !important;
}

.plg-external-form iframe {
    display: none !important;
    height: 0 !important;
}

/* Hide honeypot adjacent br tags */
.plg-field-alt + br,
input[aria-hidden="true"] + br,
input[style*="position: absolute"] + br,
input[style*="position:absolute"] + br {
    display: none !important;
}

