/* ============================================
   页面布局核心样式
   ============================================ */

/* 页面通用容器 */
.page-container {
    padding: 16px;
    padding-bottom: 72px;
    height: calc(100vh - 72px);
    overflow-y: auto;
    box-sizing: border-box;
    position: relative;
}

/* 主内容区域精确高度管理 */
.main-content {
    height: calc(100vh - 72px);
    max-height: calc(100vh - 72px);
    overflow-y: auto;
    padding-bottom: 72px;
    box-sizing: border-box;
}

/* ============================================
   四个导航页面统一间距
   ============================================ */

.main-content.home-page,
.main-content.template-page {
    padding-top: 0;
    padding-left: 14px;
    padding-right: 14px;
    margin-top: 0;
}

/* 个人中心、智能体页：全宽内容，左右不留 14px 边距 */
.main-content.ai-writer-page,
.main-content.profile-page {
    padding-top: 0;
    padding-left: 0;
    padding-right: 0;
    margin-top: 0;
}

/* iOS 安全区域适配 */
@supports (padding-top: env(safe-area-inset-top)) {
    .main-content.home-page,
    .main-content.ai-writer-page,
    .main-content.template-page,
    .main-content.profile-page {
        padding-top: env(safe-area-inset-top);
    }

    .main-content.home-page .poster-container,
    .main-content.ai-writer-page .poster-container {
        margin-top: -8px;
    }
}

/* 模板页面 - 允许滚动 */
.main-content.template-page {
    height: auto;
    max-height: none;
    min-height: calc(100vh - 72px);
    overflow-y: auto;
    padding-bottom: 80px;
}

/* 首页和AI写作页面 - 允许滚动 */
.main-content.home-page,
.main-content.ai-writer-page {
    height: auto;
    max-height: none;
    min-height: calc(100vh - 72px);
    overflow-y: auto;
    padding-bottom: 80px;
}

/* 个人中心页面 - 禁止滚动 */
.main-content.profile-page {
    height: calc(100vh - 72px);
    max-height: calc(100vh - 72px);
    overflow: hidden;
}

.main-content.profile-page::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.main-content.profile-page {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.page-container.profile-page {
    height: calc(100vh - 72px);
    max-height: calc(100vh - 72px);
    overflow: hidden;
}

.page-container.profile-page::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.page-container.profile-page {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ============================================
   四个页面顶部元素位置
   ============================================ */

.main-content.home-page .poster-container {
    margin-top: 0;
    margin-bottom: 16px;
    position: relative;
}

.main-content.ai-writer-page .poster-container {
    margin-top: 0;
    margin-bottom: 16px;
    position: relative;
}

.main-content.template-page .page-header {
    margin-top: 0;
    margin-bottom: 12px;
    padding: 6px 12px;
    border-radius: 16px;
}

.main-content.profile-page .p-hero {
    margin-top: 0;
    margin-bottom: 16px;
}

/* ============================================
   智能体页面(AI Page) - 禁止滚动
   ============================================ */

.page-container.ai-page {
    height: calc(100vh - 72px);
    max-height: calc(100vh - 72px);
    overflow: hidden;
    padding-bottom: 72px;
    min-height: auto;
}

.page-container.ai-page::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.page-container.ai-page {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.main-content.ai-page {
    overflow: hidden;
}

.main-content.ai-page::-webkit-scrollbar {
    display: none;
}

.ai-page .page-container {
    height: calc(100vh - 72px);
    overflow-y: hidden;
    padding-bottom: 72px;
    min-height: auto;
}

/* ============================================
   页面头部
   ============================================ */

.page-header {
    text-align: center;
    margin-bottom: 24px;
    padding: 18px 18px;
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(255,255,255,0.78), rgba(255,255,255,0.62));
    border: 1px solid rgba(255,255,255,0.75);
    box-shadow: 0 18px 40px rgba(15,23,42,0.07);
    backdrop-filter: blur(20px);
}

.page-header h2 {
    font-size: 1.6rem;
    color: #0f172a;
    margin-bottom: 6px;
    font-weight: 700;
    line-height: 1.3;
}

.page-header p {
    color: #64748b;
    font-size: 0.95rem;
    opacity: 0.85;
    line-height: 1.5;
}

/* ============================================
   AI 功能卡片网格
   ============================================ */

.ai-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.ai-card {
    background: linear-gradient(180deg, rgba(255,255,255,0.82), rgba(255,255,255,0.68));
    border-radius: 22px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.07);
    border: 1px solid rgba(255,255,255,0.76);
    backdrop-filter: blur(18px);
    position: relative;
    overflow: hidden;
}

.ai-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 22px 42px rgba(15, 23, 42, 0.11);
}

