/* =========================================
   Layout, Reset & Global Styles - 沉浸式手机App风格
   ========================================= */

/* 重置与基础 */
*, *::before, *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--custom-font, var(--font-family));
    font-size: var(--font-size-base);
    line-height: 1.5;
    background: linear-gradient(135deg, rgba(232, 228, 255, 1) 0%, rgba(248, 249, 252, 1) 50%, rgba(232, 228, 255, 1) 100%);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Vue 隐藏未编译模板 */
[v-cloak] { display: none !important; }

/* 选择文本颜色 */
::selection {
    background: var(--primary-light);
    color: var(--text-main);
}

/* 滚动条美化 - iOS风格 */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.15);
}

/* =========================================
   App 容器布局
   ========================================= */

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    position: relative;
    background: transparent;
}

/* 桌面端居中显示 */
@media (min-width: 481px) {
    body {
        display: flex;
        justify-content: center;
        align-items: center;
        background: linear-gradient(135deg, rgba(232, 228, 255, 1) 0%, rgba(248, 249, 252, 1) 50%, rgba(232, 228, 255, 1) 100%);
    }
    
    #app {
        max-width: 420px;
        height: 90vh;
        max-height: 900px;
        border-radius: var(--radius-2xl);
        box-shadow: var(--shadow-float), 0 0 0 1px rgba(0, 0, 0, 0.02);
        position: relative;
        overflow: hidden;
    }
}

/* =========================================
   状态栏占位（模拟手机状态栏）
   ========================================= */

.status-bar-placeholder {
    height: max(20px, env(safe-area-inset-top));
    background: var(--bg-color);
    width: 100%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--space-4);
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-main);
    position: relative;
    z-index: 999;
}

.status-bar-placeholder::before {
    content: attr(data-time);
    position: absolute;
    left: var(--space-6);
}

.status-bar-placeholder::after {
    content: "";
    position: absolute;
    right: var(--space-6);
    width: 20px;
    height: 10px;
    border: 1.5px solid var(--text-sub);
    border-radius: 3px;
    opacity: 0.6;
}

.status-bar-placeholder::after {
    background: linear-gradient(90deg, var(--online-color) 80%, transparent 80%);
    background-clip: padding-box;
}

/* =========================================
   主内容区域
   ========================================= */

.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* 为底部导航留空间 */
.main-content::after {
    content: '';
    display: block;
    height: calc(var(--nav-height) + var(--space-8) + env(safe-area-inset-bottom));
}

/* =========================================
   页面切换动画 - 轻柔过渡
   ========================================= */

.fade-enter-active,
.fade-leave-active {
    transition: opacity var(--transition-base);
}

.fade-enter-from,
.fade-leave-to {
    opacity: 0;
}

/* 滑入动画 - 模拟iOS导航 */
.slide-enter-active {
    transition: transform var(--transition-slow), opacity var(--transition-slow);
}

.slide-leave-active {
    transition: transform var(--transition-base), opacity var(--transition-base);
}

.slide-enter-from {
    transform: translateX(30%);
    opacity: 0.8;
}

.slide-leave-to {
    transform: translateX(-10%);
    opacity: 0.6;
}

/* 从下往上滑入 */
.slide-up-enter-active,
.slide-up-leave-active {
    transition: transform var(--transition-slow), opacity var(--transition-slow);
}

.slide-up-enter-from {
    transform: translateY(100%);
    opacity: 0.9;
}

.slide-up-leave-to {
    transform: translateY(100%);
    opacity: 0;
}

/* Toast 滑入动画 */
.slide-down-enter-active,
.slide-down-leave-active {
    transition: all var(--transition-base);
}

.slide-down-enter-from,
.slide-down-leave-to {
    transform: translateY(-20px);
    opacity: 0;
}

/* =========================================
   底部导航栏 - 悬浮岛设计
   ========================================= */

.bottom-nav {
    position: fixed;
    bottom: var(--space-5);
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - var(--space-8));
    max-width: 360px;
    height: 64px;
    background: var(--footer-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-radius: var(--radius-2xl);
    padding: 0 var(--space-3);
    z-index: 100;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.5);
    margin-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--icon-default);
    font-size: var(--font-size-xs);
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    min-width: var(--touch-target);
    min-height: var(--touch-target);
    border-radius: var(--radius-lg);
    user-select: none;
}

.nav-item i {
    font-size: 22px;
    transition: all var(--transition-base);
}

.nav-item span {
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* 激活状态 */
.nav-item.active {
    color: var(--primary-color);
}

.nav-item.active i {
    transform: scale(1.05);
}

/* 激活指示器 */
.nav-item.active::before {
    content: '';
    position: absolute;
    bottom: 6px;
    width: 4px;
    height: 4px;
    background: var(--primary-color);
    border-radius: 50%;
    opacity: 0;
    animation: navDot 0.3s ease forwards;
}

@keyframes navDot {
    from { opacity: 0; transform: scale(0); }
    to { opacity: 1; transform: scale(1); }
}

/* 按压效果 */
.nav-item:active {
    transform: scale(0.95);
    background: rgba(0, 0, 0, 0.03);
}

/* =========================================
   页面内容区域
   ========================================= */

.page-content {
    padding: var(--space-5) 0;
    padding-bottom: calc(var(--nav-height) + var(--space-10));
}

.section-title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    margin-bottom: var(--space-5);
    color: var(--text-main);
    padding: 0 var(--space-5);
    letter-spacing: -0.02em;
}

/* =========================================
   卡片容器 - 悬浮感设计
   ========================================= */

.card-container {
    background: var(--white);
    margin: 0 var(--space-4);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: var(--space-4);
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.card-item {
    padding: var(--space-4);
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    transition: background var(--transition-fast);
}

.card-item:last-child {
    border-bottom: none;
}

.card-item:active {
    background: rgba(0, 0, 0, 0.02);
}

/* =========================================
   Toast 通知
   ========================================= */

.toast-message {
    position: fixed;
    top: calc(env(safe-area-inset-top) + var(--space-6));
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-3) var(--space-5);
    background: var(--white);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-main);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.toast-message.success {
    background: linear-gradient(135deg, #F0FFF4 0%, #C6F6D5 100%);
    color: #276749;
}

.toast-message.error {
    background: linear-gradient(135deg, #FFF5F5 0%, #FED7D7 100%);
    color: #C53030;
}

.toast-message.warning {
    background: linear-gradient(135deg, #FFFAF0 0%, #FEEBC8 100%);
    color: #C05621;
}

/* =========================================
   工具类
   ========================================= */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.p-4 { padding: var(--space-4); }
