/**
 * Cloudflare Turnstile Widget Styles
 *
 * Comprehensive styling for Turnstile widget container,
 * error states, retry buttons, and disabled button states.
 * Optimized for cross-browser compatibility including Safari.
 */

/* Main Turnstile container */
#turnstile-container {
    min-height: 65px;
    /* Center the Turnstile widget */
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    margin: 0 auto;
    /* Ensure proper spacing */
    padding: 10px 0;
    /* Allow content to wrap properly */
    width: 100%;
    max-width: 100%;
}

/* Ensure the iframe container is properly sized */
#turnstile-container .cf-turnstile {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Global button-disabled style for Turnstile-protected forms */
button.button-disabled,
.btn.button-disabled {
    background-color: #A6B3C4 !important;
    border-color: #A6B3C4 !important;
    cursor: not-allowed !important;
    opacity: 0.7;
    pointer-events: none;
}

/* Error message styling */
.turnstile-error {
    color: #dc3545;
    font-size: 0.875rem;
    margin: 0.5rem 0;
    text-align: center;
    line-height: 1.4;
    max-width: 300px;
}

/* Retry container (holds error message and retry button) */
.turnstile-retry-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px;
    background-color: #fff8f8;
    border: 1px solid #ffcdd2;
    border-radius: 8px;
    margin: 10px 0;
    width: 100%;
    max-width: 300px;
    box-sizing: border-box;
}

/* Retry button styling */
.turnstile-retry-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 20px;
    background-color: #1a365d;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.turnstile-retry-btn:hover {
    background-color: #2c5282;
}

.turnstile-retry-btn:active {
    transform: scale(0.98);
}

.turnstile-retry-btn:focus {
    outline: 2px solid #4299e1;
    outline-offset: 2px;
}

/* "Stuck" message styling (shown during long verification) */
.turnstile-stuck {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.8rem;
    color: #666;
    flex-wrap: wrap;
}

.turnstile-stuck span {
    color: #666;
}

/* Retry link (text button style) */
.turnstile-retry-link {
    background: none;
    border: none;
    color: #1a365d;
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    font-weight: 500;
}

.turnstile-retry-link:hover {
    color: #2c5282;
    text-decoration: none;
}

.turnstile-retry-link:focus {
    outline: 2px solid #4299e1;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Safari-specific fixes */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific styles */
    #turnstile-container {
        /* Prevent iOS Safari zoom on iframe interaction */
        touch-action: manipulation;
    }

    .turnstile-retry-btn,
    .turnstile-retry-link {
        /* Ensure proper touch targets on iOS */
        min-height: 44px;
        min-width: 44px;
    }
}

/* Loading state animation (optional - can be used during retries) */
@keyframes turnstile-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.turnstile-loading {
    animation: turnstile-pulse 1.5s ease-in-out infinite;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    #turnstile-container {
        padding: 8px 0;
    }

    .turnstile-retry-container {
        padding: 12px;
        margin: 8px 0;
    }

    .turnstile-error {
        font-size: 0.8125rem;
    }

    .turnstile-retry-btn {
        padding: 10px 24px;
        font-size: 0.8125rem;
        width: 100%;
    }

    .turnstile-stuck {
        flex-direction: column;
        gap: 4px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .turnstile-error {
        color: #b71c1c;
        font-weight: 600;
    }

    .turnstile-retry-btn {
        border: 2px solid #000;
    }

    button.button-disabled,
    .btn.button-disabled {
        background-color: #9e9e9e !important;
        border-color: #757575 !important;
        color: #424242 !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .turnstile-retry-btn {
        transition: none;
    }

    .turnstile-loading {
        animation: none;
    }
}
