/* 
 * 清华大学移动端财务聚合平台 - 设计系统
 * 版本: 2.0.0 - 清华紫高级质感版
 * 更新日期: 2026-06-08
 */

/* ============================================
   1. 设计令牌 (Design Tokens) - 清华紫配色
   ============================================ */

:root {
    /* ---- 清华紫主色系 ---- */
    --primary-50: #f5f0fa;
    --primary-100: #e8dcf2;
    --primary-200: #d1b9e6;
    --primary-300: #b996d9;
    --primary-400: #a273cd;
    --primary-500: #6C3483;  /* 清华紫主色 */
    --primary-600: #5B2C6F;
    --primary-700: #4A2059;
    --primary-800: #381845;
    --primary-900: #260E2E;
    
    /* ---- 辅助色 - 优雅灰紫 ---- */
    --accent-50: #f8f6fa;
    --accent-100: #ede8f2;
    --accent-200: #d9d0e2;
    --accent-300: #c5b8d2;
    --accent-400: #b1a0c2;
    --accent-500: #8E7AA0;
    --accent-600: #7a6890;
    --accent-700: #665680;
    --accent-800: #524470;
    --accent-900: #3e3260;
    
    /* ---- 中性色 - 纯净白灰 ---- */
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-500: #9e9e9e;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --gray-900: #1a1a2e;
    
    /* ---- 状态色 ---- */
    --success-50: #e8f5e9;
    --success-500: #4caf50;
    --success-600: #43a047;
    
    --warning-50: #fff8e1;
    --warning-500: #ff9800;
    --warning-600: #fb8c00;
    
    --danger-50: #ffebee;
    --danger-500: #f44336;
    --danger-600: #e53935;
    
    --info-50: #e3f2fd;
    --info-500: #2196f3;
    --info-600: #1e88e5;
    
    /* ---- 语义化颜色 ---- */
    --bg: #fafafa;           /* 纯净白底 */
    --surface: #ffffff;
    --surface-alt: #f8f8f8;
    --fg: #1a1a2e;
    --fg-secondary: #5a5a6e;
    --muted: #9e9eae;
    --border: #eee;
    
    /* ---- 渐变 ---- */
    --gradient-primary: linear-gradient(135deg, #6C3483 0%, #8E44AD 100%);
    --gradient-accent: linear-gradient(135deg, #8E7AA0 0%, #a273cd 100%);
    --gradient-surface: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
    
    /* ---- 阴影 ---- */
    --shadow-xs: 0 1px 2px rgba(108, 52, 131, 0.04);
    --shadow-sm: 0 1px 3px rgba(108, 52, 131, 0.06);
    --shadow-md: 0 4px 12px rgba(108, 52, 131, 0.08);
    --shadow-lg: 0 8px 24px rgba(108, 52, 131, 0.1);
    --shadow-xl: 0 12px 36px rgba(108, 52, 131, 0.12);
    
    /* ---- 圆角 ---- */
    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-pill: 50px;
    --radius-full: 9999px;
    
    /* ---- 间距 (4px 基准) ---- */
    --space-0: 0;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;
    
    /* ---- 字体 ---- */
    --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    --font-body: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    
    /* ---- 字号 ---- */
    --text-xs: 12px;
    --text-sm: 14px;
    --text-base: 16px;
    --text-lg: 18px;
    --text-xl: 20px;
    --text-2xl: 24px;
    --text-3xl: 30px;
    --text-4xl: 36px;
    
    /* ---- 行高 ---- */
    --leading-none: 1;
    --leading-tight: 1.2;
    --leading-snug: 1.375;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;
    --leading-loose: 2;
    
    /* ---- 字重 ---- */
    --font-light: 300;
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;
    
    /* ---- 过渡 ---- */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
    --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
    
    /* ---- z-index ---- */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-fixed: 300;
    --z-modal-backdrop: 400;
    --z-modal: 500;
    --z-popover: 600;
    --z-tooltip: 700;
}

/* ============================================
   2. 深色模式
   ============================================ */

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1a2e;
        --surface: #252540;
        --surface-alt: #2d2d4a;
        --fg: #f5f5f5;
        --fg-secondary: #b0b0c0;
        --muted: #707080;
        --border: #3a3a50;
        
        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    }
}

