/**
 * 用户封面图上传样式
 *
 * @package    Hui
 * @subpackage User_Cover
 * @since      1.2.0
 * @version    1.4.0 - 添加裁剪样式
 */

/* 加载动画 */
@keyframes huiSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes huiToastFadeOut {
    from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    to { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

.animate-spin {
    animation: huiSpin 1s linear infinite;
}

/* ============================================================================
   封面上传弹窗
   ============================================================================ */

.hui-cover-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.hui-cover-modal.is-active {
    display: flex;
}

.hui-cover-modal__overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-bg-mask, rgba(0, 0, 0, 0.45));
    backdrop-filter: blur(4px);
}

.hui-cover-modal__container {
    position: relative;
    width: 90%;
    max-width: 600px;
    background: var(--color-bg-container, #fff);
    border-radius: var(--xun-radius-lg, 12px);
    box-shadow: var(--shadow-modal, 0 20px 25px -5px rgba(0, 0, 0, 0.1));
    overflow: hidden;
    animation: huiModalFadeIn 0.2s ease-out;
}

@keyframes huiModalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.hui-cover-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border-secondary, #f0f0f0);
}

.hui-cover-modal__title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text, #171717);
}

.hui-cover-modal__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--radius-full, 9999px);
    color: var(--color-text-tertiary, #999);
    cursor: pointer;
    transition: all 0.2s ease;
}

.hui-cover-modal__close:hover {
    background: var(--color-fill-secondary, rgba(0, 0, 0, 0.06));
    color: var(--color-text, #171717);
}

.hui-cover-modal__body {
    padding: 1.5rem 1.25rem;
    min-height: 300px;
}

/* 上传区域 */
.hui-cover-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 2rem;
    background: var(--color-fill-quaternary, rgba(0, 0, 0, 0.02));
    border: 2px dashed var(--color-border, #e5e5e5);
    border-radius: var(--xun-radius, 8px);
    cursor: pointer;
    transition: all 0.2s ease;
}

.hui-cover-upload-area:hover {
    border-color: var(--xun-secondary, var(--color-secondary));
    background: var(--color-fill-tertiary, rgba(0, 0, 0, 0.04));
}

.hui-cover-upload-area.is-dragover {
    border-color: var(--xun-secondary, var(--color-secondary));
    background: oklch(from var(--xun-secondary, var(--color-secondary)) l c h / 0.1);
}

.hui-cover-upload-icon {
    color: var(--color-text-quaternary, #ccc);
    margin-bottom: 1rem;
}

.hui-cover-upload-text {
    margin: 0 0 0.5rem 0;
    font-size: 0.9375rem;
    color: var(--color-text-secondary, #666);
}

.hui-cover-upload-hint {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--color-text-tertiary, #999);
}

/* 上传进度 */
.hui-cover-upload-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 2rem;
}

.hui-cover-upload-progress-bar {
    width: 200px;
    height: 4px;
    background: var(--color-fill-secondary, rgba(0, 0, 0, 0.06));
    border-radius: 2px;
    overflow: hidden;
}

.hui-cover-upload-progress-fill {
    width: 30%;
    height: 100%;
    background: var(--color-text, #171717);
    animation: huiProgressPulse 1.5s ease-in-out infinite;
}

@keyframes huiProgressPulse {
    0%, 100% { width: 30%; margin-left: 0; }
    50% { width: 50%; margin-left: 50%; }
}

.hui-cover-upload-progress-text {
    margin: 1rem 0 0 0;
    font-size: 0.875rem;
    color: var(--color-text-tertiary, #999);
}

/* ============================================================================
   裁剪步骤
   ============================================================================ */

.hui-cover-step-crop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.hui-cover-crop-container {
    display: flex;
    justify-content: center;
    width: 100%;
}

.hui-cover-crop-wrapper {
    position: relative;
    display: inline-block;
    background: #f5f5f5;
    border-radius: var(--xun-radius, 8px);
    overflow: hidden;
}

#hui-cover-crop-image {
    display: block;
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--xun-radius, 8px);
}

/* 裁剪框 */
.hui-cover-crop-box {
    position: absolute;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3);
    cursor: move;
    z-index: 2;
    background: transparent;
}

.hui-cover-crop-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
}

