.slider-captcha {
    position: relative;
    width: 280px;
    margin: 0;
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.captcha-canvas-container {
    position: relative;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    overflow: visible;
    background: #f8f9fa;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.captcha-canvas {
    display: block;
    width: 100%;
    height: auto;
    image-rendering: crisp-edges;
}

.captcha-slider {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    filter: drop-shadow(2px 2px 6px rgba(0, 0, 0, 0.4));
    transition: left 0.1s ease-out;
    pointer-events: none;
}

.captcha-refresh {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    transition: background-color 0.2s ease;
}

.captcha-refresh:hover {
    background: rgba(0, 0, 0, 0.7);
}

.captcha-refresh:before {
    content: "⟳";
    font-size: 14px;
}

.slider-container {
    position: relative;
    height: 44px;
    background: linear-gradient(
        to right,
        #f8f9fa 0%,
        #e9ecef 50%,
        #f8f9fa 100%
    );
    border: 2px solid #dee2e6;
    border-radius: 22px;
    margin-top: 8px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

.slider-track {
    display: none;
}

.slider-button {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    cursor: grab;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    font-weight: bold;
    user-select: none;
    z-index: 5;
}

.slider-button:hover {
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
    transform: translateY(-1px);
}

.slider-button:active {
    cursor: grabbing;
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.5);
}

.slider-button:before {
    content: "→";
    font-weight: bold;
}

.captcha-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* Success state */
.slider-captcha.captcha-success .slider-container {
    background: linear-gradient(
        to right,
        #d1fae5 0%,
        #a7f3d0 50%,
        #d1fae5 100%
    );
    border: 2px solid #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.slider-captcha.captcha-success .slider-button {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.slider-captcha.captcha-success .slider-button:before {
    content: "✓";
}

.slider-captcha.captcha-success .captcha-text {
    color: #047857;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.9);
}

.slider-captcha.captcha-success .captcha-canvas-container {
    border-color: #10b981;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

/* Fail state */
.slider-captcha.captcha-fail .slider-container {
    background: linear-gradient(
        to right,
        #fee2e2 0%,
        #fecaca 50%,
        #fee2e2 100%
    );
    border: 2px solid #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
    animation: shake 0.5s ease-in-out;
}

.slider-captcha.captcha-fail .slider-button {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.slider-captcha.captcha-fail .slider-button:before {
    content: "✗";
}

.slider-captcha.captcha-fail .captcha-text {
    color: #b91c1c;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.9);
}

.slider-captcha.captcha-fail .captcha-canvas-container {
    border-color: #ef4444;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* Loading state */
.slider-captcha.loading .captcha-text {
    color: #6c757d;
}

.slider-captcha.loading .captcha-text:after {
    content: "";
    animation: loading-dots 1.5s infinite;
}

/* Shake animation for failed attempts */
@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }
    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-4px);
    }
    20%,
    40%,
    60%,
    80% {
        transform: translateX(4px);
    }
}

/* Loading dots animation */
@keyframes loading-dots {
    0%,
    33% {
        content: ".";
    }
    34%,
    66% {
        content: "..";
    }
    67%,
    100% {
        content: "...";
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .slider-captcha {
        width: 100%;
        max-width: 280px;
    }
}

@media (max-width: 320px) {
    .slider-captcha {
        width: 260px;
    }

    .captcha-text {
        font-size: 11px;
    }

    .slider-button {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .slider-container {
        height: 36px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .slider-button {
        width: 40px;
        height: 40px;
    }

    .slider-container {
        height: 44px;
    }

    .captcha-refresh {
        width: 28px;
        height: 28px;
        top: 6px;
        right: 6px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .slider-container {
        border: 2px solid #000;
        background: #fff;
    }

    .slider-button {
        background: #000;
        border: 2px solid #fff;
    }

    .captcha-text {
        color: #000;
        font-weight: bold;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .slider-captcha {
        color: #e9ecef;
    }

    .captcha-canvas-container {
        background: #343a40;
        border-color: #495057;
    }

    .slider-container {
        background: #495057;
        border-color: #6c757d;
    }

    .captcha-text {
        color: #adb5bd;
    }

    .slider-track {
        background: #6c757d;
    }

    .captcha-refresh {
        background: rgba(255, 255, 255, 0.1);
    }

    .captcha-refresh:hover {
        background: rgba(255, 255, 255, 0.2);
    }
}

/* Focus styles for accessibility */
.slider-button:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.captcha-refresh:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Disabled state */
.slider-captcha.disabled {
    opacity: 0.6;
    pointer-events: none;
}

.slider-captcha.disabled .slider-button {
    cursor: not-allowed;
    background: #6c757d;
}
