/* ============================================================
   班费管理系统 - 移动端样式
   微信端适配，手机优先设计
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #4a90d9;
    --primary-dark: #3a7bc8;
    --primary-light: #e8f1fc;
    --income: #34a853;
    --income-bg: #e8f5e9;
    --expense: #ea4335;
    --expense-bg: #fdecea;
    --balance: #4a90d9;
    --balance-bg: #e8f1fc;
    --text: #333;
    --text-secondary: #666;
    --text-tertiary: #999;
    --border: #e0e0e0;
    --bg: #f5f7fa;
    --bg-card: #fff;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg);
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.04);
}

/* ============================================================
   顶部导航栏
   ============================================================ */
.top-bar {
    background: var(--primary);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar-left, .top-bar-right { display: flex; align-items: center; }

.semester-selector {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.15);
    transition: background 0.2s;
}
.semester-selector:active { background: rgba(255,255,255,0.25); }

.semester-current { font-size: 14px; font-weight: 600; }
.caret { font-size: 10px; margin-left: 4px; }

.top-btn {
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.15);
}

/* 学期下拉 */
.semester-dropdown {
    position: absolute;
    top: 48px;
    left: 0;
    right: 0;
    background: #fff;
    box-shadow: var(--shadow-lg);
    z-index: 99;
    border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden;
}

.semester-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.semester-item:active { background: var(--bg); }
.semester-item.active { background: var(--primary-light); }

.sem-item .sem-name { flex: 1; font-size: 14px; }
.badge-active {
    font-size: 11px;
    color: var(--primary);
    background: var(--primary-light);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}
.sem-balance { font-size: 13px; color: var(--text-tertiary); }
.semester-item.manage { color: var(--primary); font-weight: 600; justify-content: center; }

/* ============================================================
   页面内容区
   ============================================================ */
.page-content {
    padding: 16px;
    padding-bottom: 80px;
}

/* ============================================================
   余额卡片
   ============================================================ */
.balance-card {
    background: var(--primary);
    border-radius: var(--radius);
    padding: 24px 20px;
    text-align: center;
    color: #fff;
    margin-bottom: 16px;
}

.balance-label { font-size: 13px; opacity: 0.85; margin-bottom: 4px; }
.balance-amount { font-size: 32px; font-weight: 700; letter-spacing: -0.5px; }

