/**
 * ATACAJUNTO APP - 背景图编辑器样式
 * css/pages/background-editor.css
 * 
 * 抖音风格：背景图右侧定位，左侧毛玻璃渐变效果
 */

/* ========================================
   背景编辑器遮罩层
   ======================================== */
.bg-editor-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.bg-editor-overlay.active {
    opacity: 1;
    visibility: visible;
}

.bg-editor-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background: #1a1a1a;
}

/* ========================================
   头部
   ======================================== */
.bg-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    padding-top: calc(16px + env(safe-area-inset-top, 0));
    background: #1a1a1a;
    border-bottom: 1px solid #333;
}

.bg-editor-title {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
}

.bg-editor-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    padding: 8px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.bg-editor-close:hover {
    opacity: 1;
}

/* ========================================
   当前背景预览区 - 抖音风格
   ======================================== */
.bg-current-section {
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: #1a1a1a;
}

.bg-current-preview {
    width: 100%;
    height: 180px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    background: #2a2a2a;
    cursor: pointer;
}

.bg-current-preview.has-image {
    cursor: pointer;
}

/* 背景图片 - 全宽显示 */
.bg-preview-image {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: cover;
    background-position: center;
    border-radius: 12px;
}

/* 左侧毛玻璃效果 - 已禁用 */
.bg-preview-blur {
    display: none;
}

/* 占位符 */
.bg-preview-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #666;
    gap: 8px;
}

.bg-preview-placeholder i {
    font-size: 40px;
    opacity: 0.5;
}

.bg-preview-placeholder span {
    font-size: 14px;
}

.bg-current-label {
    color: #888;
    font-size: 14px;
    margin-top: 12px;
    text-align: center;
}

/* ========================================
   裁剪区域
   ======================================== */
.bg-crop-section {
    flex: 1;
    display: none;
    flex-direction: column;
    background: #000;
    position: relative;
    overflow: hidden;
}

.bg-crop-section.active {
    display: flex;
}

.bg-crop-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.bg-crop-container img {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

/* 裁剪提示 */
.bg-crop-hint {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10;
}

.bg-crop-hint i {
    font-size: 14px;
}

/* Cropper.js 自定义样式 - 矩形裁剪框 */
.bg-crop-section .cropper-view-box {
    border-radius: 8px;
    outline: 2px solid #FF8C42;
}

.bg-crop-section .cropper-face {
    border-radius: 8px;
    background-color: rgba(255, 140, 66, 0.1);
}

.bg-crop-section .cropper-dashed {
    border-color: rgba(255, 255, 255, 0.3);
}

.bg-crop-section .cropper-point {
    background-color: #FF8C42;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

/* 上传进度条 */
.bg-upload-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    display: none;
    z-index: 20;
}

.bg-upload-progress.active {
    display: block;
}

.bg-upload-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #FF8C42, #FF6B35);
    width: 0%;
    transition: width 0.3s ease;
}

.bg-upload-percent {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.7);
    padding: 4px 12px;
    border-radius: 12px;
}

/* ========================================
   操作按钮区
   ======================================== */
.bg-actions {
    display: flex;
    gap: 12px;
    padding: 20px;
    background: #1a1a1a;
    justify-content: center;
}

.bg-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    background: #2a2a2a;
    border: none;
    border-radius: 12px;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 80px;
}

.bg-action-btn:hover {
    background: #3a3a3a;
}

.bg-action-btn:active {
    transform: scale(0.95);
}

.bg-action-btn i {
    font-size: 24px;
}

.bg-action-btn span {
    font-size: 12px;
    opacity: 0.8;
}

.bg-action-btn.delete {
    color: #ff4444;
}

.bg-action-btn.delete:hover {
    background: rgba(255, 68, 68, 0.2);
}

/* ========================================
   历史背景区
   ======================================== */
.bg-history-section {
    padding: 16px 20px;
    background: #1a1a1a;
    border-top: 1px solid #333;
}

.bg-history-title {
    color: #888;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.bg-history-list {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
}

.bg-history-list::-webkit-scrollbar {
    display: none;
}

.bg-history-item {
    flex-shrink: 0;
    width: 100px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    background: #2a2a2a;
}

.bg-history-item:hover {
    border-color: #FF8C42;
    transform: scale(1.05);
}

.bg-history-thumb {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
}

.bg-history-empty {
    color: #666;
    font-size: 14px;
    padding: 12px 0;
}

/* ========================================
   底部保存/取消按钮
   ======================================== */
.bg-editor-footer {
    display: none;
    gap: 12px;
    padding: 16px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0));
    background: #1a1a1a;
    border-top: 1px solid #333;
}

.bg-editor-footer.active {
    display: flex;
}

.bg-footer-btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.bg-footer-btn.cancel {
    background: #2a2a2a;
    color: #fff;
}

