/* 
  永成财务管理系统 - 企业级核心样式
  全局 CSS 变量、布局架构与基础组件重构
*/

:root {
    /* 企业级商务色彩体系 */
    --yc-primary: #1d3557;     /* 深邃的商务蓝 */
    --yc-secondary: #457b9d;   /* 辅助蓝 */
    --yc-accent: #2a9d8f;      /* 强调色：松石绿 */
    --yc-success: #2b9348;     /* 稳健的翠绿（收入） */
    --yc-danger: #e63946;      /* 警示的珊瑚红（支出） */
    --yc-warning: #e9c46a;
    --yc-bg: #f4f6f8;          /* 极浅灰白背景，提升卡片悬浮感 */
    --yc-surface: #ffffff;
    --yc-text-main: #111827;
    --yc-text-muted: #6b7280;
    --yc-border: #e5e7eb;

    /* 布局尺寸 */
    --sidebar-width: 240px;
    --bottom-nav-height: 60px;
    --header-height: 64px;
    --fab-size: 56px;

    /* 动画与阴影 */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-fab: 0 4px 12px rgba(29, 53, 87, 0.3);
}

body {
    background-color: var(--yc-bg);
    color: var(--yc-text-main);
    font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* 数字等宽对齐 */
.number-font {
    font-family: 'DIN', 'Roboto Mono', monospace;
    letter-spacing: 0.5px;
}

/* 文本颜色复写 */
.text-success { color: var(--yc-success) !important; }
.text-danger { color: var(--yc-danger) !important; }
.text-primary { color: var(--yc-primary) !important; }
.bg-primary { background-color: var(--yc-primary) !important; }

/* 页面切换动画 */
.page-fade-in {
    animation: fadeInUp var(--transition-base) forwards;
}

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

/* ===== 核心架构：侧边栏与主内容区 (PC) ===== */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--yc-surface);
    border-right: 1px solid var(--yc-border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform var(--transition-base);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--yc-border);
}

.sidebar-logo {
    height: 32px;
    margin-right: 12px;
    object-fit: contain;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.5rem;
    overflow-y: auto;
}

.nav-item-custom {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--yc-text-muted);
    border-radius: 8px;
    margin-bottom: 0.25rem;
    text-decoration: none;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-item-custom i {
    font-size: 1.25rem;
    margin-right: 12px;
    width: 24px;
    text-align: center;
}

.nav-item-custom:hover {
    background-color: var(--yc-bg);
    color: var(--yc-primary);
}

.nav-item-custom.active {
    background-color: rgba(29, 53, 87, 0.08);
    color: var(--yc-primary);
    font-weight: 600;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--yc-border);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.top-header {
    height: var(--header-height);
    background-color: var(--yc-surface);
    border-bottom: 1px solid var(--yc-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 999;
}

.content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    padding-bottom: 100px; /* 为可能的 FAB 留出空间 */
}

/* ===== 核心架构：底部导航栏 (手机端) ===== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background-color: var(--yc-surface);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--yc-text-muted);
    text-decoration: none;
    font-size: 0.75rem;
    transition: color var(--transition-fast);
}

.bottom-nav-item i {
    font-size: 1.25rem;
    margin-bottom: 2px;
}

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

/* ===== 组件定制 ===== */

/* 卡片 */
.yc-card {
    background: var(--yc-surface);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--yc-border);
    transition: box-shadow var(--transition-fast);
}

.yc-card:hover {
    box-shadow: var(--shadow-md);
}

/* 悬浮操作按钮 (FAB) */
.fab-container {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1010;
}

