/**
 * 人机验证系统 V4 - 前端自适应样式表 (Responsive CSS)
 * 适配 PC 鼠标端与移动端 Touch 触控
 */

.v4-captcha-container {
    position: relative;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    border: 1px solid #eef0f5;
    padding: 12px;
    width: 364px;
    max-width: 100%;
    margin: 0 auto;
}

/* 顶部提示栏 */
.v4-captcha-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
    color: #4a5568;
    line-height: 1.4;
}

.v4-captcha-hint {
    font-weight: 500;
    color: #2d3748;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.v4-captcha-refresh {
    cursor: pointer;
    color: #a0aec0;
    font-size: 16px;
    transition: transform 0.3s ease, color 0.2s;
    padding: 2px 4px;
}

.v4-captcha-refresh:hover {
    color: #3182ce;
    transform: rotate(180deg);
}

/* 图片画布展示区域 */
.v4-captcha-stage {
    position: relative;
    width: 340px;
    height: 220px;
    border-radius: 6px;
    overflow: hidden;
    background-color: #f7fafc;
    background-size: cover;
    background-position: center;
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.1);
}

.v4-captcha-bg {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: fill;
}

/* 移动切片 */
.v4-captcha-piece {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    cursor: pointer;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.35));
    transition: filter 0.2s ease;
}

/* 手绘/图层 Canvas */
.v4-captcha-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 15;
    cursor: crosshair;
}

/* 点选标记徽标 */
.v4-click-badge {
    position: absolute;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    border-radius: 50%;
    background: #3182ce;
    color: #ffffff;
    font-size: 12px;
    font-weight: bold;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 8px rgba(49, 130, 206, 0.6);
    z-index: 20;
    animation: v4-pop 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes v4-pop {
    0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* 宫格拼图 Grid (2x2) */
.v4-grid-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    grid-gap: 3px;
    width: 100%;
    height: 100%;
    background: #1a202c;
    border-radius: 4px;
    overflow: hidden;
}

.v4-grid-tile {
    width: 100%;
    height: 100%;
    cursor: pointer;
    background-size: cover;
    background-position: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    border-radius: 2px;
}

.v4-grid-tile:hover {
    filter: brightness(1.08);
}

.v4-grid-tile.selected {
    box-shadow: inset 0 0 0 3px #38a169, 0 0 10px rgba(56, 161, 105, 0.8);
    transform: scale(0.95);
    z-index: 2;
}

/* 底部滑块轨道 */
.v4-captcha-track {
    position: relative;
    height: 40px;
    background: #edf2f7;
    border-radius: 20px;
    margin-top: 12px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.v4-track-text {
    position: absolute;
    width: 100%;
    height: 100%;
    text-align: center;
    line-height: 40px;
    font-size: 13px;
    color: #718096;
    pointer-events: none;
}

.v4-track-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: #ebf8ff;
    border-radius: 20px 0 0 20px;
    border-right: 1px solid #bee3f8;
    width: 0;
}

.v4-track-handle {
    position: absolute;
    top: 0;
    left: 0;
    width: 40px;
    height: 40px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    z-index: 5;
}

.v4-track-handle:active {
    cursor: grabbing;
    background: #3182ce;
}

.v4-track-handle:active .v4-handle-icon {
    color: #ffffff;
}

.v4-handle-icon {
    font-size: 14px;
    color: #4a5568;
}

/* 状态提示浮层 */
.v4-status-banner {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 6px 12px;
    font-size: 12px;
    text-align: center;
    color: #ffffff;
    z-index: 25;
    transition: transform 0.25s ease;
    transform: translateY(100%);
}

.v4-status-banner.show {
    transform: translateY(0);
}

.v4-status-banner.success {
    background: rgba(72, 187, 120, 0.92);
}

.v4-status-banner.failure {
    background: rgba(245, 101, 101, 0.92);
}

/* 加载中动画 */
.v4-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 30;
    font-size: 12px;
    color: #718096;
}

.v4-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e2e8f0;
    border-top-color: #3182ce;
    border-radius: 50%;
    animation: v4-spin 0.8s linear infinite;
    margin-bottom: 6px;
}

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