/* 全局重置和修复样式 */

/* ========== 修复样式冲突 ========== */

/* 确保每个页面独立 */
.tab-pane {
    isolation: isolate;
}

/* 动态页特定样式 */
#home .action-btn {
    all: initial;
    display: flex;
    align-items: center;
    gap: 4px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: var(--font-sm);
    cursor: pointer;
    padding: 4px;
    transition: var(--transition-fast);
    font-family: var(--font-family);
}

#home .action-btn i {
    font-size: 18px;
}

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

#home .action-btn.liked {
    color: var(--danger-color);
}

/* 作品页特定样式 */
#works .header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg) var(--spacing-lg) var(--spacing-sm);
}

#works .header-top h2 {
    font-size: var(--font-xl);
    font-weight: var(--font-bold);
    color: var(--text-primary);
}

/* 消息页特定样式 */
#messages .message-header {
    background: var(--card-bg);
    padding: var(--spacing-lg);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    border-bottom: 1px solid var(--divider-color);
}

/* 个人中心特定样式 */
#profile .profile-header {
    background: var(--card-bg);
    padding-bottom: var(--spacing-xl);
}

/* ========== 通用修复 ========== */

/* 防止图片拉伸 */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* 修复按钮点击区域 */
button {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* 修复滚动性能 */
.tab-pane {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
    overflow-x: hidden;
}

/* 修复z-index层级 */
.moment-header {
    z-index: 100;
}

.works-header {
    z-index: 100;
}

.message-header {
    z-index: 100;
}

.tabbar {
    z-index: 200;
}

.fab-publish {
    z-index: 150;
}

/* 修复文字截断 */
.ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 修复flex子元素 */
.flex-1 {
    flex: 1;
    min-width: 0;
}

/* ========== 移动端优化 ========== */

/* 禁用iOS橡皮筋效果 */
html, body {
    overscroll-behavior: contain;
}

/* 修复iOS输入框 */
input, textarea {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* 修复点击延迟 */
a, button {
    touch-action: manipulation;
}

/* 修复字体大小 */
html {
    -webkit-text-size-adjust: 100%;
}

/* ========== 性能优化 ========== */

/* 开启硬件加速 */
.tab-pane {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* 优化动画性能 */
.transition-gpu {
    will-change: transform;
}

/* ========== 兼容性修复 ========== */

/* 修复Grid布局兼容性 */
@supports not (display: grid) {
    .works-container {
        display: flex;
        flex-wrap: wrap;
    }
    
    .work-card {
        width: calc(50% - var(--spacing-sm));
        margin: calc(var(--spacing-sm) / 2);
    }
}

/* 修复Sticky定位兼容性 */
@supports not (position: sticky) {
    .moment-header,
    .works-header,
    .message-header {
        position: fixed;
        width: 100%;
    }
    
    .tab-pane {
        padding-top: 60px;
    }
}