.bg-footer-btn.cancel:hover {
    background: #3a3a3a;
}

.bg-footer-btn.save {
    background: linear-gradient(135deg, #FF8C42 0%, #FF6B35 100%);
    color: #fff;
}

.bg-footer-btn.save:hover {
    opacity: 0.9;
}

.bg-footer-btn.save:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   大图查看器
   ======================================== */
.bg-fullscreen-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.bg-fullscreen-viewer.active {
    opacity: 1;
    visibility: visible;
}

.bg-fullscreen-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
}

.bg-fullscreen-image {
    position: relative;
    width: 90vw;
    height: 50vw;
    max-width: 1200px;
    max-height: 400px;
    border-radius: 12px;
    background-size: cover;
    background-position: center;
    transform: scale(0.8);
    transition: transform 0.3s ease;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.bg-fullscreen-viewer.active .bg-fullscreen-image {
    transform: scale(1);
}

.bg-fullscreen-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10;
}

.bg-fullscreen-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ========================================
   个人资料页背景样式 - 抖音风格
   ======================================== */
.profile-background {
    position: relative;
    width: 100%;
    height: 280px;
    overflow: hidden;
    z-index: 1;
}

/* 底层：全宽模糊背景 - 已禁用 */
.profile-background-blur {
    display: none;
}

/* 上层：清晰图片，全宽显示 */
.profile-background-image {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: cover;
    background-position: center;
    z-index: 1;
    pointer-events: none;
}

/* 顶部渐变（配合状态栏） */
.profile-background-gradient {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.3), transparent);
    z-index: 2;
    pointer-events: none;
}

/* 底部渐变（与下方内容融合）- 已禁用 */
.profile-background::after {
    display: none;
}

/* 编辑按钮 */
.profile-background-edit {
    position: absolute;
    top: calc(16px + env(safe-area-inset-top, 0));
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    pointer-events: auto;
}

/* 有背景图时隐藏编辑按钮，整个区域可点击 */
.profile-background:not(.no-image) .profile-background-edit {
    display: none;
}

.profile-background:not(.no-image) {
    cursor: pointer;
}

.profile-background-edit:hover {
    background: rgba(0, 0, 0, 0.6);
    transform: scale(1.1);
}

.profile-background-edit:active {
    transform: scale(0.95);
}

/* 汉堡菜单按钮在背景区域 */
.profile-background .profile-menu-btn {
    position: absolute;
    top: calc(16px + env(safe-area-inset-top, 0));
    left: 16px;
    width: 40px;
    height: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: #fff;
    z-index: 20;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.2s;
    pointer-events: auto;
}

.profile-background .profile-menu-btn:hover {
    background: rgba(0, 0, 0, 0.5);
}

/* 无背景时菜单按钮使用白色半透明背景 */
.profile-background.no-image .profile-menu-btn {
    background: rgba(255, 255, 255, 0.2);
}

.profile-background.no-image .profile-menu-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.profile-background .profile-menu-btn span {
    display: block;
    width: 18px;
    height: 2px;
    background-color: currentColor;
    border-radius: 1px;
}

/* 无背景图时隐藏背景区域，显示原有渐变头部 */
.profile-background.no-image {
    display: none;
}

/* 有背景图时的页面容器 */
.page:has(.profile-background:not(.no-image)) .profile-content {
    margin-top: 0;
}

/* ========================================
   响应式调整
   ======================================== */
@media (min-width: 768px) {
    .bg-editor-overlay {
        align-items: center;
        justify-content: center;
        background: rgba(0, 0, 0, 0.8);
    }
    
    .bg-editor-container {
        width: 100%;
        max-width: 600px;
        max-height: 90vh;
        border-radius: 16px;
        overflow: hidden;
    }
    
    .bg-editor-header {
        padding-top: 16px;
    }
    
    .bg-editor-footer {
        padding-bottom: 16px;
    }
    
    .bg-current-preview {
        height: 220px;
    }
    
    /* 桌面端背景更高 */
    .profile-background {
        height: 320px;
    }
    
    .bg-history-item {
        width: 140px;
        height: 80px;
    }
}

@media (min-width: 1024px) {
    .profile-background {
        height: 360px;
    }
    
    .bg-current-preview {
        height: 250px;
    }
}

/* ========================================
   暗色主题适配（如果需要）
   ======================================== */
@media (prefers-color-scheme: dark) {
    .bg-preview-blur::after {
        background: linear-gradient(
            to right,
            rgba(26, 26, 26, 0.95) 0%,
            rgba(26, 26, 26, 0.8) 40%,
            rgba(26, 26, 26, 0.4) 70%,
            transparent 100%
        );
    }
}

/* ========================================
   动画效果
   ======================================== */
@keyframes bgFadeIn {
    from {
        opacity: 0;
        transform: scale(1.1);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.profile-background-image {
    animation: bgFadeIn 0.5s ease-out;
}