/* ============================================
   3. 基础重置
   ============================================ */

*,
*::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-body);
    background: var(--bg);
    color: var(--fg);
    line-height: var(--leading-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

img,
svg {
    display: block;
    max-width: 100%;
}

button,
input,
textarea,
select {
    font-family: inherit;
    font-size: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

ul,
ol {
    list-style: none;
}

/* ============================================
   4. 移动端容器
   ============================================ */

.mobile-container {
    max-width: 430px;
    margin: 0 auto;
    background: var(--surface);
    min-height: 100vh;
    position: relative;
    box-shadow: var(--shadow-xl);
}

/* ============================================
   5. 组件规范
   ============================================ */

/* ---- 状态栏 ---- */
.status-bar {
    height: 44px;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    color: white;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
}

.status-bar .time {
    font-weight: var(--font-semibold);
}

.status-bar .icons {
    display: flex;
    gap: var(--space-2);
}

/* ---- 导航栏 ---- */
.nav-bar {
    background: var(--gradient-primary);
    padding: var(--space-4) var(--space-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.nav-bar .title {
    color: white;
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
    letter-spacing: 0.5px;
}

/* ---- 搜索栏 ---- */
.search-section {
    padding: var(--space-4) var(--space-6);
    background: var(--gradient-primary);
    padding-bottom: var(--space-6);
}

.search-input {
    width: 100%;
    height: 44px;
    border: none;
    border-radius: var(--radius-pill);
    padding: 0 var(--space-6);
    font-size: var(--text-base);
    background: rgba(255, 255, 255, 0.15);
    color: white;
    backdrop-filter: blur(10px);
    transition: all var(--transition-base);
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.search-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 0 3px rgba(142, 122, 160, 0.3);
}

/* ---- 卡片 ---- */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: all var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.card-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--fg);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.card-action {
    color: var(--fg-secondary);
    font-size: var(--text-sm);
    display: flex;
    align-items: center;
    gap: var(--space-1);
    cursor: pointer;
}

/* ---- 按钮 ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    cursor: pointer;
    transition: all var(--transition-base);
    border: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--surface);
    color: var(--fg);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface-alt);
}

/* ---- 标签 ---- */
.tag {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
}

.tag-primary {
    background: var(--primary-50);
    color: var(--primary-700);
}

.tag-accent {
    background: var(--accent-50);
    color: var(--accent-700);
}

.tag-success {
    background: var(--success-50);
    color: var(--success-600);
}

.tag-warning {
    background: var(--warning-50);
    color: var(--warning-600);
}

.tag-danger {
    background: var(--danger-50);
    color: var(--danger-600);
}

.tag-info {
    background: var(--info-50);
    color: var(--info-600);
}

/* ---- 图标按钮 ---- */
.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: all var(--transition-base);
    border: none;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ---- 列表项 ---- */
.list-item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition-base);
}

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

.list-item:hover {
    background: var(--surface-alt);
}

/* ---- 分隔线 ---- */
.divider {
    height: 1px;
    background: var(--border);
    margin: var(--space-4) 0;
}

/* ============================================
   6. 底部导航
   ============================================ */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 430px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: var(--space-2) 0;
    padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom));
    z-index: var(--z-fixed);
    box-shadow: 0 -4px 12px rgba(108, 52, 131, 0.05);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2);
    color: var(--fg-secondary);
    text-decoration: none;
    transition: all var(--transition-base);
    min-width: 60px;
}

.nav-item.active {
    color: var(--primary-600);
}

