/**
 * 拼图验证码样式
 *
 * @author Claude
 * @create 2025-01-16
 */

/* 拼图验证容器 */
.puzzle-captcha-container {
    width: 330px;
    margin: 15px auto;
    border: 1px solid #e6e6e6;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* 加载状态 */
.captcha-loading {
    padding: 40px 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

.captcha-loading i {
    font-size: 20px;
    margin-right: 8px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* 验证码内容区域 */
.captcha-content {
    padding: 15px;
}

/* 图片区域 */
.captcha-image-area {
    position: relative;
    width: 300px;
    height: 150px;
    margin: 0 auto 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    background: #f5f5f5;
}

.background-image {
    width: 100%;
    height: 100%;
    display: block;
}

.puzzle-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 76px;  /* 修复：与后端生成的76px一致 */
    height: 76px; /* 修复：与后端生成的76px一致 */
    display: block;
    cursor: move;
    transition: none;
    z-index: 10;
}

/* 刷新按钮 */
.refresh-captcha {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0,0,0,0.3);
    border: none;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background-color 0.3s;
}

.refresh-captcha:hover {
    background: rgba(0,0,0,0.5);
}

.refresh-captcha:active {
    transform: scale(0.95);
}

/* 滑块轨道 */
.slide-track {
    position: relative;
    width: 100%;
    height: 40px;
    background: #f7f9fa;
    border: 1px solid #e4e7eb;
    border-radius: 20px;
    overflow: hidden;
    margin-top: 10px;
}

/* 滑块进度条 */
.slide-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #52ccba 0%, #1acba6 100%);
    border-radius: 20px;
    transition: width 0.1s ease-out;
    z-index: 1; /* 确保进度条在按钮下方 */
}

/* 滑块按钮 */
.slide-button {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 36px;
    height: 36px;
    background: #fff;
    border-radius: 50%;
    cursor: move;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #52ccba;
    transition: none;
    user-select: none;
    z-index: 2; /* 确保按钮在进度条上方 */
}

.slide-button:hover {
    box-shadow: 0 3px 12px rgba(0,0,0,0.2);
}

.slide-button.dragging {
    cursor: grabbing;
}

/* 滑块文本 */
.slide-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #999;
    font-size: 14px;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 3; /* 确保文本在最上层 */
}

.slide-text.hidden {
    opacity: 0;
}

/* 错误状态 */
.captcha-error {
    padding: 20px;
    text-align: center;
    color: #ff4757;
    font-size: 14px;
}

.error-text {
    margin-bottom: 10px;
}

.retry-button {
    background: #ff4757;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.3s;
}

.retry-button:hover {
    background: #ff3838;
}

/* 成功状态 */
.captcha-success {
    background: #2ed573;
    color: #fff;
    padding: 8px;
    text-align: center;
    border-radius: 4px;
    font-size: 14px;
    animation: fadeIn 0.3s ease-out;
}

/* 验证状态指示器 */
.captcha-status {
    height: 4px;
    background: #e4e7eb;
    border-radius: 2px;
    margin-bottom: 10px;
    overflow: hidden;
}

.captcha-status-bar {
    height: 100%;
    width: 0;
    transition: width 0.3s ease-out;
    border-radius: 2px;
}

.captcha-status-bar.loading {
    background: #ffa502;
    animation: pulse 1.5s ease-in-out infinite;
}

.captcha-status-bar.success {
    background: #2ed573;
    width: 100%;
}

.captcha-status-bar.error {
    background: #ff4757;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 响应式设计 */
@media (max-width: 360px) {
    .puzzle-captcha-container {
        width: 280px;
        margin: 15px auto;
    }

    .captcha-image-area {
        width: 250px;
        height: 125px;
    }

    .slide-text {
        font-size: 12px;
    }
}

/* 深色主题支持 */
@media (prefers-color-scheme: dark) {
    .puzzle-captcha-container {
        background: #2c3e50;
        border-color: #34495e;
        color: #ecf0f1;
    }

    .captcha-image-area {
        border-color: #34495e;
        background: #34495e;
    }

    .slide-track {
        background: #34495e;
        border-color: #4a5f7a;
    }

    .slide-text {
        color: #bdc3c7;
    }
}

/* 动画效果 */
.puzzle-image.dragging {
    cursor: grabbing;
    transform: scale(1.05);
}

.slide-button.dragging {
    transform: scale(1.1);
}

/* 辅助功能 */
.slide-button:focus {
    outline: 2px solid #52ccba;
    outline-offset: 2px;
}

.refresh-captcha:focus {
    outline: 2px solid #52ccba;
    outline-offset: 2px;
}

/* 触摸设备优化 */
@media (pointer: coarse) {
    .slide-button {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    .refresh-captcha {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}