/* ui-enhancements.css - UI增强和优化 */

/* ==================== 1. 增强Spinner加载动画 ==================== */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spinner-rotate 0.8s linear infinite;
}

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

/* 大尺寸Spinner */
.spinner-large {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

/* 彩色Spinner */
.spinner-primary {
    border: 3px solid rgba(102, 126, 234, 0.2);
    border-top-color: #667eea;
}

/* ==================== 2. 表单验证视觉反馈 ==================== */
/* 错误状态 */
input.error, textarea.error {
    border-color: #ff4d4f !important;
    background-color: #fff1f0;
    animation: shake-input 0.5s ease;
}

input.error:focus, textarea.error:focus {
    border-color: #ff4d4f !important;
    box-shadow: 0 0 0 3px rgba(255, 77, 79, 0.1);
}

/* 成功状态 */
input.success, textarea.success {
    border-color: #52c41a !important;
    background-color: #f6ffed;
}

input.success:focus, textarea.success:focus {
    border-color: #52c41a !important;
    box-shadow: 0 0 0 3px rgba(82, 196, 26, 0.1);
}

/* 抖动动画 */
@keyframes shake-input {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
    20%, 40%, 60%, 80% { transform: translateX(8px); }
}

/* 错误消息样式 */
.error-message {
    color: #ff4d4f;
    font-size: 12px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    animation: fadeInDown 0.3s ease;
}

.error-message::before {
    content: '⚠️';
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== 3. 骨架屏流动动画 ==================== */
.skeleton, .skeleton-line, .loading-skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #f8f8f8 20%,
        #f0f0f0 40%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-line {
    height: 16px;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-line.short {
    width: 60%;
}

/* ==================== 4. 按钮增强样式 ==================== */
/* 按钮禁用状态 */
button:disabled,
.btn-primary:disabled,
.btn-secondary:disabled,
.btn-download:disabled,
.btn-polish:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(30%);
    transform: none !important;
}

/* 按钮加载状态 */
button.loading {
    position: relative;
    color: transparent !important;
}

button.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spinner-rotate 0.8s linear infinite;
}

/* 按钮悬浮提升效果 */
.btn-primary:not(:disabled):hover,
.btn-download:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 按钮点击缩放效果 */
.btn-primary:not(:disabled):active,
.btn-secondary:not(:disabled):active {
    transform: translateY(0) scale(0.98);
}

/* ==================== 5. 改进的拖拽区域 ==================== */
.upload-area {
    transition: all 0.3s ease;
}

.upload-area.dragover {
    background: linear-gradient(135deg, #e6f7ff 0%, #bae7ff 100%);
    border-color: #1890ff;
    border-style: solid;
    transform: scale(1.02);
    animation: pulse-border 0.6s ease-in-out infinite;
}

@keyframes pulse-border {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(24, 144, 255, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(24, 144, 255, 0);
    }
}

/* ==================== 6. 响应式优化 ==================== */
/* 平板设备 */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 240px 220px 1fr !important;
        gap: 0;
    }

    .polish-panel {
        width: 240px;
    }

    .outline-panel {
        width: 220px;
    }
}

/* 小屏幕设备 */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto auto 1fr;
    }

    .polish-panel,
    .outline-panel {
        max-height: 300px;
        overflow-y: auto;
    }

    .editor-panel {
        min-height: 500px;
    }
}

/* ==================== 7. 改进的Toast提示 ==================== */
.toast {
    animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.toast-hide {
    animation: slideOutRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* ==================== 8. 卡片悬浮效果增强 ==================== */
.card,
.feature-item,
.outline-node {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover,
.feature-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
}

/* ==================== 9. 进度指示器 ==================== */
.progress-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.3s ease;
    z-index: 9999;
}

.progress-indicator.loading {
    animation: progress-loading 2s ease-in-out infinite;
}

@keyframes progress-loading {
    0% {
        width: 0;
        left: 0;
    }
    50% {
        width: 50%;
        left: 25%;
    }
    100% {
        width: 0;
        left: 100%;
    }
}

/* ==================== 10. 滚动条美化 ==================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

/* ==================== 11. 焦点可见性优化 ==================== */
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* ==================== 12. 加载遮罩 ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.loading-overlay .spinner {
    width: 50px;
    height: 50px;
    border-width: 4px;
    margin-bottom: 20px;
}

.loading-overlay p {
    color: #666;
    font-size: 16px;
}

/* ==================== 13. 空状态样式 ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 16px;
    margin-bottom: 8px;
}

.empty-state-hint {
    font-size: 14px;
    color: #bbb;
}

/* ==================== 14. 平滑过渡 ==================== */
* {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== 15. 无障碍优化 ==================== */
/* 减少动画（用户偏好） */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    button,
    input,
    textarea {
        border-width: 2px;
    }
}

/* ==================== 16. 打印样式优化 ==================== */
@media print {
    .header,
    .polish-panel,
    .outline-panel,
    button,
    .toast-container {
        display: none !important;
    }

    .editor-panel {
        width: 100% !important;
        box-shadow: none !important;
    }
}