.fab-btn {
    width: var(--fab-size);
    height: var(--fab-size);
    border-radius: 50%;
    background-color: var(--yc-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: var(--shadow-fab);
    border: none;
    cursor: pointer;
    transition: transform var(--transition-fast), background-color var(--transition-fast);
}

.fab-btn:hover {
    transform: scale(1.05);
    background-color: #152740;
}

.fab-btn:active {
    transform: scale(0.95);
}

/* 数据表格降维 (手机端卡片化) */
.table-responsive-custom {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-responsive-custom th {
    background-color: #f8fafc;
    color: var(--yc-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--yc-border);
}

.table-responsive-custom td {
    padding: 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--yc-border);
}

.table-responsive-custom tbody tr {
    transition: background-color var(--transition-fast);
}

.table-responsive-custom tbody tr:hover {
    background-color: #f8fafc;
}

/* 骨架屏 */
.skeleton {
    background: #e2e8f0;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.skeleton::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* 报表卡片 */
.data-card {
    border: none;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    height: 100%;
    background: var(--yc-surface);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

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

.icon-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

/* 详情展开/收起动画 */
.detail-row {
    display: none;
    background-color: var(--yc-bg) !important;
}
.detail-row.show {
    display: table-row;
    animation: fadeIn 0.2s ease-in-out;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.expand-btn {
    cursor: pointer;
    color: var(--yc-primary);
    transition: transform 0.2s;
}
.expand-btn.expanded {
    transform: rotate(180deg);
}

/* 交互辅助类 */
.opacity-0 { opacity: 0 !important; }
.hover-opacity-100:hover { opacity: 1 !important; }
.transition-hover { transition: transform 0.2s ease, box-shadow 0.2s ease; }
.transition-hover:hover { transform: translateY(-2px); }

/* SweetAlert2 定制 */
.swal2-popup.yc-swal {
    border-radius: 16px !important;
    padding: 24px !important;
    box-shadow: var(--shadow-lg) !important;
}

.swal2-styled.swal2-confirm {
    background-color: var(--yc-primary) !important;
    border-radius: 8px !important;
}

.swal2-styled.swal2-cancel {
    background-color: #f1f5f9 !important;
    color: var(--yc-text-main) !important;
    border-radius: 8px !important;
}

/* 表单元素尺寸优化 (手机端防误触) */
.form-control, .form-select, .btn {
    min-height: 44px;
    border-radius: 8px;
}

/* ===== 响应式适配 ===== */
@media (max-width: 768px) {
    .sidebar {
        display: none; /* 手机端隐藏侧边栏 */
    }
    
    .bottom-nav {
        display: flex; /* 手机端显示底部导航 */
    }
    
    .top-header {
        padding: 0 1rem;
    }
    
    .content-wrapper {
        padding: 1rem;
        padding-bottom: calc(var(--bottom-nav-height) + 80px);
    }
    
    .fab-container {
        bottom: calc(var(--bottom-nav-height) + 60px);
        right: 16px;
    }
    
    /* 修正固定在底部的统计栏位置 */
    #summary-bar {
        bottom: var(--bottom-nav-height) !important;
        border-radius: 16px 16px 0 0 !important;
        padding: 12px 16px;
        z-index: 1005; /* 确保不被底部导航遮挡 */
    }
    
    /* 表格转卡片 (手机端窄横条优化) */
    .mobile-card-list thead {
        display: none;
    }
    
    .mobile-card-list tbody tr:not(.detail-row) {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        background: var(--yc-surface);
        border: 1px solid var(--yc-border);
        border-radius: 12px;
        margin-bottom: 12px;
        padding: 12px 16px;
        box-shadow: var(--shadow-sm);
    }
    
    .mobile-card-list tbody tr:not(.detail-row) td {
        border-bottom: none;
        padding: 4px 0;
        display: flex;
        align-items: center;
    }
    
    .mobile-card-list tbody tr:not(.detail-row) td::before {
        display: none; /* 隐藏所有前缀 Label */
    }

    /* 日期和明细合并占据左侧大部分空间 */
    .mobile-card-list tbody tr:not(.detail-row) td[data-label="日期"],
    .mobile-card-list tbody tr:not(.detail-row) td[data-label="分享时间"] {
        width: auto;
        margin-right: 12px;
        color: var(--yc-text-muted);
        font-size: 0.8rem;
    }

    .mobile-card-list tbody tr:not(.detail-row) td[data-label="明细"],
    .mobile-card-list tbody tr:not(.detail-row) td[data-label="关联交易"] {
        flex: 1;
        width: auto;
        justify-content: flex-start;
        font-size: 0.95rem;
        font-weight: 500;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* 金额占据右侧 */
    .mobile-card-list tbody tr:not(.detail-row) td[data-label="金额"] {
        width: auto;
        justify-content: flex-end;
        font-size: 1.1rem;
        font-weight: bold;
    }

    /* 隐藏手机端横条上不需要显示的列 (如：归属、状态等，移到展开详情里) */
    .mobile-card-list tbody tr:not(.detail-row) td[data-label="收支"],
    .mobile-card-list tbody tr:not(.detail-row) td[data-label="归属"],
    .mobile-card-list tbody tr:not(.detail-row) td[data-label="选择"],
    .mobile-card-list tbody tr:not(.detail-row) td[data-label="状态"],
    .mobile-card-list tbody tr:not(.detail-row) td[data-label="有效期至"],
    .mobile-card-list tbody tr:not(.detail-row) td[data-label="访问限制"],
    .mobile-card-list tbody tr:not(.detail-row) td[data-label="已访问"] {
        display: none;
    }

    /* 展开详情行样式 */
    .mobile-card-list tbody tr.detail-row {
        display: none;
        background: var(--yc-bg);
        border: 1px solid var(--yc-border);
        border-top: none;
        border-radius: 0 0 12px 12px;
        margin-top: -16px; /* 向上偏移以连接横条 */
        margin-bottom: 12px;
        padding: 0;
    }
    
    .mobile-card-list tbody tr.detail-row.show {
        display: block;
    }
    
    .mobile-card-list tbody tr.detail-row td {
        display: block;
        width: 100%;
        padding: 0;
        border: none;
    }
    
    .mobile-card-list tbody tr.detail-row td::before {
        display: none;
    }
}
