/**
 * Ninan验证码样式 - 深色毛玻璃风格 - 响应式优化版
 */

/* 验证码模态框 */
.captcha-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background: rgba(0, 0, 0, 0.8);
    padding: 16px;
}

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

/* 内容容器 - 毛玻璃效果 */
.captcha-content {
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 720px;
    max-height: calc(100vh - 32px);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* 流光边框效果 */
.captcha-content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    transform: rotate(0deg);
    animation: captcha-flow 6s linear infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes captcha-flow {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 消息提示 */
.captcha-message {
    display: none;
    padding: 16px 24px;
    margin: 0;
    font-size: 14px;
    text-align: center;
    font-weight: 300;
    letter-spacing: 0.02em;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

.captcha-message.show {
    display: block;
}

.captcha-message.success {
    background: rgba(16, 185, 129, 0.1);
    color: rgba(16, 185, 129, 0.9);
    border-bottom: 1px solid rgba(16, 185, 129, 0.2);
}

.captcha-message.warning {
    background: rgba(251, 191, 36, 0.1);
    color: rgba(251, 191, 36, 0.9);
    border-bottom: 1px solid rgba(251, 191, 36, 0.2);
}

.captcha-message.error {
    background: rgba(239, 68, 68, 0.1);
    color: rgba(239, 68, 68, 0.9);
    border-bottom: 1px solid rgba(239, 68, 68, 0.2);
}

/* 头部 - 改为居左排列 */
.captcha-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    text-align: left;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

.captcha-header h3 {
    margin: 0 0 8px 0;
    font-size: 20px;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 0.05em;
}

.captcha-header p {
    margin: 0;
    color: rgba(255, 255, 255, 0.4);
    font-size: 14px;
    font-weight: 300;
    line-height: 1.4;
}

/* 主要内容区域 */
.captcha-main {
    flex: 1;
    overflow: hidden;
    position: relative;
    z-index: 2;
    min-height: 0;
}

/* 图片网格 */
.captcha-grid,
#captcha-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    padding: 24px;
    height: 100%;
    overflow-y: auto;
    position: relative;
}

/* 单个图片容器 */
.captcha-image {
    position: relative;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.captcha-image:hover,
.captcha-image:focus {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    outline: none;
}

/* 图片 */
.captcha-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0.8;
    transition: opacity 0.3s;
    pointer-events: none;
}

.captcha-image:hover img,
.captcha-image:focus img {
    opacity: 1;
}

/* 选中状态 */
.captcha-image.selected {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(0.95);
}

.captcha-image.selected img {
    opacity: 1;
}

/* 选中标记 */
.captcha-check {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: none;
}

.captcha-image.selected .captcha-check {
    opacity: 1;
    transform: scale(1);
}

/* 按钮区域 - 修复层级问题 */
.captcha-actions {
    padding: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: center;
    gap: 16px;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.01);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* 按钮基础样式 */
.captcha-actions button {
    padding: 12px 32px;
    font-size: 14px;
    font-weight: 300;
    letter-spacing: 0.05em;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-width: 80px;
    z-index: 11;
}

.captcha-actions button:focus {
    outline: 2px solid rgba(255, 255, 255, 0.3);
    outline-offset: 2px;
}

/* 取消按钮 */
.captcha-cancel {
    color: rgba(255, 255, 255, 0.4);
}

.captcha-cancel:hover,
.captcha-cancel:focus {
    color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

/* 确认按钮 - 流光效果 */
.captcha-confirm {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
}

.captcha-confirm::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transform: rotate(0deg);
    animation: button-flow 3s linear infinite;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: -1;
}

.captcha-confirm:hover::before,
.captcha-confirm:focus::before {
    opacity: 1;
}

.captcha-confirm:hover,
.captcha-confirm:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 255, 255, 0.1);
}

.captcha-confirm:disabled {
    color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.01);
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.05);
}

.captcha-confirm:disabled::before {
    display: none;
}

