/**
 * AI 格式化助手弹窗样式
 * 采用 BEM 命名规范，避免样式污染
 */

/* ============================================
   弹窗容器
   ============================================ */
.ai-formatter-modal {
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

/* ============================================
   弹窗头部
   ============================================ */
.ai-formatter-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 24px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.ai-formatter-header-left h2 {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 600;
}

.ai-formatter-subtitle {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

.modal-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 28px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* ============================================
   弹窗主体
   ============================================ */
.ai-formatter-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* 步骤指示器 */
.step-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e5e7eb;
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e5e7eb;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s;
}

.step-number.active {
    background: var(--primary-color);
    color: white;
    animation: pulse 2s infinite;
}

.step-number.success {
    background: var(--success-color);
    color: white;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(102, 126, 234, 0);
    }
}

.step-label {
    font-size: 16px;
    font-weight: 600;
    color: #374151;
}

/* ============================================
   上传区域
   ============================================ */
.formatter-upload-zone {
    border: 3px dashed #d1d5db;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #f9fafb;
}

.formatter-upload-zone:hover,
.formatter-upload-zone--drag-over {
    border-color: #667eea;
    background: #f0f4ff;
}

.formatter-upload-zone--has-file {
    border-color: #10b981;
    background: #f0fdf4;
}

.formatter-upload-zone__icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.formatter-upload-zone__text {
    font-size: 16px;
    color: #374151;
    margin-bottom: 8px;
    font-weight: 500;
}

.formatter-upload-zone__hint {
    font-size: 13px;
    color: #6b7280;
}

.formatter-file-input {
    display: none;
}

/* 文件信息 */
.formatter-file-info {
    display: none;
    margin-top: 16px;
    padding: 16px;
    background: #f0f4ff;
    border-radius: 10px;
    border-left: 4px solid #667eea;
    align-items: center;
    gap: 12px;
}

.formatter-file-info--show {
    display: flex;
}

.formatter-file-info__icon {
    font-size: 24px;
}

.formatter-file-info__details {
    flex: 1;
}

.formatter-file-info__name {
    font-weight: 600;
    color: #667eea;
    margin-bottom: 4px;
}

.formatter-file-info__size {
    font-size: 13px;
    color: #6b7280;
}

.formatter-file-info__remove {
    background: none;
    border: none;
    color: #dc2626;
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.formatter-file-info__remove:hover {
    background: #fee2e2;
}

/* ============================================
   进度条
   ============================================ */
.formatter-progress {
    margin-top: 20px;
}

.formatter-progress__bar-container {
    background: #e5e7eb;
    border-radius: 10px;
    height: 12px;
    overflow: hidden;
    margin-bottom: 12px;
}

.formatter-progress__bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    width: 0%;
    transition: width 0.3s;
    border-radius: 10px;
}

.formatter-progress__text {
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

/* AI 彩环进度样式 */
.formatter-progress-ai {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.formatter-progress-ring {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 彩环渐变边框容器 */
.formatter-progress-ring::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    background: conic-gradient(
        from var(--angle, 0deg),
        #00ffff,
        #9d00ff,
        #007bff,
        #9d00ff,
        #00ffff
    );
    z-index: 0;
    animation: ai-glow-rotate 3s linear infinite;
    opacity: 0.8;
}

/* 内部遮罩 */
.formatter-progress-ring::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--card-bg, #ffffff);
    border-radius: 50%;
    z-index: 1;
}

/* SVG 圆环 */
.progress-ring {
    position: relative;
    z-index: 2;
    transform: rotate(-90deg);
    filter: drop-shadow(0 0 8px rgba(0, 255, 255, 0.3));
}

.progress-ring__bg {
    fill: none;
    stroke: #e5e7eb;
    stroke-width: 6;
}

.progress-ring__circle {
    fill: none;
    stroke-width: 6;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.35s;
    filter: drop-shadow(0 0 6px currentColor);
}

/* 中心百分比 */
.formatter-progress-percentage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    font-size: 28px;
    font-weight: 700;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* 进度文本 */
.formatter-progress-ai .formatter-progress__text {
    font-size: 15px;
    color: #6b7280;
    font-weight: 500;
    text-align: center;
    min-height: 24px;
}

/* ============================================
   统计网格
   ============================================ */
.formatter-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.formatter-stat-card {
    background: #f9fafb;
    padding: 16px;
    border-radius: 10px;
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.3s;
}

.formatter-stat-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
}

