/**
 * Captcha Component CSS - 验证码组件样式
 * 
 * 提供多种验证码类型的样式
 */

/* ========================================
   验证码容器
======================================== */

.captcha-container {
    position: relative;
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
}

.captcha-wrapper {
    position: relative;
    background: var(--surface, #ffffff);
    border: 1px solid var(--outline, #e5e7eb);
    border-radius: 8px;
    padding: 16px;
    transition: all 0.3s ease;
}

.captcha-wrapper.success {
    border-color: var(--success, #10b981);
    background: rgba(16, 185, 129, 0.05);
}

.captcha-wrapper.error {
    border-color: var(--error, #ef4444);
    background: rgba(239, 68, 68, 0.05);
}

.captcha-wrapper.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ========================================
   图形验证码 (Image Captcha)
======================================== */

.captcha-image-type {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.captcha-image-display {
    position: relative;
    height: 60px;
    background: #f3f4f6;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
}

.captcha-image-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.captcha-image-refresh {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.captcha-image-refresh:hover {
    background: white;
    transform: rotate(180deg);
}

.captcha-image-refresh svg {
    width: 16px;
    height: 16px;
    color: #6b7280;
}

.captcha-image-input {
    display: flex;
    gap: 8px;
}

.captcha-image-input input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--outline, #e5e7eb);
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
}

.captcha-image-input input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-container);
}

.captcha-image-input button {
    padding: 10px 20px;
    background: var(--primary);
    color: var(--on-primary);
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.captcha-image-input button:hover {
    background: var(--primary-dark, #4338CA);
}

/* ========================================
   滑块验证码 (Slider Captcha)
======================================== */

.captcha-slider-type {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.captcha-slider-puzzle {
    position: relative;
    height: 200px;
    background: #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.06),
        inset 0 1px 2px rgba(0, 0, 0, 0.04);
    border: 1px solid #e1e8ed;
}

.captcha-slider-bg,
.captcha-slider-piece {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.captcha-slider-bg {
    z-index: 1;
}

.captcha-slider-piece {
    z-index: 2;
    transition: left 0.3s ease;
    filter: drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.25));
    pointer-events: none;
}

.captcha-slider-track {
    position: relative;
    height: 48px;
    background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%);
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid #e1e8ed;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

.captcha-slider-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--primary-container);
    transition: background 0.3s;
    border-radius: 24px;
}

.captcha-slider-fill.success {
    background: linear-gradient(90deg, 
        rgba(16, 185, 129, 0.15),
        rgba(16, 185, 129, 0.25)
    );
}

.captcha-slider-fill.error {
    background: linear-gradient(90deg, 
        rgba(239, 68, 68, 0.15),
        rgba(239, 68, 68, 0.25)
    );
}

.captcha-slider-button {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 2px solid #e1e8ed;
    border-radius: 50%;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.08),
        0 1px 2px rgba(0, 0, 0, 0.06);
    z-index: 10;
}

.captcha-slider-button:hover {
    transform: translateY(-50%) scale(1.05);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.12),
        0 2px 4px rgba(0, 0, 0, 0.08);
}

.captcha-slider-button:active {
    cursor: grabbing;
    transform: translateY(-50%) scale(0.98);
    box-shadow: 
        0 1px 4px rgba(0, 0, 0, 0.1),
        0 1px 2px rgba(0, 0, 0, 0.06);
}

.captcha-slider-button.success {
    border-color: var(--success, #10b981);
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 
        0 4px 12px rgba(16, 185, 129, 0.3),
        0 2px 4px rgba(16, 185, 129, 0.2);
}

.captcha-slider-button.error {
    border-color: var(--error, #ef4444);
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 
        0 4px 12px rgba(239, 68, 68, 0.3),
        0 2px 4px rgba(239, 68, 68, 0.2);
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateY(-50%) translateX(0); }
    25% { transform: translateY(-50%) translateX(-5px); }
    75% { transform: translateY(-50%) translateX(5px); }
}

.captcha-slider-button svg {
    width: 22px;
    height: 22px;
    color: #6b7280;
    transition: all 0.3s;
}

.captcha-slider-button:hover svg {
    color: var(--primary);
}

.captcha-slider-button.success svg,
.captcha-slider-button.error svg {
    color: white;
}

.captcha-slider-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    font-weight: 500;
    color: #9ca3af;
    pointer-events: none;
    user-select: none;
    letter-spacing: 0.5px;
    transition: opacity 0.3s;
}

.captcha-slider-track:hover .captcha-slider-text {
    opacity: 0.7;
}

/* ========================================
   点击验证码 (Click Captcha)
======================================== */

.captcha-click-type {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.captcha-click-instruction {
    padding: 12px;
    background: var(--primary-container);
    border-left: 3px solid var(--primary);
    border-radius: 4px;
    font-size: 14px;
    color: var(--on-surface);
}

.captcha-click-instruction strong {
    color: var(--primary);
}

.captcha-click-canvas-wrapper {
    position: relative;
    height: 200px;
    background: #f3f4f6;
    border-radius: 6px;
    overflow: hidden;
    cursor: crosshair;
}

.captcha-click-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.captcha-click-mark {
    position: absolute;
    width: 30px;
    height: 30px;
    margin-left: -15px;
    margin-top: -15px;
    pointer-events: none;
    animation: captcha-click-mark-appear 0.3s ease;
}

@keyframes captcha-click-mark-appear {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.captcha-click-mark svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.captcha-click-actions {
    display: flex;
    gap: 8px;
}

.captcha-click-actions button {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--outline, #e5e7eb);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

.captcha-click-actions button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.captcha-click-actions button.primary {
    background: var(--primary);
    color: var(--on-primary);
    border-color: var(--primary);
}

.captcha-click-actions button.primary:hover {
    background: var(--primary-variant);
}

/* ========================================
   验证状态提示
======================================== */

.captcha-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 14px;
    margin-top: 8px;
    animation: captcha-status-appear 0.3s ease;
}

@keyframes captcha-status-appear {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.captcha-status.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success, #10b981);
}

.captcha-status.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error, #ef4444);
}

.captcha-status svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ========================================
   加载状态
======================================== */

.captcha-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    color: #9ca3af;
    font-size: 14px;
}

.captcha-loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--primary-container);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: captcha-loading-spin 0.8s linear infinite;
}