.balance-stats {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.stat-mini {
    flex: 1;
    border-radius: var(--radius-sm);
    padding: 10px;
    text-align: center;
}
.stat-mini.income { background: var(--income-bg); }
.stat-mini.expense { background: var(--expense-bg); }

.stat-mini .stat-label { font-size: 12px; margin-bottom: 2px; }
.stat-mini.income .stat-label { color: var(--income); }
.stat-mini.expense .stat-label { color: var(--expense); }

.stat-mini .stat-value { font-size: 17px; font-weight: 700; }
.stat-mini.income .stat-value { color: var(--income); }
.stat-mini.expense .stat-value { color: var(--expense); }

/* ============================================================
   卡片
   ============================================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.card-title { font-size: 16px; font-weight: 600; }
.card-link { font-size: 13px; color: var(--primary); text-decoration: none; }

/* ============================================================
   交易记录列表
   ============================================================ */
.txn-list { list-style: none; }

.txn-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.txn-item:last-child { border-bottom: none; }

.txn-info { flex: 1; min-width: 0; }
.txn-summary { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-meta { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.txn-meta .txn-tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
    margin-right: 4px;
}

.txn-amount {
    font-size: 15px;
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
    margin-left: 8px;
}
.txn-amount.income { color: var(--income); }
.txn-amount.expense { color: var(--expense); }

/* ============================================================
   表单
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.form-label .req { color: var(--expense); }

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: #fff;
    -webkit-appearance: none;
    transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--primary);
    outline: none;
}

.form-textarea { min-height: 80px; resize: vertical; }

.form-row { display: flex; gap: 8px; }
.form-row .form-group { flex: 1; }

.form-hint { font-size: 12px; color: var(--text-tertiary); margin-top: 4px; }

/* ============================================================
   按钮
   ============================================================ */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { opacity: 0.8; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--income); color: #fff; }
.btn-danger { background: var(--expense); color: #fff; }
.btn-outline { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ============================================================
   底部 Tab 栏
   ============================================================ */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    display: flex;
    background: #fff;
    border-top: 1px solid var(--border);
    z-index: 100;
    padding: 4px 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 0;
    text-decoration: none;
    color: var(--text-tertiary);
    font-size: 11px;
    position: relative;
}

.tab-icon { font-size: 20px; line-height: 1; }
.tab-label { margin-top: 2px; }

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

.tab-add .tab-icon-add {
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 300;
    margin-top: -10px;
    box-shadow: 0 2px 8px rgba(74,144,217,0.4);
}
.tab-add .tab-label { margin-top: 2px; }

/* ============================================================
   登录页
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--primary);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-logo {
    text-align: center;
    color: #fff;
    margin-bottom: 32px;
}
.login-logo .logo-icon { font-size: 48px; }
.login-logo h1 { font-size: 20px; margin-top: 8px; }
.login-logo p { font-size: 14px; opacity: 0.85; margin-top: 4px; }

.login-form {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px 20px;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow-lg);
}

/* ============================================================
   空状态
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
}
.empty-icon { font-size: 48px; margin-bottom: 8px; }
.empty-text { font-size: 14px; }

/* ============================================================
   徽章/标签
   ============================================================ */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.badge-income { background: var(--income-bg); color: var(--income); }
.badge-expense { background: var(--expense-bg); color: var(--expense); }
.badge-info { background: var(--primary-light); color: var(--primary); }

/* ============================================================
   筛选条
   ============================================================ */
.filter-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 2px 0;
}
.filter-bar::-webkit-scrollbar { display: none; }

.filter-chip {
    white-space: nowrap;
    padding: 5px 14px;
    border-radius: 16px;
    font-size: 13px;
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}
.filter-chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ============================================================
   分类统计
   ============================================================ */
.cat-stat-row {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.cat-stat-row:last-child { border-bottom: none; }

.cat-stat-name { flex: 0 0 80px; font-size: 13px; }
.cat-stat-bar {
    flex: 1;
    height: 20px;
    background: var(--bg);
    border-radius: 4px;
    margin: 0 8px;
    overflow: hidden;
    position: relative;
}
.cat-stat-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}
.cat-stat-amount { flex: 0 0 70px; text-align: right; font-size: 13px; font-weight: 600; }

/* ============================================================
   附件/凭证
   ============================================================ */
.attachment-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.attachment-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg);
}
.attachment-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}

.attachment-upload {
    aspect-ratio: 1;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: var(--text-tertiary);
    cursor: pointer;
    background: var(--bg);
}

/* ============================================================
   提示消息
   ============================================================ */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 13px;
}
.alert-success { background: var(--income-bg); color: var(--income); }
.alert-error { background: var(--expense-bg); color: var(--expense); }
.alert-info { background: var(--primary-light); color: var(--primary); }

/* ============================================================
   列表项（管理页面）
   ============================================================ */
.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: #fff;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    box-shadow: var(--shadow);
}
.list-item-info { flex: 1; min-width: 0; }
.list-item-title { font-size: 14px; font-weight: 500; }
.list-item-sub { font-size: 12px; color: var(--text-tertiary); }
.list-item-actions { display: flex; gap: 6px; }

/* ============================================================
   图片灯箱
   ============================================================ */
.lightbox {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.lightbox img { max-width: 95%; max-height: 90vh; }

/* ============================================================
   工具类
   ============================================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-tertiary); }
.text-success { color: var(--income); }
.text-danger { color: var(--expense); }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }

/* ============================================================
   响应式微调
   ============================================================ */
@media (min-width: 481px) {
    .app-container { box-shadow: 0 0 40px rgba(0,0,0,0.08); }
}
