/* ============================================
   全局基础样式 - 纯移动端H5风格
   ============================================ */

:root {
    /* 苹果系原生蓝 */
    --primary: #007AFF;
    --primary-light: #5AC8FA;
    --primary-dark: #0056b3;
    --primary-bg: #E5F1FF;
    
    /* 辅助色 */
    --success: #34C759;
    --warning: #FF9500;
    --danger: #FF3B30;
    --info: #5AC8FA;
    
    /* 中性色 (Apple风格) */
    --text-primary: #000000;
    --text-secondary: #3C3C43;
    --text-muted: #8E8E93;
    --text-white: #ffffff;
    
    /* 背景色 */
    --bg-body: #F2F2F7;
    --bg-card: #FFFFFF;
    --bg-card-solid: #FFFFFF;
    --bg-hover: #E5E5EA;
    --bg-dark: #1C1C1E;
    
    /* 边框 */
    --border-color: rgba(60, 60, 67, 0.15);
    --border-focus: #007AFF;
    
    /* 原生感轻柔阴影 */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.06);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.08);
    
    /* 原生级大圆角 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* 间距 */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 20px;
    --space-xl: 24px;
    --space-2xl: 32px;
    
    /* 字体 (原生优先) */
    --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
    --font-xs: 12px;
    --font-sm: 14px;
    --font-base: 16px;
    --font-md: 17px;
    --font-lg: 20px;
    --font-xl: 24px;
    --font-2xl: 28px;
    --font-3xl: 34px;
    
    /* 动画 */
    --transition-fast: 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
    --transition-normal: 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
    
    /* 导航高度 */
    --nav-height: 44px; /* iOS原生导航栏高度 */
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* 阻止橡皮筋回弹导致看到背景底色 */
    overscroll-behavior-y: none;
}

/* ============================================
   布局系统 (全宽无限制)
   ============================================ */

.main-content {
    width: 100%;
    min-height: 100vh;
    padding-top: var(--nav-height);
    background: var(--bg-body);
}

.page {
    display: none;
    min-height: calc(100vh - var(--nav-height));
    animation: fadeIn 0.3s ease-out;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.page-container {
    width: 100%;
    padding: var(--space-md);
}

/* ============================================
   顶部导航栏 (原生App风格)
   ============================================ */

.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--nav-height);
    background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(248,250,255,0.95));
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid rgba(37,99,235,0.08);
    z-index: 1000;
    box-shadow: 0 1px 8px rgba(0,0,0,0.04);
    transition: box-shadow 0.3s, background 0.3s;
}

.top-nav.scrolled {
    box-shadow: 0 2px 16px rgba(0,0,0,0.08);
    background: rgba(255,255,255,0.98);
}

.nav-inner {
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-md);
}

