/* 康明优格日常记账系统 - 样式表 */
/* 适配手机和电脑 */

/* ==================== 基础样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4CAF50;
    --primary-dark: #388E3C;
    --primary-light: #C8E6C9;
    --secondary-color: #2196F3;
    --danger-color: #F44336;
    --warning-color: #FF9800;
    --text-primary: #212121;
    --text-secondary: #757575;
    --text-light: #FFFFFF;
    --bg-primary: #FFFFFF;
    --bg-secondary: #F5F5F5;
    --bg-header: #4CAF50;
    --border-color: #E0E0E0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --radius: 8px;
    --radius-lg: 12px;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ==================== 加载动画 ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--primary-light);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    margin-top: 12px;
    color: var(--text-secondary);
}

/* ==================== 页面布局 ==================== */
.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==================== 登录页面 ==================== */
.login-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

.logo {
    text-align: center;
    margin-bottom: 10px;
    color: var(--text-light);
    max-width: 100%;
    width: 100%;
    padding: 0 20px;
}

.logo h1,
.logo-img {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    max-width: 180px;
    width: 30cqb;
    height: auto;
}

.logo-img {
    display: block;
    object-fit: contain;
    margin: 0 auto;
}

.logo p {
    font-size: 1.2rem;
    opacity: 0.9;
}

.login-form {
    background: var(--bg-primary);
    padding: 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 300px;
}

/* ==================== 头部 ==================== */
.app-header {
    background: var(--bg-header);
    color: var(--text-light);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.clickable-title {
    cursor: pointer;
    user-select: none;
    transition: opacity 0.2s;
}

.clickable-title:hover {
    opacity: 0.8;
}

.clickable-title:active {
    opacity: 0.6;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
}

/* ==================== 主内容区 ==================== */
.app-main {
    flex: 1;
    padding: 16px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* ==================== 统计栏 ==================== */
.stats-bar {
    display: flex;
    justify-content: space-around;
    background: var(--bg-primary);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.stat-item {
    text-align: center;
    flex: 1;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-value.amount {
    color: var(--primary-color);
    font-size: 1.3rem;
}

/* ==================== 月份选择器 ==================== */
.month-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: var(--bg-primary);
    padding: 12px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

#monthDisplay {
    font-size: 1.1rem;
    font-weight: 600;
    min-width: 120px;
    text-align: center;
}

/* ==================== 操作栏 ==================== */
.action-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.action-bar .btn {
    flex: 1;
}

/* ==================== 账目列表 ==================== */
.records-list {
    background: var(--bg-primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.record-item {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.record-item:last-child {
    border-bottom: none;
}

.record-item:hover {
    background: var(--bg-secondary);
}

.record-item:active {
    background: var(--primary-light);
}

.record-main {
    flex: 1;
}

.record-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.record-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.record-description {
    font-weight: 500;
    color: var(--text-primary);
}

.record-remark {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.record-images-indicator {
    font-size: 1rem;
}

.record-amount {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap;
}

.record-operator {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 8px;
}

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* ==================== 分页 ==================== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 8px;
}

.pagination .btn {
    min-width: 36px;
    padding: 6px 12px;
}

.pagination .current-page {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ==================== 按钮 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--text-light);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border-color);
}

.btn-danger {
    background: var(--danger-color);
    color: var(--text-light);
}

.btn-danger:hover:not(:disabled) {
    background: #D32F2F;
}

.btn-block {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: rgba(255,255,255,0.2);
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
}

.btn-close:hover {
    color: var(--text-primary);
}

/* ==================== 表单 ==================== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.form-group .required {
    color: var(--danger-color);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea,
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s;
    font-family: inherit;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
}

input::placeholder,
textarea::placeholder {
    color: #BDBDBD;
}

textarea {
    resize: vertical;
}

.hint-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* ==================== 弹窗 ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

.modal-small {
    max-width: 320px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    justify-content: flex-end;
}

.modal-footer .btn {
    min-width: 80px;
}

.text-center {
    text-align: center;
}

/* ==================== 图片上传 ==================== */
.image-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.image-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.image-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-item .remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==================== 详情弹窗 ==================== */
.detail-item {
    margin-bottom: 16px;
}

.detail-item label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.detail-item span {
    font-size: 1rem;
    color: var(--text-primary);
}

.detail-item .amount {
    color: var(--primary-color);
    font-size: 1.3rem;
    font-weight: 600;
}

.detail-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.detail-image-item {
    width: 100px;
    height: 100px;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.detail-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.detail-image-item:hover img {
    transform: scale(1.05);
}

/* ==================== 图片预览弹窗 ==================== */
.image-modal {
    background: rgba(0,0,0,0.9);
}

.image-modal-content {
    max-width: 90vw;
    max-height: 90vh;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-modal-content img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: var(--radius);
}

.image-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 2rem;
    z-index: 1001;
}

/* ==================== 后台管理 ==================== */
.admin-tabs {
    display: flex;
    background: var(--bg-primary);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--primary-color);
    color: var(--text-light);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.admin-toolbar {
    margin-bottom: 16px;
}

.admin-list {
    background: var(--bg-primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.user-item,
.log-item {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-item:last-child,
.log-item:last-child {
    border-bottom: none;
}

.user-info-text {
    flex: 1;
}

.user-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.user-type {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.user-type.admin {
    color: var(--primary-color);
}

.user-actions {
    display: flex;
    gap: 8px;
}

.log-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.log-action {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.log-user {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.log-details {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ==================== 消息提示 ==================== */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 0.9rem;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ==================== 响应式适配 ==================== */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    .login-container {
        padding: 16px;
    }

    .logo {
        padding: 0 10px;
    }

    .logo-img {
        max-width: 120px;
    }

    .app-header {
        padding: 12px 16px;
    }
    
    .app-header h1 {
        font-size: 1.1rem;
    }
    
    .app-main {
        padding: 12px;
    }
    
    .stats-bar {
        padding: 12px;
    }
    
    .record-item {
        padding: 12px;
    }
    
    .modal-content {
        max-height: 95vh;
    }
    
    .modal-footer {
        flex-direction: row;
    }
    
    .modal-footer .btn {
        flex: 1;
    }
}

@media (min-width: 769px) {
    .records-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 16px;
        background: transparent;
        box-shadow: none;
    }
    
    .record-item {
        background: var(--bg-primary);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        border-bottom: none;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .record-amount {
        margin-top: 8px;
        font-size: 1.4rem;
    }
}