/* 裁剪框网格线 */
.hui-cover-crop-box::after {
    content: '';
    position: absolute;
    top: 33.33%;
    left: 0;
    right: 0;
    height: 33.33%;
    border-top: 1px dashed rgba(255, 255, 255, 0.3);
    border-bottom: 1px dashed rgba(255, 255, 255, 0.3);
    pointer-events: none;
}

/* 调整大小手柄 */
.hui-cover-crop-handle {
    position: absolute;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.2);
    z-index: 3;
}

/* 四个角的手柄 */
.hui-cover-crop-handle-nw,
.hui-cover-crop-handle-ne,
.hui-cover-crop-handle-sw,
.hui-cover-crop-handle-se {
    width: 12px;
    height: 12px;
}

.hui-cover-crop-handle-nw {
    left: -6px;
    top: -6px;
    cursor: nw-resize;
}

.hui-cover-crop-handle-ne {
    right: -6px;
    top: -6px;
    cursor: ne-resize;
}

.hui-cover-crop-handle-sw {
    left: -6px;
    bottom: -6px;
    cursor: sw-resize;
}

.hui-cover-crop-handle-se {
    right: -6px;
    bottom: -6px;
    cursor: se-resize;
}

/* 四条边的手柄 */
.hui-cover-crop-handle-n,
.hui-cover-crop-handle-s {
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 8px;
    border-radius: 4px;
}

.hui-cover-crop-handle-n {
    top: -4px;
    cursor: n-resize;
}

.hui-cover-crop-handle-s {
    bottom: -4px;
    cursor: s-resize;
}

.hui-cover-crop-handle-e,
.hui-cover-crop-handle-w {
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 30px;
    border-radius: 4px;
}

.hui-cover-crop-handle-e {
    right: -4px;
    cursor: e-resize;
}

.hui-cover-crop-handle-w {
    left: -4px;
    cursor: w-resize;
}

/* 预览区域 */
.hui-cover-crop-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.hui-cover-crop-preview-box {
    width: 240px;
    height: 80px;
    border-radius: var(--xun-radius, 8px);
    background-color: #f5f5f5;
    background-repeat: no-repeat;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.hui-cover-crop-preview-label {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--color-text-tertiary, #999);
}

/* ============================================================================
   弹窗底部
   ============================================================================ */

.hui-cover-modal__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--color-border-secondary, #f0f0f0);
}

.hui-cover-modal__footer .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--xun-radius, 8px);
    cursor: pointer;
    transition: all 0.2s ease;
}

.hui-cover-modal__footer .btn-ghost {
    background: transparent;
    border: 1px solid var(--color-border, #e5e5e5);
    color: var(--color-text-secondary, #666);
}

.hui-cover-modal__footer .btn-ghost:hover {
    background: var(--color-fill-secondary, rgba(0, 0, 0, 0.06));
}

.hui-cover-modal__footer .btn-primary {
    background: var(--color-text, #171717);
    border: 1px solid var(--color-text, #171717);
    color: #fff;
}

.hui-cover-modal__footer .btn-primary:hover:not(:disabled) {
    background: var(--color-text-secondary, #666);
    border-color: var(--color-text-secondary, #666);
}

.hui-cover-modal__footer .btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.hui-cover-btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

/* ============================================================================
   深色模式适配
   ============================================================================ */

@media (prefers-color-scheme: dark) {
    :root:not(.light) .hui-cover-modal__container {
        background: var(--color-bg-container);
    }
    
    :root:not(.light) .hui-cover-upload-area {
        background: var(--color-fill-quaternary);
        border-color: var(--color-border);
    }
    
    :root:not(.light) .hui-cover-crop-preview-box {
        background-color: #333;
    }
}

.dark .hui-cover-modal__container {
    background: var(--color-bg-container);
}

.dark .hui-cover-upload-area {
    background: var(--color-fill-quaternary);
    border-color: var(--color-border);
}

.dark .hui-cover-crop-preview-box {
    background-color: #333;
}

/* ============================================================================
   响应式设计
   ============================================================================ */

@media (max-width: 768px) {
    .hui-cover-modal__container {
        width: 95%;
        max-width: none;
        margin: 1rem;
    }
    
    .hui-cover-modal__body {
        padding: 1rem;
    }
    
    .hui-cover-upload-area {
        min-height: 160px;
        padding: 1.5rem;
    }
    
    #hui-cover-crop-image {
        max-height: 200px;
    }
    
    .hui-cover-crop-preview-box {
        width: 180px;
        height: 60px;
    }
}