@keyframes button-flow {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 加载状态 */
.captcha-loading {
    text-align: center;
    padding: 80px 20px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 14px;
    font-weight: 300;
    letter-spacing: 0.05em;
}

.captcha-loading::after {
    content: '';
    display: block;
    width: 32px;
    height: 32px;
    margin: 20px auto 0;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    animation: loading-spin 1s linear infinite;
}

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

/* 平板设备优化 */
@media (max-width: 1024px) and (min-width: 641px) {
    .captcha-grid,
    #captcha-images {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 14px;
    }
}

/* 响应式 - 移动端优化 */
@media (max-width: 640px) {
    .captcha-modal {
        padding: 12px;
        align-items: flex-end;
    }

    .captcha-content {
        max-height: calc(100vh - 24px);
        border-radius: 16px 16px 0 0;
        width: 100%;
    }
    
    .captcha-header {
        padding: 20px 16px;
    }
    
    .captcha-header h3 {
        font-size: 18px;
    }

    .captcha-header p {
        font-size: 13px;
    }
    
    /* 移动端自适应列数 */
    .captcha-grid,
    #captcha-images {
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
        gap: 12px;
        padding: 16px;
    }
    
    .captcha-actions {
        padding: 16px;
        gap: 12px;
        flex-direction: column-reverse;
        position: sticky;
        bottom: 0;
        margin-top: auto;
    }
    
    .captcha-actions button {
        padding: 14px 24px;
        font-size: 15px;
        width: 100%;
        border-radius: 12px;
    }
    
    .captcha-check {
        width: 28px;
        height: 28px;
        font-size: 16px;
        top: 8px;
        right: 8px;
    }

    .captcha-message {
        padding: 12px 16px;
        font-size: 13px;
    }
}

/* 小屏幕设备 */
@media (max-width: 420px) {
    .captcha-modal {
        padding: 8px;
    }

    .captcha-content {
        border-radius: 12px 12px 0 0;
    }

    .captcha-grid,
    #captcha-images {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
        gap: 10px;
        padding: 12px;
    }

    .captcha-header {
        padding: 16px 12px;
    }

    .captcha-actions {
        padding: 12px;
    }

    .captcha-actions button {
        padding: 12px 20px;
        font-size: 14px;
    }
}

/* 极小屏幕 */
@media (max-width: 320px) {
    .captcha-grid,
    #captcha-images {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

/* 横屏优化 */
@media (max-height: 640px) and (orientation: landscape) {
    .captcha-modal {
        align-items: center;
    }

    .captcha-content {
        max-height: calc(100vh - 16px);
        border-radius: 16px;
    }

    .captcha-header {
        padding: 16px 24px;
    }

    .captcha-grid,
    #captcha-images {
        padding: 16px 24px;
    }

    .captcha-actions {
        padding: 16px 24px;
        flex-direction: row;
        position: relative;
        bottom: auto;
    }

    .captcha-actions button {
        width: auto;
    }
}

/* 滚动条美化 */
.captcha-grid::-webkit-scrollbar,
#captcha-images::-webkit-scrollbar {
    width: 6px;
}

.captcha-grid::-webkit-scrollbar-track,
#captcha-images::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 3px;
}

.captcha-grid::-webkit-scrollbar-thumb,
#captcha-images::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.captcha-grid::-webkit-scrollbar-thumb:hover,
#captcha-images::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 动画优化 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.captcha-modal.show .captcha-content {
    animation: fadeIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* 噪点纹理（可选） */
.captcha-content::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.015;
    pointer-events: none;
    background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMDAiIGhlaWdodD0iMzAwIj48ZmlsdGVyIGlkPSJhIj48ZmVUdXJidWxlbmNlIGJhc2VGcmVxdWVuY3k9Ii45IiBudW1PY3RhdmVzPSI0IiBzZWVkPSIyIi8+PC9maWx0ZXI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsdGVyPSJ1cmwoI2EpIiBvcGFjaXR5PSIxIi8+PC9zdmc+');
    z-index: 1;
}

/* 减少动画以提升性能 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}