/**
 * CAPTCHA Popup Styling - PrestaShop Theme Compatible
 * Modern popup overlay for ALTCHA verification using PrestaShop/Bootstrap styles
 *
 * @author Biix <office@biix.pl>
 * @copyright 2025 Biix
 */

/* Popup overlay - covers entire screen (Bootstrap modal style) */
.biix-captcha-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s linear;
    outline: 0;
}

.biix-captcha-popup-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Popup container - exactly like Bootstrap modal */
.biix-captcha-popup {
    position: relative;
    width: auto;
    margin: 0.5rem;
    pointer-events: none;
    max-width: 500px;
    transform: scale(0.9);
    transition: transform 0.3s ease-out;
}

.biix-captcha-popup-overlay.show .biix-captcha-popup {
    transform: scale(1);
}

.biix-captcha-popup .modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: auto;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 0.3rem;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.5);
    outline: 0;
}

/* Popup header - Bootstrap modal header style */
.biix-captcha-popup .modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1rem 1rem;
    border-bottom: 1px solid #dee2e6;
    border-top-left-radius: calc(0.3rem - 1px);
    border-top-right-radius: calc(0.3rem - 1px);
}

.biix-captcha-popup .modal-title {
    margin-bottom: 0;
    line-height: 1.5;
    font-size: 1.25rem;
    font-weight: 500;
    color: #212529;
}

.biix-captcha-popup .close {
    padding: 1rem 1rem;
    margin: -1rem -1rem -1rem auto;
    background-color: transparent;
    border: 0;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    color: #000;
    text-shadow: 0 1px 0 #fff;
    opacity: 0.5;
    cursor: pointer;
}

.biix-captcha-popup .close:hover {
    color: #000;
    text-decoration: none;
    opacity: 0.75;
}

.biix-captcha-popup .close:focus {
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Popup body - Bootstrap modal body style */
.biix-captcha-popup .modal-body {
    position: relative;
    flex: 1 1 auto;
    padding: 1rem;
}

.biix-captcha-popup .modal-text {
    margin-bottom: 1rem;
    color: #6c757d;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* ALTCHA widget container - hide the original widget */
.biix-captcha-popup-widget {
    position: relative;
    min-height: 80px;
    margin: 1rem 0;
}

/* Hide the original ALTCHA widget but keep it functional */
.biix-captcha-popup-widget altcha-widget {
    opacity: 0;
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Custom verification display */
.biix-captcha-verification-display {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    border: 2px dashed #dee2e6;
    border-radius: 0.375rem;
    background-color: #f8f9fa;
    transition: all 0.3s ease;
    cursor: pointer;
    text-align: center;
}

.biix-captcha-verification-display:hover {
    border-color: #007bff;
    background-color: #e7f3ff;
}

.biix-captcha-verification-display.verifying {
    border-color: #ffc107;
    background-color: #fff3cd;
}

.biix-captcha-verification-display.verified {
    border-color: #28a745;
    background-color: #d4edda;
    color: #155724;
}

.biix-captcha-verification-display.error {
    border-color: #dc3545;
    background-color: #f8d7da;
    color: #721c24;
}

.biix-captcha-verification-icon {
    margin-right: 0.5rem;
    font-size: 1.25rem;
}

.biix-captcha-verification-text {
    font-weight: 500;
    font-size: 0.95rem;
}

/* Loading indicator - Bootstrap spinner */
.biix-captcha-popup-loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    color: #6c757d;
    font-size: 0.9rem;
}

.biix-captcha-popup-loading.show {
    display: flex;
}

.biix-captcha-popup-spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: biix-spin 1s linear infinite;
}

@keyframes biix-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Status messages */
.biix-captcha-popup-status {
    display: none;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    border-radius: 0.375rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.biix-captcha-popup-status.show {
    display: block;
}

.biix-captcha-popup-status.success {
    color: #155724;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
}

.biix-captcha-popup-status.error {
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
}

/* Popup footer - Bootstrap modal footer style */
.biix-captcha-popup .modal-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    padding: 0.75rem;
    border-top: 1px solid #dee2e6;
    border-bottom-right-radius: calc(0.3rem - 1px);
    border-bottom-left-radius: calc(0.3rem - 1px);
}

.biix-captcha-popup .modal-footer > * {
    margin: 0.25rem;
}

/* Buttons - Bootstrap button styles */
.biix-captcha-popup .btn {
    display: inline-block;
    font-weight: 400;
    color: #212529;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background-color: transparent;
    border: 1px solid transparent;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: 0.25rem;
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, 
                border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    text-decoration: none;
}

.biix-captcha-popup .btn:hover {
    color: #212529;
    text-decoration: none;
}

.biix-captcha-popup .btn:focus,
.biix-captcha-popup .btn.focus {
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.biix-captcha-popup .btn:disabled,
.biix-captcha-popup .btn.disabled {
    opacity: 0.65;
    pointer-events: none;
}

.biix-captcha-popup .btn-primary {
    color: #fff;
    background-color: #007bff;
    border-color: #007bff;
}

.biix-captcha-popup .btn-primary:hover {
    color: #fff;
    background-color: #0069d9;
    border-color: #0062cc;
}

.biix-captcha-popup .btn-primary:focus,
.biix-captcha-popup .btn-primary.focus {
    color: #fff;
    background-color: #0069d9;
    border-color: #0062cc;
    box-shadow: 0 0 0 0.2rem rgba(38, 143, 255, 0.5);
}

.biix-captcha-popup .btn-secondary {
    color: #6c757d;
    background-color: transparent;
    border-color: #6c757d;
}

.biix-captcha-popup .btn-secondary:hover {
    color: #fff;
    background-color: #6c757d;
    border-color: #6c757d;
}

.biix-captcha-popup .btn-secondary:focus,
.biix-captcha-popup .btn-secondary.focus {
    color: #fff;
    background-color: #6c757d;
    border-color: #6c757d;
    box-shadow: 0 0 0 0.2rem rgba(108, 117, 125, 0.5);
}

/* ALTCHA branding - small and discrete */
.biix-captcha-altcha-branding {
    text-align: center;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #6c757d;
    opacity: 0.8;
}

.biix-captcha-altcha-branding a {
    color: #6c757d;
    text-decoration: none;
    font-weight: 500;
}

.biix-captcha-altcha-branding a:hover {
    color: #495057;
    text-decoration: underline;
}

.biix-captcha-altcha-logo {
    display: inline-block;
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-left: 0.25rem;
    opacity: 0.6;
}

/* Body scroll lock when popup is open */
body.biix-captcha-popup-open {
    overflow: hidden;
}

/* Responsive design */
@media (max-width: 576px) {
    .biix-captcha-popup {
        width: 95%;
        margin: 1rem;
    }
    
    .biix-captcha-popup-header,
    .biix-captcha-popup-body,
    .biix-captcha-popup-footer {
        padding: 0.75rem;
    }
    
    .biix-captcha-popup-footer {
        flex-direction: column-reverse;
        gap: 0.5rem;
    }
    
    .biix-captcha-popup-button {
        width: 100%;
        justify-content: center;
    }
}

/* Animation improvements */
@media (prefers-reduced-motion: reduce) {
    .biix-captcha-popup-overlay,
    .biix-captcha-popup,
    .biix-captcha-popup-button,
    .biix-captcha-verification-display {
        transition: none;
    }
    
    .biix-captcha-popup-spinner {
        animation: none;
    }
}
