/* JZ 家庭记账系统 - 主样式 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f5f6fa;
    color: #333;
    line-height: 1.6;
}

/* 导航栏 */
.navbar {
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    font-size: 20px;
    font-weight: bold;
    color: #667eea;
    text-decoration: none;
}

.nav-menu {
    display: flex;
    gap: 5px;
}

.nav-menu a {
    padding: 8px 16px;
    color: #666;
    text-decoration: none;
    border-radius: 5px;
    transition: all 0.3s;
}

.nav-menu a:hover,
.nav-menu a.active {
    background: #667eea;
    color: white;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.nav-icon {
    position: relative;
    font-size: 20px;
    text-decoration: none;
    color: #666;
}

.badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #f44336;
    color: white;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 10px;
}

.user-menu {
    position: relative;
    cursor: pointer;
}

.user-name {
    color: #666;
    font-size: 14px;
}

.dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: white;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    border-radius: 5px;
    min-width: 150px;
    margin-top: 5px;
}

.user-menu:hover .dropdown,
.nav-dropdown:hover .dropdown-menu {
    display: block;
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown .dropdown-menu {
    display: none;
    position: absolute;
    left: 0;
    top: 100%;
    background: white;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    border-radius: 5px;
    min-width: 150px;
    margin-top: 5px;
    z-index: 100;
}

.nav-dropdown .dropdown-menu a {
    display: block;
    padding: 10px 15px;
    color: #666;
    text-decoration: none;
    border-bottom: 1px solid #eee;
}

.nav-dropdown .dropdown-menu a:last-child {
    border-bottom: none;
}

.nav-dropdown .dropdown-menu a:hover {
    background: #f5f6fa;
}

.dropdown a {
    display: block;
    padding: 10px 15px;
    color: #666;
    text-decoration: none;
    border-bottom: 1px solid #eee;
}

.dropdown a:last-child {
    border-bottom: none;
}

.dropdown a:hover {
    background: #f5f6fa;
}

/* 主容器 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.stat-icon {
    font-size: 40px;
}

.stat-label {
    color: #666;
    font-size: 14px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #333;
}

.stat-detail {
    font-size: 12px;
    color: #999;
}

.stat-card.income .stat-value { color: #4CAF50; }
.stat-card.expense .stat-value { color: #f44336; }
.stat-card.balance .stat-value { color: #2196F3; }
.stat-card.approval .stat-value { color: #FF9800; }

/* 卡片 */
.card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

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

.card-header h2 {
    font-size: 18px;
    color: #333;
}

.card-body {
    padding: 20px;
}

/* 表格 */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.table th {
    background: #f5f6fa;
    font-weight: 600;
    color: #666;
}

.table tr:hover {
    background: #f9f9f9;
}

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

/* 按钮 */
.btn {
    display: inline-block;
    padding: 10px 20px;
    background: #667eea;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

.btn-sm {
    padding: 5px 15px;
    font-size: 12px;
}

.btn-success { background: #4CAF50; }
.btn-success:hover { background: #45a049; }

.btn-danger { background: #f44336; }
.btn-danger:hover { background: #da190b; }

.btn-warning { background: #FF9800; }
.btn-warning:hover { background: #F57C00; }

/* 快捷操作 */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: white;
    border-radius: 10px;
    text-decoration: none;
    color: #333;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: all 0.3s;
}

.action-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.action-btn .icon {
    font-size: 30px;
    margin-bottom: 10px;
}

.action-btn.income { border-top: 3px solid #4CAF50; }
.action-btn.expense { border-top: 3px solid #f44336; }

/* 表单 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #333;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

/* 页脚 */
.footer {
    text-align: center;
    padding: 20px;
    color: #999;
    font-size: 14px;
    margin-top: 40px;
}

/* 响应式设计 - 移动端适配 */

/* 平板和手机通用 */
@media (max-width: 768px) {
    /* 导航栏优化 */
    .navbar {
        flex-wrap: wrap;
        height: auto;
        padding: 10px;
        position: sticky;
        top: 0;
        z-index: 1000;
    }
    
    .nav-brand {
        width: 100%;
        text-align: center;
        margin-bottom: 10px;
    }
    
    .nav-menu {
        order: 3;
        width: 100%;
        justify-content: center;
        margin-top: 10px;
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .nav-menu a {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .nav-right {
        width: 100%;
        justify-content: center;
        gap: 20px;
        margin-top: 10px;
    }
    
    .user-menu {
        display: none; /* 移动端隐藏用户菜单 */
    }
    
    /* 统计卡片 */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-icon {
        font-size: 30px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    /* 卡片优化 */
    .card {
        margin-bottom: 15px;
        border-radius: 8px;
    }
    
    .card-header {
        padding: 15px;
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .card-header h2 {
        font-size: 16px;
    }
    
    .card-body {
        padding: 15px;
    }
    
    /* 表格容器 - 横向滚动 */
    .table-responsive {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* iOS 平滑滚动 */
        margin-bottom: 15px;
    }
    
    /* 表格优化 */
    .table {
        font-size: 13px;
        min-width: 600px; /* 确保表格有足够宽度 */
    }
    
    .table th,
    .table td {
        padding: 8px;
    }
    
    /* 表单优化 */
    .form-group {
        margin-bottom: 15px;
    }
    
    .form-group label {
        font-size: 14px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 14px; /* 防止 iOS 缩放 */
        padding: 10px;
    }
    
    .form-row {
        grid-template-columns: 1fr !important;
    }
    
    /* 按钮优化 */
    .btn {
        padding: 10px 15px;
        font-size: 14px;
        width: 100%;
        margin-bottom: 8px;
    }
    
    .btn-sm {
        padding: 6px 12px;
        font-size: 12px;
        width: auto;
    }
    
    /* 快捷操作 */
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .action-btn {
        padding: 15px;
    }
    
    .action-btn .icon {
        font-size: 24px;
    }
    
    /* 筛选表单 */
    .filter-form {
        flex-direction: column;
    }
    
    .filter-form select,
    .filter-form input {
        width: 100%;
        margin-bottom: 8px;
    }
    
    .filter-form .btn {
        width: 100%;
    }
    
    /* 通知列表 */
    .notification-item {
        flex-direction: column;
        padding: 15px;
    }
    
    .notification-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .notification-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .notification-actions .btn {
        width: 100%;
    }
    
    /* 设置页面 */
    .settings-section {
        padding: 15px;
    }
    
    .settings-form {
        max-width: 100%;
    }
    
    /* 主题选项 */
    .theme-options {
        grid-template-columns: 1fr !important;
    }
    
    .theme-option-card {
        padding: 15px !important;
    }
    
    /* 模态框优化 */
    #editModal div[style*="margin: 50px auto"],
    #editModal div[style*="margin: 100px auto"] {
        margin: 20px auto !important;
        max-width: 95% !important;
        padding: 20px !important;
    }
    
    /* 登录页面 */
    .login-container {
        margin: 20px;
        padding: 30px 20px !important;
    }
    
    .login-header h1 {
        font-size: 24px;
    }
    
    /* 页脚 */
    .footer {
        font-size: 12px;
        padding: 15px;
    }
}

/* 小屏手机优化 */
@media (max-width: 375px) {
    .nav-menu a {
        padding: 5px 8px;
        font-size: 12px;
    }
    
    .stat-value {
        font-size: 18px;
    }
    
    .card-header h2 {
        font-size: 15px;
    }
    
    .table {
        font-size: 12px;
    }
    
    .quick-actions {
        grid-template-columns: 1fr;
    }
}

/* 横屏模式优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .quick-actions {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* 触摸优化 */
@media (hover: none) and (pointer: coarse) {
    /* 增大触摸目标 */
    .btn,
    .nav-menu a,
    .action-btn {
        min-height: 44px; /* iOS 推荐最小触摸目标 */
    }
    
    .table td,
    .table th {
        min-height: 40px;
    }
    
    /* 移除 hover 效果 */
    .nav-menu a:hover,
    .action-btn:hover {
        transform: none;
    }
}