.ai-card:active {
    transform: translateY(-1px) scale(0.98);
}

.ai-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #3b82f6, #0ea5e9);
    transition: transform 0.25s ease;
}

.ai-card:hover .ai-icon {
    transform: scale(1.08) rotate(3deg);
}

.ai-icon i {
    font-size: 1.3rem;
    color: #fff;
}

.ai-card h3 {
    font-size: 1rem;
    color: #1a1a2e;
    margin-bottom: 6px;
    font-weight: 600;
    line-height: 1.3;
}

.ai-card p {
    font-size: 0.85rem;
    color: #6b7280;
    line-height: 1.5;
}

/* ============================================
   个人中心
   ============================================ */

.profile-header {
    text-align: center;
    margin-bottom: 20px;
    padding: 24px 20px 20px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    margin: -16px -14px 20px;
    color: #fff;
    border-radius: 0 0 30px 30px;
    box-shadow: 0 24px 50px rgba(15, 23, 42, 0.22);
}

.avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.avatar i {
    font-size: 1.4rem;
    color: #fff;
    opacity: 0.9;
}

.profile-header h2 {
    font-size: 1.25rem;
    margin-bottom: 6px;
    font-weight: 600;
    color: #fff;
}

.user-level {
    display: inline-block;
    padding: 3px 10px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 14px;
}

.user-stats {
    display: flex;
    justify-content: center;
    gap: 24px;
}

.stat-item {
    text-align: center;
}

.stat-number {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 2px;
}

.stat-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.8);
}

.profile-menu {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    transition: background-color 0.2s ease, padding-left 0.2s ease;
    position: relative;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item:hover {
    background: rgba(102, 126, 234, 0.04);
    padding-left: 20px;
}

.menu-item:active {
    background: rgba(102, 126, 234, 0.08);
}

.menu-item i:first-child {
    font-size: 1rem;
    color: #667eea;
    margin-right: 12px;
    width: 18px;
    text-align: center;
}

.menu-item span {
    flex: 1;
    font-size: 0.9rem;
    color: #1a1a2e;
    font-weight: 500;
}

.menu-item i:last-child {
    font-size: 0.8rem;
    color: #ccc;
}

/* ============================================
   深色模式
   ============================================ */

@media (prefers-color-scheme: dark) {
    .page-header h2 {
        color: #e5e7eb;
    }

    .page-header p {
        color: #9ca3af;
    }

    .ai-card {
        background: #1e2030;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }

    .ai-card:hover {
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    }

    .ai-card h3 {
        color: #e5e7eb;
    }

    .ai-card p {
        color: #9ca3af;
    }

    .profile-menu {
        background: #1e2030;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }

    .menu-item {
        border-bottom-color: #2a2d3e;
    }

    .menu-item:hover {
        background: rgba(102, 126, 234, 0.08);
    }

    .menu-item:active {
        background: rgba(102, 126, 234, 0.12);
    }

    .menu-item span {
        color: #e5e7eb;
    }

    .menu-item i:last-child {
        color: #4b5563;
    }
}

/* ============================================
   响应式 375px 断点
   ============================================ */

@media (max-width: 375px) {
    .page-container {
        padding: 12px;
        padding-bottom: 72px;
    }

    .ai-features {
        gap: 10px;
    }

    .ai-card {
        padding: 16px 12px;
        border-radius: 14px;
    }

    .ai-icon {
        width: 42px;
        height: 42px;
        margin-bottom: 10px;
    }

    .ai-icon i {
        font-size: 1.1rem;
    }

    .ai-card h3 {
        font-size: 0.9rem;
    }

    .ai-card p {
        font-size: 0.8rem;
    }

    .user-stats {
        gap: 20px;
    }

    .profile-header {
        padding: 20px 16px 16px;
    }

    .avatar {
        width: 48px;
        height: 48px;
    }

    .menu-item {
        padding: 12px 14px;
    }
}
