/* 
 * 安全验证码系统 - 主样式
 * 支持滑块、点击、拼图、文字四种验证模式
 */

.captcha-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    max-width: 380px;
    margin: 0 auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

.captcha-header {
    padding: 16px 20px 12px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.captcha-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.captcha-type-badge {
    font-size: 11px;
    color: #999;
    background: #f5f5f5;
    padding: 2px 10px;
    border-radius: 10px;
}

.captcha-body {
    padding: 20px;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* 滑块验证 */
.captcha-slider-area {
    width: 100%;
    position: relative;
    margin-bottom: 16px;
}

.captcha-slider-bg {
    width: 100%;
    height: 160px;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    border: 1px solid #e8e8e8;
}

.captcha-slider-gap {
    position: absolute;
    border: 2px solid #fff;
    border-radius: 4px;
    box-shadow: 0 0 8px rgba(0,0,0,0.3);
    background: rgba(0,0,0,0.35);
    z-index: 2;
}

.captcha-slider-piece {
    position: absolute;
    z-index: 3;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    border: 2px solid rgba(255,255,255,0.8);
    cursor: pointer;
    transition: left 0.05s linear;
}

.captcha-slider-track {
    width: 100%;
    height: 42px;
    background: #f5f7fa;
    border-radius: 21px;
    position: relative;
    border: 1px solid #e8e8e8;
    cursor: pointer;
    touch-action: none;
}

.captcha-slider-progress {
    height: 100%;
    border-radius: 21px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    transition: width 0.1s ease;
    width: 0%;
}

.captcha-slider-btn {
    position: absolute;
    top: -4px;
    left: -4px;
    width: 50px;
    height: 50px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(102,126,234,0.4);
    cursor: pointer;
    overflow: hidden;
    transition: left 0.05s linear;
    touch-action: none;
    z-index: 2;
    border: 2px solid #fff;
}

.captcha-slider-btn:active {
    transform: scale(1.05);
}

.captcha-slider-btn .arrow {
    display: inline-block;
    transition: transform 0.3s;
}

.captcha-slider-btn.success {
    background: linear-gradient(135deg, #28a745, #20c997);
}

.captcha-slider-btn.fail {
    background: linear-gradient(135deg, #dc3545, #e74c3c);
}

.captcha-slider-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #aaa;
    font-size: 13px;
    z-index: 1;
    pointer-events: none;
}

/* 点击验证 */
.captcha-click-area {
    width: 100%;
    position: relative;
}

.captcha-click-bg {
    width: 100%;
    height: 180px;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    border: 1px solid #e8e8e8;
    cursor: pointer;
}

.captcha-click-target {
    position: absolute;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(102,126,234,0.3);
    border: 2px solid #667eea;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #667eea;
    pointer-events: none;
    animation: clickTargetPop 0.3s ease;
}

.captcha-click-order {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.captcha-click-order-item {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #667eea;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s;
}

.captcha-click-order-item.done {
    background: #28a745;
    opacity: 0.6;
}

/* 拼图验证 */
.captcha-puzzle-area {
    width: 100%;
}

.puzzle-hint {
    text-align: center;
    font-size: 13px;
    color: #888;
    margin-bottom: 10px;
    padding: 6px 10px;
    background: #f8f9fe;
    border-radius: 6px;
    border: 1px solid #e8ecf4;
}

.captcha-puzzle-grid {
    display: grid;
    gap: 4px;
    margin-bottom: 12px;
}

.captcha-puzzle-piece {
    aspect-ratio: 1;
    border-radius: 6px;
    background-size: cover;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent;
    position: relative;
}

.captcha-puzzle-piece:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.captcha-puzzle-piece.selected {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.3);
}

.captcha-puzzle-piece.placed {
    border-color: #28a745;
    opacity: 0.7;
    cursor: default;
}

.captcha-puzzle-piece .piece-id {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

/* 文字验证码 */
.captcha-text-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    width: 100%;
}

.captcha-text-input {
    width: 100%;
    height: 42px;
    padding: 0 14px;
    border: 2px solid #e1e5ee;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.3s;
    letter-spacing: 4px;
    box-sizing: border-box;
}

.captcha-text-input:focus {
    border-color: #667eea;
}

.captcha-text-img {
    width: 100%;
    max-width: 320px;
    height: auto;
    aspect-ratio: 320 / 180;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid #e8e8e8;
    transition: opacity 0.3s;
    object-fit: contain;
}

.captcha-text-img:hover {
    opacity: 0.8;
}

/* 验证结果 */
.captcha-result {
    padding: 12px 20px;
    font-size: 13px;
    display: none;
    align-items: center;
    gap: 6px;
}

.captcha-result.show {
    display: flex;
}

.captcha-result.success {
    background: #e8f5e9;
    color: #2e7d32;
}

.captcha-result.fail {
    background: #fbe9e7;
    color: #c62828;
}

.captcha-result .icon {
    font-size: 16px;
}

/* 加载动画 */
.captcha-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #999;
    font-size: 13px;
    padding: 40px 0;
}

.captcha-loading .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e8e8e8;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes clickTargetPop {
    0% { transform: scale(0); opacity: 0; }
    70% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* 暗色模式适配 */
@media (prefers-color-scheme: dark) {
    .captcha-container {
        background: #1e1e2e;
        box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    }
    .captcha-header { border-color: #333; }
    .captcha-title { color: #cdd6f4; }
    .captcha-slider-track { background: #313244; border-color: #45475a; }
    .captcha-text-input { background: #313244; border-color: #45475a; color: #cdd6f4; }
    .captcha-loading .spinner { border-color: #45475a; border-top-color: #89b4fa; }
}