.nav-hamburger {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: #334155;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}
.nav-hamburger:hover { background: rgba(0,0,0,0.05); }
.nav-hamburger:active { background: rgba(0,0,0,0.08); }

.nav-brand-center {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 17px;
    letter-spacing: -0.3px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.nav-brand-center i {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: #fff;
    border-radius: 8px;
    font-size: 14px;
}

.nav-brand-center span {
    background: linear-gradient(135deg, #1e293b, #334155);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.nav-right-placeholder { width: 38px; flex-shrink: 0; }

/* ---- 侧滑抽屉菜单 ---- */
.drawer-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4); z-index: 2000;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s;
}
.drawer-overlay.active { opacity: 1; pointer-events: auto; }

.drawer {
    position: fixed; top: 0; left: -280px; width: 280px; height: 100%;
    background: #fff; z-index: 2001;
    box-shadow: 4px 0 24px rgba(0,0,0,0.12);
    transition: left 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    display: flex; flex-direction: column;
    overflow-y: auto;
}
.drawer.active { left: 0; }

.drawer-header {
    padding: 24px 20px 20px;
    background: linear-gradient(135deg, #f0f4ff, #e8f0fe);
    border-bottom: 1px solid #e2e8f0;
}
.drawer-user {
    display: flex; align-items: center; gap: 12px;
}
.drawer-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 18px; flex-shrink: 0;
}
.drawer-user-info { display: flex; flex-direction: column; gap: 2px; }
.drawer-user-name { font-size: 15px; font-weight: 700; color: #1e293b; }
.drawer-user-hint { font-size: 12px; color: #94a3b8; }

.drawer-consult-section {
    flex: 1; padding: 0; overflow-y: auto;
    border-bottom: 1px solid #e2e8f0;
}
.drawer-section-title {
    padding: 12px 20px 8px; font-size: 12px; font-weight: 600;
    color: #64748b; text-transform: uppercase; letter-spacing: 0.5px;
}
.drawer-section-title i { margin-right: 6px; }
.drawer-consult-list { padding: 0 12px 12px; }
.drawer-consult-empty {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 32px 20px; color: #94a3b8; font-size: 13px;
}
.drawer-consult-empty i { font-size: 28px; opacity: 0.4; }
.drawer-consult-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 10px; cursor: pointer;
    transition: background 0.2s; text-decoration: none; color: inherit;
}
.drawer-consult-item:hover { background: #f0f4ff; }
.drawer-consult-icon {
    width: 36px; height: 36px; border-radius: 10px;
    background: #f1f5f9; color: #64748b;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; flex-shrink: 0;
}
.drawer-consult-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.drawer-consult-title {
    font-size: 13px; font-weight: 600; color: #1e293b;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.drawer-consult-desc { font-size: 11px; color: #94a3b8; }

.drawer-category-section {
    border-bottom: 1px solid #e2e8f0;
}
.drawer-category-toggle {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 20px; cursor: pointer; transition: background 0.2s;
}
.drawer-category-toggle:hover { background: #f8fafc; }
.drawer-category-current {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; font-weight: 600; color: #334155;
}
.drawer-category-current i { font-size: 14px; color: #64748b; }
.drawer-category-arrow {
    font-size: 11px; color: #94a3b8;
    transition: transform 0.25s ease;
}
.drawer-category-arrow.open { transform: rotate(180deg); }
.drawer-category-list { padding: 0 12px 10px; }
.drawer-category-item {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px; border-radius: 8px; cursor: pointer;
    transition: background 0.2s; text-decoration: none; color: inherit;
}
.drawer-category-item:hover { background: #f0f4ff; }
.drawer-category-item.active { background: #eff6ff; }
.drawer-category-icon {
    width: 28px; height: 28px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 12px; flex-shrink: 0;
}
.drawer-category-info { display: flex; align-items: center; gap: 6px; min-width: 0; }
.drawer-category-name { font-size: 13px; font-weight: 500; color: #1e293b; }
.drawer-category-badge {
    font-size: 10px; font-weight: 600; color: var(--primary);
    background: #eff6ff; border: 1px solid rgba(37,99,235,0.2);
    padding: 1px 5px; border-radius: 4px;
}
.drawer-category-item.active .drawer-category-name { color: var(--primary); font-weight: 600; }

.drawer-nav-bottom {
    padding: 8px 0; border-top: 1px solid #e2e8f0;
}
.drawer-item {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 24px; color: #334155;
    font-size: 14px; font-weight: 500;
    cursor: pointer; transition: background 0.2s;
    text-decoration: none;
}
.drawer-item:hover { background: #f0f4ff; color: var(--primary); }
.drawer-item i { width: 20px; text-align: center; font-size: 15px; color: #64748b; }
.drawer-item:hover i { color: var(--primary); }

.drawer-divider { height: 1px; background: #e2e8f0; margin: 8px 20px; }

.drawer-footer {
    padding: 12px 24px; border-top: 1px solid #e2e8f0;
    font-size: 11px; color: #94a3b8; text-align: center;
}

/* ---- 个人中心页 ---- */
.profile-container { padding: 20px 16px; }
.profile-header-card {
    display: flex; align-items: center; gap: 16px;
    padding: 24px 20px; border-radius: 16px;
    background: linear-gradient(135deg, #f0f4ff, #e8f0fe);
    margin-bottom: 20px;
}
.profile-avatar { font-size: 48px; color: var(--primary); }
.profile-info { display: flex; flex-direction: column; gap: 4px; }
.profile-phone { font-size: 18px; font-weight: 700; color: #1e293b; }
.profile-status { font-size: 12px; color: #64748b; }

.profile-section { margin-bottom: 20px; }
.profile-section-title {
    font-size: 13px; font-weight: 600; color: #64748b;
    padding: 0 4px 10px; border-bottom: 1px solid #f1f5f9; margin-bottom: 12px;
}
.profile-stats {
    display: flex; justify-content: space-around; gap: 12px;
    padding: 16px; background: #fff; border-radius: 12px;
    border: 1px solid #e2e8f0;
}
.profile-stat-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.profile-stat-num { font-size: 20px; font-weight: 700; color: var(--primary); }
.profile-stat-label { font-size: 11px; color: #94a3b8; }

.profile-menu-list { border-radius: 12px; overflow: hidden; border: 1px solid #e2e8f0; }
.profile-menu-item {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px; background: #fff; cursor: pointer;
    transition: background 0.2s; text-decoration: none; color: #334155;
    font-size: 14px; font-weight: 500;
    border-bottom: 1px solid #f1f5f9;
}
.profile-menu-item:last-child { border-bottom: none; }
.profile-menu-item:hover { background: #f8fafc; }
.profile-menu-item i { width: 20px; text-align: center; font-size: 15px; color: #64748b; }
.profile-menu-arrow { margin-left: auto; font-size: 12px; color: #cbd5e1; }

.profile-category-card {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; background: #fff; border-radius: 12px;
    border: 1px solid #e2e8f0;
}
.profile-cat-current {
    display: flex; align-items: center; gap: 10px;
    font-size: 14px; font-weight: 600; color: #1e293b;
}
.profile-cat-current i { color: var(--primary); font-size: 16px; }
.profile-cat-switch-btn { font-size: 12px; padding: 4px 12px; }
.profile-cat-list {
    margin-top: 8px; background: #fff; border-radius: 12px;
    border: 1px solid #e2e8f0; overflow: hidden;
}
.profile-cat-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; font-size: 13px; color: #334155;
    cursor: pointer; transition: background 0.2s;
    border-bottom: 1px solid #f1f5f9;
}
.profile-cat-item:last-child { border-bottom: none; }
.profile-cat-item:hover { background: #f0f4ff; }
.profile-cat-item.active { color: var(--primary); font-weight: 600; background: rgba(59,130,246,0.06); }
.profile-cat-item i { width: 18px; text-align: center; font-size: 14px; }

.profile-logout-btn { margin-top: 8px; color: #ef4444; border-color: #fecaca; }
.profile-logout-btn:hover { background: #fef2f2; }

/* ============================================
   卡片 (iOS原生风格)
   ============================================ */

.glass-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    border: none;
}

/* ============================================
   全局弹窗 (原生 Bottom Sheet 风格)
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 2000;
    display: none;
    align-items: flex-end;
}

.modal-overlay.active {
    display: flex;
    animation: fadeInOverlay 0.25s ease-out;
}

@keyframes fadeInOverlay {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-box {
    width: 100%;
    max-height: 85vh;
    background: var(--bg-body);
    border-radius: 24px 24px 0 0;
    padding: var(--space-lg) var(--space-md) calc(var(--space-lg) + env(safe-area-inset-bottom));
    animation: slideUp 0.3s cubic-bezier(0.25, 1, 0.25, 1);
    position: relative;
    padding-top: 36px;
    display: flex;
    flex-direction: column;
}

/* 顶部拖拽条指示器 */
.modal-box::before {
    content: '';
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 5px;
    background: #D1D1D6;
    border-radius: 2.5px;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    margin-bottom: var(--space-lg);
    text-align: center;
    position: relative;
}

.modal-header h3 {
    font-size: var(--font-lg);
    font-weight: 600;
    padding: 0 32px;
}

.modal-close-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg-hover, #f3f4f6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-util-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.modal-util-bar .btn {
    flex: 1;
    font-size: 12px;
    padding: 6px 0;
}

.modal-body {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: var(--space-md);
    background: #fff;
    padding: var(--space-md);
    border-radius: var(--radius-md);
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.modal-footer {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    flex-shrink: 0;
    padding-top: var(--space-sm);
}

.modal-actions {
    display: flex;
    flex-direction: column; /* 手机端弹窗按钮通常垂直排列 */
    gap: var(--space-sm);
}

/* ============================================
   Toast 提示 (原生风格，顶部弹出)
   ============================================ */

.toast-container {
    position: fixed;
    top: calc(var(--nav-height) + env(safe-area-inset-top) + 12px);
    left: 16px;
    right: 16px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-full);
    color: #fff;
    font-size: var(--font-base);
    font-weight: 500;
    box-shadow: var(--shadow-md);
    animation: toastIn 0.3s cubic-bezier(0.25, 1, 0.25, 1);
    max-width: 100%;
}

.toast.success { background: rgba(52, 199, 89, 0.9); }
.toast.warning { background: rgba(255, 149, 0, 0.9); }
.toast.error { background: rgba(255, 59, 48, 0.9); }

.toast i { font-size: 18px; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.9); }
}

/* ============================================
   免责栏
   ============================================ */

.disclaimer-bar {
    background: transparent;
    padding: var(--space-md);
    text-align: center;
}

.disclaimer-bar p {
    font-size: var(--font-xs);
    color: var(--text-muted);
    line-height: 1.5;
}

/* ============================================
   加载动画
   ============================================ */

.spinner {
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-body);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.loading-text {
    margin-top: var(--space-md);
    color: var(--text-secondary);
    font-weight: 500;
}
