/* ============================================
   Drag Puzzle Captcha Widget Styles
   ============================================ */

/* Widget Container */
.captcha-widget {
    width: 300px;
    max-width: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: var(--card-bg, #ffffff);
    transition: border-color 0.3s ease;
    user-select: none;
    position: relative;
}

/* Image Container */
.captcha-image-container {
    position: relative;
    width: 100%;
    line-height: 0;
}

/* Canvas */
.captcha-canvas {
    display: block;
    width: 100%;
    height: auto;
    cursor: default;
    outline: none;
    transition: filter 0.2s ease;
}

.captcha-canvas:focus-visible {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.4);
    border-radius: 4px;
}

.captcha-cursor-grab {
    cursor: grab;
}

.captcha-cursor-grabbing {
    cursor: grabbing;
}

/* Hint Text */
.captcha-hint-text {
    display: block;
    text-align: center;
    color: var(--text-muted, #6b7280);
    font-size: 0.8em !important;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    letter-spacing: 0.02em;
    padding: 6px 0;
}

.captcha-hint-text-hidden {
    opacity: 0;
}

/* ============================================
   Loading State (AJAX verification in progress)
   ============================================ */

.captcha-widget.captcha-loading .captcha-canvas {
    filter: brightness(0.85);
    background: var(--card-bg, #f8f9fa);
}

.captcha-widget.captcha-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid rgba(99, 102, 241, 0.25);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: captcha-spin 0.6s linear infinite;
    z-index: 5;
}

.captcha-widget.captcha-loading .captcha-hint-text {
    opacity: 0;
}

@keyframes captcha-spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   Success State (server verified)
   ============================================ */

.captcha-widget.captcha-success {
    border-color: #198754;
}

.captcha-widget.captcha-success .captcha-canvas {
    filter: brightness(1.02);
}

.captcha-widget.captcha-success .captcha-hint-text {
    color: #198754;
    font-weight: 700;
}

/* ============================================
   Error State
   ============================================ */

.captcha-widget.captcha-error {
    border-color: #dc3545;
    animation: captcha-shake 0.4s ease-in-out;
}

.captcha-widget.captcha-error .captcha-hint-text {
    color: #dc3545;
    font-weight: 700;
}

/* Shake Animation */
@keyframes captcha-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* ============================================
   Dark Theme Support
   ============================================ */

[data-bs-theme="dark"] .captcha-widget {
    border-color: var(--border-color, #495057);
    background: var(--card-bg, #1a1d23);
}

[data-bs-theme="dark"] .captcha-hint-text {
    color: var(--text-muted, #adb5bd);
}

[data-bs-theme="dark"] .captcha-widget.captcha-success .captcha-hint-text {
    color: #198754;
    font-weight: 700;
}

[data-bs-theme="dark"] .captcha-widget.captcha-error .captcha-hint-text {
    color: #dc3545;
    font-weight: 700;
}

[data-bs-theme="dark"] .captcha-widget.captcha-loading::after {
    border-color: rgba(129, 140, 248, 0.25);
    border-top-color: #818cf8;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 400px) {
    .captcha-widget {
        width: 100%;
    }

    .captcha-hint-text {
        font-size: 10px;
    }
}
