/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Microsoft YaHei', sans-serif;
}

body {
    background-color: #f9f9f9;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    text-decoration: none;
    color: #a62a1a;
    transition: color 0.3s;
}

a:hover {
    color: #8e2414;
}

ul {
    list-style: none;
}

/* 头部样式 */
header {
    background-color: #a62a1a;
    color: white;
    padding: 5px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.logo img {
        height: 50px;
    margin-top: 5px;
}

nav ul {
    display: flex;
}

nav ul li {
    margin-left: 20px;
}

nav ul li a {
    color: white;
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background-color 0.3s;
}

nav ul li a:hover {
        color: #ffffff !important; /* 修改为品牌红色 */
    background-color: rgba(255, 255, 255, 0.2);
}

/* 通用按钮样式 */
.btn-primary {
    background-color: #a62a1a;
    color: white;
    border: none;
    padding: 15px 146.5px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
    background-color: #8e2414;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-primary-reg {
    background-color: #a62a1a;
    color: white;
    border: none;
    padding: 15px 133.3px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.btn-primary-reg:hover {
    background-color: #8e2414;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-logout {
    background-color: #a62a1a;
    color: white;
    border: none;
    padding: 5px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    font-size: 15px;
}

.btn-logout:hover {
    background-color: #8e2414;
}

.btn-add {
    background-color: #a62a1a;
    color: white;
    border: none;
    padding: 10px 80px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.btn-add:hover {
    background-color: #8e2414;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-search {
    background-color: #a62a1a;
    color: white;
    border: none;
    padding: 13px 30px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    font-size: 15px;
}

.btn-search:hover {
    background-color: #8e2414;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-primary-save {
    background-color: #a62a1a;
    color: white;
    border: none;
    padding: 15px 196px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.btn-primary-save:hover {
    background-color: #8e2414;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-edit {
    color: #4CAF50;
    margin-right: 10px;
    transition: color 0.3s;
}

.btn-edit:hover {
    color: #45a049;
}

.btn-delete {
    color: #F44336;
    transition: color 0.3s;
}

.btn-delete:hover {
    color: #d32f2f;
}

/* 登录页面样式 */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    flex: 1;
    background-color: #f9f9f9;
}

.banner {
    height: 130px;
    background: url('../img/jizhangbanner.png') repeat-x;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 24px;
    font-weight: bold;
    background-color: #a62a1a;
}

.banner-content {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box, .register-box {
    background-color: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    transition: transform 0.3s;
}

.login-box:hover, .register-box:hover {
    transform: translateY(-5px);
}

.login-box h2, .register-box h2 {
    color: #a62a1a;
    text-align: center;
    margin-bottom: 30px;
    font-size: 28px;
    font-weight: bold;
}

.register-box .subtitle {
    text-align: center;
    margin-bottom: 30px;
    color: #666;
    font-size: 16px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: #a62a1a;
    box-shadow: 0 0 0 2px rgba(166, 42, 26, 0.2);
    outline: none;
}

.password-container {
    position: relative;
}

.show-password {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #999;
    transition: color 0.3s;
}

.show-password:hover {
    color: #a62a1a;
}

.register-link, .login-link {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
}

/* 记账列表页面样式 */
.dashboard-container {
    padding: 30px;
    width: 1200px;
    margin: 0 auto;
    box-sizing: border-box;
    flex: 1;
}

.dashboard-container h1 {
    color: #a62a1a;
    text-align: center;
    margin-bottom: 30px;
    font-size: 32px;
    font-weight: bold;
    position: relative;
}

.dashboard-container h1::after {
    content: '';
    display: block;
    width: 100px;
    height: 4px;
    background-color: #a62a1a;
    margin: 10px auto 0;
    border-radius: 2px;
}

.user-info {
    background-color: white;
    padding: 20px 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.user-info span {
    display: flex;
    align-items: center;
    font-size: 16px;
    color: #555;
}

.user-info i {
    margin-right: 10px;
}

.filter-section {
    background-color: white;
    padding: 20px 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    
}

.filter-form {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap; /* 允许换行 */
    flex-grow: 1; /* 占据剩余空间 */
}

.filter-form input[type="date"] {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
}

.filter-form select {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    background-color: white;
}

.stats-section {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    flex: 1;
    background-color: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    text-align: center;
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card h3 {
    margin-bottom: 15px;
    color: #555;
    font-size: 18px;
}

.stat-card .amount {
    font-size: 28px;
    font-weight: bold;
}

.transactions-list {
    background-color: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    overflow-x: auto;
    width: 100%;
    max-width: 1200px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th, table td {
    padding: 15px 20px;
    text-align: center;
    border-bottom: 1px solid #eee;
    font-size: 13px;
}

table th {
    background-color: #f9f9f9;
    font-weight: bold;
    color: #555;
}

.income {
    color: #a62a1a;
    font-weight: bold;
}

.expense {
    color: #359339;
    font-weight: bold;
}

table tr:hover {
    background-color: #f5f5f5;
}

/* 分页容器 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 30px 0;
    flex-wrap: wrap; /* 允许换行 */
}

/* 分页按钮 */
.pagination a {
    display: block;
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    color: #a62a1a;
    text-decoration: none;
    transition: all 0.3s;
}

/* 当前页样式 */
.pagination a.active {
    background: #a62a1a;
    color: white;
    border-color: #a62a1a;
}

/* 悬停效果 */
.pagination a:hover:not(.active) {
    background: #f5f5f5;
}

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

.modal-content {
    background-color: white;
    margin: 8% auto;
    padding: 40px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: fadeIn 0.3s;
}

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

.close {
    position: absolute;
    top: 15px;
    right: 38px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
    transition: color 0.3s;
}

.close:hover {
    color: #333;
}

/* 提示框样式 */
.flash-message {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 30px;
    border-radius: 6px;
    font-weight: bold;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    animation: fadeOut 3s forwards;
}

.flash-message.success {
    background-color: #4CAF50;
    color: white;
}

.flash-message.error {
    background-color: #F44336;
    color: white;
}

@keyframes fadeOut {
    0% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

/* 页脚样式 */
footer {
    background-color: #333;
    color: white;
    text-align: center;
    padding: 20px 0;
    margin-top: auto;
}

/* 修改顶部按钮悬停颜色 */
/* 在现有.btn-logout和.btn-add样式中添加hover颜色 */

.btn-logout:hover,
.btn-add:hover {
    color: white !important;
    background-color: #8e2414; /* 原有背景色保持不变 */
    
}

/* 响应式设计补充 */
@media (max-width: 1200px) {
    .dashboard-container {
        width: 100%;
        padding: 20px;
    }
    
    .user-info {
        flex-wrap: wrap;
        gap: 15px;
    }
    
    .filter-section {
        flex-direction: column;
        align-items: stretch;
        flex-wrap: nowrap;   /* 防止换行挤压 */
    }
        .filter-form {
        gap: 10px;
    }
    
    .search-input {
        flex: 1 1 100%; /* 手机端占满宽度 */
        max-width: 100%;
    }
    
    .btn-add {
    background-color: #a62a1a;
    color: white;
    border: none;
    padding: 10px 80px;  /* 左右留白保持居中 */
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    /* 新增固定长度设置 */
    width: 200px !important;  /* 强制固定宽度 */
    box-sizing: border-box;   /* 包含padding */
    white-space: nowrap;      /* 防止文字换行 */
    flex-shrink: 0;          /* 禁止被压缩 */
    order: 1; /* 让"记一笔"按钮始终在最后 */
}
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        padding: 15px;
    }
    
    nav ul {
        flex-wrap: wrap;
        justify-content: center;
        margin-top: 15px;
    }
    
    nav ul li {
        margin: 5px 10px;
    }
    
    .stats-section {
        flex-direction: column;
    }
    
    table th,
    table td {
        padding: 10px;
        font-size: 12px;
    }
    .btn-add {
        width: 200px !important;  /* 移动端保持相同宽度 */
        margin-top: 15px;         /* 添加顶部间距 */
    }
     input[type="date"], select, .search-input {
        width: 100% !important; /* 移动端自动撑满 */
    }

}

/* 强制覆盖收入支出颜色 */
.income {
    color: #a62a1a !important;
    font-weight: bold;
}

.expense {
    color: #359339 !important;
    font-weight: bold;
}



/* 商家备注文字截断 */
table td:nth-child(4), /* 商家列 */
table td:nth-child(5) { /* 备注列 */
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 中等屏幕适配 */
@media (max-width: 1200px) {
    .transactions-list {
        padding: 15px;
    }
    
    .stat-card {
        padding: 15px;
    }
    .btn-add {
        width: 200px !important;  /* 重复声明确保覆盖 */
        padding: 10px 20px !important;  /* 调整内边距 */
    }
}

/* 移动端适配 */
@media (max-width: 480px) {
    .modal-content {
        width: 95%;
        padding: 20px;
    }
    
    .btn-primary-save {
        padding: 15px 20px;
        width: 100%;
    }
}

/* 确保表格布局稳定 */
table {
    table-layout: fixed;
}

/* 固定其他列宽度 */
table td:first-child { width: 160px; } /* 时间列 */
table td:nth-child(2) { width: 120px; } /* 金额列 */
table td:nth-child(3) { width: 80px; }  /* 类型列 */

/* 新增搜索框样式 */
.search-input {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    width: 150px;
    transition: all 0.3s;
        flex: 0 1 150px; /* 固定基础宽度 */
    min-width: 120px; /* 最小宽度 */
}

.search-input:focus {
    border-color: #a62a1a;
    box-shadow: 0 0 0 2px rgba(166, 42, 26, 0.2);
    outline: none;
}

/* 确保日期选择器宽度一致 */
input[type="date"] {
    width: 150px;
    padding: 10px;
}

/* 修复select下拉框样式 */
select {
    width: 95px !important; /* 固定类别选择框宽度 */
}

/* 新增独立样式 */
.modal-select {
    width: 420px !important; /* 保持原类别框宽度 */
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    background-color: white;
}

.banner-link {
    color: white !important;
    text-decoration: none !important;
    transition: opacity 0.3s;
}

.banner-link:hover {
    opacity: 0.9;
    text-decoration: none !important;
}


/* 导航栏样式 */
nav ul {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

nav ul li {
    margin-left: 20px;
}

/* 更多工具下拉框样式 */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    color: white;
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.dropdown-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.dropdown-menu {
    display: none;
    position: absolute;
    background-color: white;
    min-width: 130px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
    z-index: 1000;
    top: 100%; /* 从父元素底部开始定位 */
    left: -30px; /* 向左移动10px */
    margin-top: 5px; /* 向下移动15px */
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    
}

.dropdown-menu.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.dropdown-menu a {
    color: #333;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    transition: all 0.3s ease;
    font-size: 14px;
}

.dropdown-menu a:hover {
    background-color: #a62a1a;
    color: #a62a1a; /* 鼠标悬停时字体显示为红色 */
}

/* 响应式设计 */
@media (max-width: 768px) {
    nav ul {
        flex-wrap: wrap;
    }
}