.nav-item:hover {
    color: var(--primary-500);
}

.nav-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-label {
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
}

/* ============================================
   7. 动画
   ============================================ */

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

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* 动画类 */
.animate-fadeIn {
    animation: fadeIn 0.6s ease forwards;
}

.animate-fadeInUp {
    animation: fadeInUp 0.6s ease forwards;
}

.animate-fadeInDown {
    animation: fadeInDown 0.6s ease forwards;
}

.animate-slideInLeft {
    animation: slideInLeft 0.6s ease forwards;
}

.animate-slideInRight {
    animation: slideInRight 0.6s ease forwards;
}

.animate-scaleIn {
    animation: scaleIn 0.6s ease forwards;
}

.animate-pulse {
    animation: pulse 2s infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* 延迟动画 */
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }

/* ============================================
   8. 响应式断点
   ============================================ */

/* 小屏手机 (< 375px) */
@media (max-width: 374px) {
    :root {
        --text-2xl: 20px;
        --text-3xl: 26px;
        --text-4xl: 32px;
        
        --space-6: 20px;
        --space-8: 28px;
    }
    
    .mobile-container {
        max-width: 100%;
    }
}

/* 标准手机 (375px - 430px) */
@media (min-width: 375px) and (max-width: 430px) {
    .mobile-container {
        max-width: 100%;
    }
}

/* 大屏手机 / 小平板 (> 430px) */
@media (min-width: 431px) {
    body {
        background: var(--gray-200);
    }
    
    .mobile-container {
        border-radius: var(--radius-xl);
        margin-top: var(--space-8);
        margin-bottom: var(--space-8);
    }
}

/* ============================================
   9. 滚动条
   ============================================ */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--surface-alt);
}

::-webkit-scrollbar-thumb {
    background: var(--muted);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--fg-secondary);
}

/* ============================================
   10. 工具类
   ============================================ */

/* 文本 */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.font-display { font-family: var(--font-display); }
.font-body { font-family: var(--font-body); }
.font-mono { font-family: var(--font-mono); }

.font-light { font-weight: var(--font-light); }
.font-normal { font-weight: var(--font-normal); }
.font-medium { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }

/* 间距 */
.m-0 { margin: 0; }
.m-auto { margin: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-0 { padding: 0; }

/* 显示 */
.hidden { display: none; }
.block { display: block; }
.flex { display: flex; }
.grid { display: grid; }

/* Flex */
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

/* 间距 */
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* 溢出 */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 圆角 */
.rounded-full { border-radius: var(--radius-full); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-sm { border-radius: var(--radius-sm); }

/* 阴影 */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }

/* 背景 */
.bg-primary { background: var(--primary-600); }
.bg-surface { background: var(--surface); }
.bg-surface-alt { background: var(--surface-alt); }

/* 文本颜色 */
.text-primary { color: var(--primary-600); }
.text-secondary { color: var(--fg-secondary); }
.text-muted { color: var(--muted); }
.text-accent { color: var(--accent-500); }
.text-success { color: var(--success-500); }
.text-warning { color: var(--warning-500); }
.text-danger { color: var(--danger-500); }
.text-info { color: var(--info-500); }

/* 宽度 */
.w-full { width: 100%; }
.h-full { height: 100%; }

/* 最小高度 */
.min-h-screen { min-height: 100vh; }

/* ============================================
   11. 打印样式
   ============================================ */

@media print {
    .status-bar,
    .nav-bar,
    .bottom-nav {
        display: none;
    }
    
    .mobile-container {
        box-shadow: none;
        max-width: 100%;
    }
    
    body {
        background: white;
    }
}

/* ============================================
   12. 底部导航消息未读红标
   ============================================ */

.nav-icon {
    position: relative;
}

.nav-badge {
    position: absolute;
    top: -5px;
    right: -9px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 9px;
    background: #e5484d;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px #ffffff;
    pointer-events: none;
}