.formatter-stat-card__number {
    font-size: 28px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 4px;
}

.formatter-stat-card__label {
    font-size: 13px;
    color: #6b7280;
}

/* ============================================
   结果预览
   ============================================ */
.formatter-result-preview {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
}

.formatter-result-preview__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
}

.formatter-result-preview__header h4 {
    margin: 0;
    font-size: 16px;
    color: #374151;
}

.formatter-result-preview__actions {
    display: flex;
    gap: 8px;
    position: relative;
}

/* 导出下拉菜单 */
.formatter-export-dropdown {
    position: relative;
}

.formatter-export-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 160px;
    z-index: 1000;
    display: none;
    overflow: hidden;
}

.formatter-export-menu--show {
    display: block;
    animation: dropdownFadeIn 0.2s ease;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.formatter-export-menu__item {
    width: 100%;
    padding: 10px 16px;
    background: white;
    border: none;
    text-align: left;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.formatter-export-menu__item:hover {
    background: #f3f4f6;
    color: #667eea;
}

.formatter-export-menu__item:active {
    background: #e5e7eb;
}

.formatter-result-preview__content {
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    background: white;
}

.formatter-result-preview__content::-webkit-scrollbar {
    width: 8px;
}

.formatter-result-preview__content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.formatter-result-preview__content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.formatter-result-preview__content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ============================================
   按钮样式
   ============================================ */
.formatter-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 500;
}

.formatter-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.formatter-btn--sm {
    padding: 6px 12px;
    font-size: 13px;
}

.formatter-btn--large {
    padding: 12px 24px;
    font-size: 15px;
}

.formatter-btn--primary {
    background: var(--primary-color);
    color: white;
}

.formatter-btn--primary:hover:not(:disabled) {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.formatter-btn--secondary {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.formatter-btn--secondary:hover:not(:disabled) {
    background: #f0f4ff;
}

.formatter-btn--success {
    background: var(--success-color);
    color: white;
}

.formatter-btn--success:hover:not(:disabled) {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.formatter-btn--warning {
    background: #f59e0b;
    color: white;
}

.formatter-btn--warning:hover:not(:disabled) {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

/* 操作按钮组 */
.formatter-action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

/* ============================================
   弹窗底部
   ============================================ */
.ai-formatter-footer {
    padding: 20px 24px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 0 0 12px 12px;
}

.formatter-footer-actions {
    display: flex;
    justify-content: flex-end;
}

/* 错误消息 */
.formatter-error-message {
    display: none;
    background: #fee2e2;
    color: #dc2626;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    border-left: 4px solid #dc2626;
    font-size: 14px;
}

.formatter-error-message--show {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   加载动画
   ============================================ */
.formatter-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   响应式设计
   ============================================ */
@media (max-width: 768px) {
    .ai-formatter-modal {
        width: 95%;
        max-height: 95vh;
    }

    .ai-formatter-header {
        padding: 16px;
    }

    .ai-formatter-header-left h2 {
        font-size: 20px;
    }

    .ai-formatter-body {
        padding: 16px;
    }

    .formatter-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .formatter-action-buttons {
        grid-template-columns: 1fr;
    }

    .formatter-result-preview__header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
}

/* ============================================
   AI 彩环动画关键帧
   ============================================ */
@keyframes ai-glow-rotate {
    0% { 
        --angle: 0deg; 
    }
    100% { 
        --angle: 360deg; 
    }
}

/* 为不支持 CSS @property 的浏览器提供回退方案 */
@property --angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}
