/* 财务管理页面样式 */

/* 财务面板样式 */
.finance-dashboard {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 992px) {
    .finance-dashboard {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .finance-overview-card,
    .finance-chart-card,
    .finance-detail-card,
    .payment-accounts-card {
        grid-column: span 2;
    }
}

/* 财务概览卡片样式 */
.finance-overview-card {
    background: linear-gradient(to right, #f8f9fa, #ffffff);
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.finance-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-evenly;
    gap: 20px;
    margin: 20px 0;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    min-width: 150px;
    text-align: center;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s;
}

.stat-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.stat-label {
    font-size: 16px;
    color: #6c757d;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 30px !important; /* 使用!important确保字体大小不被覆盖 */
    font-weight: 600;
    margin-bottom: 5px;
    line-height: 1.2; /* 确保行高合适 */
}

/* 期间选择器 */
.card-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.period-selector {
    padding: 6px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background-color: #fff;
    font-size: 14px;
    color: #495057;
}

.date-range-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-input {
    width: 120px;
    padding: 6px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

/* 金额样式 */
.income-amount {
    color: #28a745;
    font-weight: 600;
}

.expense-amount {
    color: #dc3545;
    font-weight: 600;
}

/* 财务概览卡片中的结余金额特殊样式 */
.finance-stats .balance-amount {
    color: #007bff;
    font-weight: 700;
    font-size: 30px;
}

/* 收支明细表格中的结余金额样式保持不变 */
.finance-table .balance-amount {
    color: #007bff;
    font-weight: 700;
    font-size: 28px;
}

/* 趋势指示器 */
.trend-indicator {
    font-size: 13px;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
}

.trend-indicator.up {
    background-color: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.trend-indicator.down {
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

/* 财务图表容器 */
.finance-chart-card {
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.finance-chart-container {
    height: 300px;
    margin: 15px 0;
}

.chart-tabs {
    display: flex;
    margin-bottom: 15px;
    border-bottom: 1px solid #dee2e6;
}

.chart-tab {
    padding: 8px 16px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-right: 10px;
    transition: all 0.2s;
}

.chart-tab:hover {
    color: #007bff;
}

.chart-tab.active {
    color: #007bff;
    border-bottom-color: #007bff;
    font-weight: 600;
}

/* 财务明细表格 */
.finance-detail-card {
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.finance-table-container {
    overflow-x: auto;
    /* 移除最大高度限制和垂直滚动 */
    max-height: none;
    overflow-y: visible;
    margin-top: 15px;
}

.finance-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    table-layout: fixed; /* 固定表格布局 */
}

.finance-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 12px 10px;
    text-align: left;
    border-bottom: 2px solid #dee2e6;
}

/* 设置各列固定宽度 */
.finance-table th:nth-child(1), /* 日期列 */
.finance-table td:nth-child(1) {
    width: 12%;
}

.finance-table th:nth-child(2), /* 类型列 */
.finance-table td:nth-child(2) {
    width: 10%;
}

.finance-table th:nth-child(3), /* 分类列 */
.finance-table td:nth-child(3) {
    width: 15%;
}

.finance-table th:nth-child(4), /* 金额列 - 变窄 */
.finance-table td:nth-child(4) {
    width: 10%;
    text-align: right; /* 金额右对齐 */
}

.finance-table th:nth-child(5), /* 备注列 - 变宽 */
.finance-table td:nth-child(5) {
    width: 40%;
    word-break: break-word; /* 允许单词内断行 */
}

.finance-table th:nth-child(6), /* 操作列 */
.finance-table td:nth-child(6) {
    width: 13%;
    text-align: center;
}

.finance-table th .sort-icon {
    margin-left: 5px;
    font-size: 12px;
    opacity: 0.5;
}

.finance-table th:hover .sort-icon {
    opacity: 1;
}

.finance-table td {
    padding: 10px;
    border-bottom: 1px solid #e9ecef;
    overflow: hidden;
    text-overflow: ellipsis;
}

.finance-table tr:hover {
    background-color: rgba(0, 123, 255, 0.05);
}

/* 隐藏分页器 */
.pagination-container {
    display: none !important;
}

/* 财务筛选器 */
.finance-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
}

.filter-item {
    flex: 1;
    min-width: 150px;
}

.filter-item label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    color: #6c757d;
}

.filter-item select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.filter-actions {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

/* 财务记录类型标签 */
.finance-type {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.finance-type.income {
    background-color: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.finance-type.expense {
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

/* 操作按钮 */
.action-buttons {
    display: flex;
    gap: 5px;
}

.btn-icon {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-icon.edit {
    background-color: rgba(0, 123, 255, 0.1);
    color: #007bff;
}

.btn-icon.delete {
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.btn-icon:hover {
    opacity: 0.8;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
}

.modal-content {
    background-color: #fff;
    margin: 50px auto;
    max-width: 600px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    animation: modalFadeIn 0.3s;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #e9ecef;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.close {
    font-size: 24px;
    font-weight: 700;
    color: #6c757d;
    cursor: pointer;
}

.close:hover {
    color: #343a40;
}

.modal-body {
    padding: 20px;
}

/* 财务表单样式 */
.finance-form .form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
}

.finance-form .form-group {
    flex: 1;
    min-width: 200px;
}

.finance-form label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: #495057;
}

.finance-form input,
.finance-form select,
.finance-form textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

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

.attachment-group input {
    border: none;
    padding: 0;
}

.preview-container {
    margin-top: 10px;
    max-width: 100%;
}

.preview-container img {
    max-width: 100%;
    max-height: 150px;
    border-radius: 4px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* 按钮样式 */
.btn-primary {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: #0069d9;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.btn-danger:hover {
    background-color: #c82333;
}

/* 对话框动画 */
.modal-content {
    transform-origin: top;
    transition: transform 0.3s ease-out, opacity 0.3s;
}

.modal.fade .modal-content {
    transform: translateY(-50px);
    opacity: 0;
}

.modal.show .modal-content {
    transform: translateY(0);
    opacity: 1;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .finance-form .form-row {
        flex-direction: column;
    }
    
    .finance-form .form-group {
        width: 100%;
    }
    
    .finance-stats {
        flex-direction: column;
        align-items: stretch;
    }
    
    .stat-item {
        width: 100%;
    }
    
    .card-actions {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .filter-actions {
        width: 100%;
        justify-content: space-between;
    }
}

/* 财务明细筛选控件样式覆盖 */
.finance-detail-card .filter-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: flex-start !important; /* 强制左对齐，覆盖其他样式 */
    align-items: flex-end !important; /* 改为底部对齐 */
    margin-bottom: 20px;
}

.finance-detail-card .form-group {
    margin-bottom: 0;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.finance-detail-card .date-range-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 新增：统一筛选控件标签和输入框样式 */
.finance-detail-card label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: #495057;
}

.finance-detail-card select.form-control,
.finance-detail-card input.form-control {
    height: 36px;
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box; /* 确保边框不增加实际宽度 */
}

/* 确保类型和分类筛选器与日期输入框对齐 */
.finance-detail-card #type-filter,
.finance-detail-card #category-filter {
    min-width: 140px;
    display: block;
}

/* 查询按钮样式 */
.finance-detail-card .btn-primary {
    height: 36px; /* 与输入框高度一致 */
    align-self: flex-end; /* 底部对齐 */
}

/* 日期输入框样式优化 */
.finance-detail-card input[type="date"] {
    cursor: pointer; /* 鼠标指针形状为手型 */
    padding-right: 30px; /* 为日历图标预留空间 */
    position: relative;
}

/* 隐藏默认的日历图标，并使整个输入框可点击 */
.finance-detail-card input[type="date"]::-webkit-calendar-picker-indicator {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background: transparent; /* 背景透明 */
    color: transparent; /* 文字透明 */
    cursor: pointer;
    z-index: 1; /* 确保可点击层在最上方 */
}

/* 添加自定义日历图标 */
.finance-detail-card input[type="date"]::after {
    content: "";
    display: block;
    width: 20px;
    height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'%3E%3Cpath fill='%23495057' d='M9 11H7v2h2v-2zm4 0h-2v2h2v-2zm4 0h-2v2h2v-2zm2-7h-1V2h-2v2H8V2H6v2H5c-1.11 0-1.99.9-1.99 2L3 20a2 2 0 0 0 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 16H5V9h14v11z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none; /* 防止图标阻挡点击 */
}

/* 样式输入框获取焦点时的效果 */
.finance-detail-card input[type="date"]:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* 确保日期输入框的值正确对齐 */
.finance-detail-card input[type="date"] {
    text-align: left;
    padding-left: 10px;
}

/* 添加合计行样式 */
.total-row {
    background-color: #f8f9fa;
    font-weight: bold;
    border-top: 2px solid #dee2e6;
}

.total-row td {
    padding: 10px 8px;
}

.text-right {
    text-align: right;
}

/* 合计行内的金额样式增强 */
.total-row .income-amount,
.total-row .expense-amount,
.total-row .balance-amount {
    display: block;
    padding: 3px 0;
    /* 确保合计行中的字体大小不受财务概览样式影响 */
    font-size: inherit; 
}

.total-row .balance-amount {
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid #dee2e6;
    /* 确保合计行中的结余金额不使用财务概览中的大字体 */
    font-size: inherit; 
}

/* 合计行的金额单元格特殊处理 */
.total-row td:nth-child(4) {
    width: 10%;
    text-align: right;
}

/* 合计行的文本单元格要横跨前三列 */
.total-row td.text-right {
    font-weight: bold;
}

/* 确保模态框中的保存和取消按钮样式一致 */
.form-actions .close-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s;
    font-size: 14px;
    width: auto;
    height: auto;
    display: inline-block;
}

.form-actions .close-btn:hover {
    background-color: #0062cc;
}

/* 进度对话框样式 */
.progress-modal .modal-content {
    max-width: 350px; /* 调整宽度 */
    text-align: center;
}

.progress-modal .modal-header {
    /* 可以根据需要调整样式 */
}

.progress-modal .close-progress {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}

.progress-modal .close-progress:hover,
.progress-modal .close-progress:focus {
    color: black;
    text-decoration: none;
}

.progress-modal .modal-body {
    padding: 20px;
}

.progress-indicator .spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: var(--primary-color);
    animation: spin 1s ease infinite;
    margin: 10px auto;
}

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

#progress-status-icon .success {
    color: var(--success-color);
}

#progress-status-icon .error {
    color: var(--danger-color);
}

/* 收款账户卡片样式 */
.payment-accounts-card {
    margin-top: 20px;
}

.payment-accounts-table {
    width: 100%;
    border-collapse: collapse;
}

.payment-accounts-table th,
.payment-accounts-table td {
    padding: 10px 15px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.payment-accounts-table th {
    background-color: #f5f5f5;
    color: #333;
    font-weight: 600;
}

.payment-accounts-table tr:hover {
    background-color: #f9f9f9;
}

.payment-accounts-table tr:last-child td {
    border-bottom: none;
}

.payment-accounts-table .no-data {
    text-align: center;
    color: #757575;
    padding: 20px;
    font-style: italic;
}

/* 设置列宽，与财务表格保持一致的样式 */
.payment-accounts-table th:nth-child(1),
.payment-accounts-table td:nth-child(1) {
    width: 10%; /* ID列宽度 */
}

.payment-accounts-table th:nth-child(2),
.payment-accounts-table td:nth-child(2) {
    width: 77%; /* 收款账户信息列宽度 */
}

.payment-accounts-table th:nth-child(3),
.payment-accounts-table td:nth-child(3) {
    width: 13%; /* 操作列宽度，与财务表格保持一致 */
    text-align: center;
}

/* 统一的编辑和删除按钮样式 */
.finance-table .btn-edit,
.finance-table .btn-delete,
.payment-accounts-table .btn-edit,
.payment-accounts-table .btn-delete {
    padding: 5px 10px;
    margin: 0 2px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.finance-table .btn-edit,
.payment-accounts-table .btn-edit {
    background-color: var(--primary-color);
    color: white;
}

.finance-table .btn-edit:hover,
.payment-accounts-table .btn-edit:hover {
    background-color: #0062cc;
}

.finance-table .btn-delete,
.payment-accounts-table .btn-delete {
    background-color: var(--danger-color);
    color: white;
}

.finance-table .btn-delete:hover,
.payment-accounts-table .btn-delete:hover {
    background-color: #c82333;
}

/* 财务概览卡片中的月份选择器容器 */
.finance-overview-card .filter-controls {
    position: relative;
}

.filter-item {
    display: flex;
    align-items: center;
    margin-left: 15px;
}

.filter-item label {
    margin-right: 8px;
    margin-bottom: 0;
    white-space: nowrap;
}