@keyframes captcha-loading-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   响应式设计
======================================== */

@media (max-width: 480px) {
    .captcha-wrapper {
        padding: 12px;
    }
    
    .captcha-slider-puzzle,
    .captcha-click-canvas-wrapper {
        height: 160px;
    }
    
    .captcha-slider-track {
        height: 44px;
    }
    
    .captcha-slider-button {
        width: 44px;
        height: 44px;
    }
}

/* ========================================
   暗色主题支持
======================================== */

@media (prefers-color-scheme: dark) {
    .captcha-wrapper {
        background: #1f2937;
        border-color: #374151;
    }
    
    .captcha-image-display,
    .captcha-slider-puzzle,
    .captcha-slider-track,
    .captcha-click-canvas-wrapper {
        background: #111827;
    }
    
    .captcha-image-input input,
    .captcha-click-actions button {
        background: #1f2937;
        border-color: #374151;
        color: #f3f4f6;
    }
    
    .captcha-slider-button {
        background: #1f2937;
        border-color: #374151;
    }
    
    .captcha-click-instruction {
        background: var(--primary-container);
        color: var(--on-surface);
    }
}

/* ========================================
   无障碍支持
======================================== */

@media (prefers-reduced-motion: reduce) {
    .captcha-wrapper,
    .captcha-slider-fill,
    .captcha-slider-button,
    .captcha-click-mark {
        animation: none;
        transition: none;
    }
}
