/**
 * MU CCL CAPTCHA Gouv - Frontend Styles
 * Styles pour le CAPTCHA côté client
 * 
 * @package MU_CCL_Captcha_Gouv
 * @version 1.1.0
 */

/* ========================================
   Conteneur principal
   ======================================== */

.ccl-captcha-container {
    margin: 15px 0;
    padding: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* ========================================
   Label et éléments requis
   ======================================== */

.ccl-captcha-label {
    display: block;
    margin-bottom: 12px;
    font-weight: 600;
    color: #1e1e1e;
    font-size: 16px;
}

.ccl-captcha-required {
    color: #d63638;
    font-weight: bold;
}

/* ========================================
   Wrapper image et contrôles
   ======================================== */

.ccl-captcha-image-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.ccl-captcha-image-wrapper .jet-form-builder-row {
    flex-basis: 20%;
}

/* ========================================
   Image CAPTCHA
   ======================================== */

.ccl-captcha-image-container {
    position: relative;
    flex: 0 0 auto;
}

.ccl-captcha-image {
    display: block;
    max-width: 280px;
    height: auto;
    border: 2px solid #d0d0d0;
    border-radius: 6px;
    background: #fff;
}

.ccl-captcha-image:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* ========================================
   Overlay de chargement
   ======================================== */

.ccl-captcha-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.ccl-captcha-spinner {
    width: 40px;
    height: 40px;
    animation: ccl-rotate 2s linear infinite;
}

.ccl-captcha-spinner-path {
    stroke: #2271b1;
    stroke-linecap: round;
    animation: ccl-dash 1.5s ease-in-out infinite;
}

@keyframes ccl-rotate {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes ccl-dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

/* ========================================
   Contrôles (boutons rafraîchir/audio)
   ======================================== */

.ccl-captcha-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ccl-captcha-refresh-icon,
.ccl-captcha-audio-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 25px;
    height: 25px;
    padding: 0;
    border: none;
    background: none;
    color: #323A3A;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.ccl-captcha-refresh-icon:hover,
.ccl-captcha-audio-icon:hover,
.ccl-captcha-refresh-icon:focus,
.ccl-captcha-audio-icon:focus {
    background: none;
    color: #323A3A;
    transform: scale(1.5);
}

.ccl-captcha-refresh-icon:active,
.ccl-captcha-audio-icon:active {
    transform: scale(0.95);
}

.ccl-captcha-refresh-icon:disabled,
.ccl-captcha-audio-icon:disabled {
    background: #dcdcde;
    border-color: #dcdcde;
    cursor: not-allowed;
    opacity: 0.6;
}

.ccl-captcha-refresh-icon.ccl-spinning svg,
.ccl-captcha-audio-icon.ccl-spinning svg {
    animation: ccl-spin 1s linear infinite;
}

@keyframes ccl-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.ccl-captcha-refresh-icon svg,
.ccl-captcha-audio-icon svg {
    display: block;
    width: 20px;
    height: 20px;
}

/* ========================================
   Champ de saisie
   ======================================== */

.ccl-captcha-input {
    width: 100%;
    max-width: 320px;
    padding: 10px 14px;
    border: 2px solid #8c8f94;
    border-radius: 6px;
    font-size: 16px;
    line-height: 1.5;
    transition: border-color 0.2s ease;
}

.ccl-captcha-input:focus {
    border-color: #2271b1;
    outline: 2px solid #2271b1;
    outline-offset: 2px;
    box-shadow: none;
}

.ccl-captcha-input[aria-invalid="true"] {
    border-color: #d63638;
}

/* ========================================
   Instructions
   ======================================== */

.ccl-captcha-instructions {
    margin-top: 8px;
    font-size: 14px;
    color: #646970;
    line-height: 1.6;
    display: flex;
    align-items: flex-start;
}

.ccl-captcha-instructions svg {
    margin-right: 6px;
    flex-shrink: 0;
}

/* ========================================
   Messages d'erreur
   ======================================== */

.ccl-captcha-error,
.ccl-captcha-error-message {
    color: #d63638;
    font-size: 14px;
    margin-top: 10px;
    padding: 12px;
    background: #fef7f7;
    border-left: 4px solid #d63638;
    border-radius: 4px;
    font-weight: 500;
}

/* ========================================
   Accessibilité
   ======================================== */

.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;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
    .ccl-captcha-image-wrapper {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .ccl-captcha-image-wrapper .jet-form-builder-row {
        flex-basis: 100%;
    }
    
    .ccl-captcha-image {
        max-width: 100%;
    }
}

/* ========================================
   Contraste élevé
   ======================================== */

@media (prefers-contrast: high) {
    .ccl-captcha-container {
        border: 2px solid #000;
    }
    
    .ccl-captcha-input,
    .ccl-captcha-refresh-icon,
    .ccl-captcha-audio-icon {
        border: 2px solid #000;
    }
}

/* ========================================
   Lecteur audio (caché)
   ======================================== */

.ccl-captcha-audio-player {
    display: none;
}

.ccl-captcha-fallback-notice {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}