/* ============================================================
   比亚迪充电记录工具 - 移动优先 H5 样式
   ============================================================ */

:root {
    --primary: #07C160;
    --primary-light: #E8F8EF;
    --primary-dark: #06AD56;
    --bg: #F5F5F5;
    --card-bg: #FFFFFF;
    --text: #1A1A1A;
    --text-secondary: #8E8E93;
    --text-muted: #C7C7CC;
    --border: #E5E5EA;
    --danger: #FF3B30;
    --warning: #FF9500;
    --success: #34C759;
    --ac-blue: #007AFF;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --nav-height: 64px;
    --header-height: 52px;
}

/* ==================== 基础重置 ==================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
                 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    max-width: 512px;
    margin: 0 auto;
    min-height: 100vh;
    padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 16px));
}

a { color: var(--ac-blue); text-decoration: none; }
a:active { opacity: 0.7; }

input, select, textarea, button {
    font-family: inherit;
    font-size: inherit;
}

/* ==================== 顶部导航栏 ==================== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-btn {
    background: none;
    border: none;
    font-size: 14px;
    color: var(--ac-blue);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.header-btn:active { background: rgba(0,0,0,0.05); }

/* ==================== 底部导航栏 ==================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 512px;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: var(--nav-height);
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 100;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background: rgba(255,255,255,0.92);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    height: 100%;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 10px;
    position: relative;
    transition: color 0.2s;
}

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

.nav-item .nav-icon {
    font-size: 22px;
    line-height: 1;
}

.nav-item .nav-label {
    font-size: 10px;
    line-height: 1;
}

/* ==================== 页面容器 ==================== */
.page {
    padding: 16px;
    min-height: calc(100vh - var(--header-height) - var(--nav-height));
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
}

/* ==================== 卡片 ==================== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.stat-item {
    text-align: center;
    padding: 12px 8px;
    background: var(--bg);
    border-radius: var(--radius);
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.stat-value.small {
    font-size: 17px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ==================== 记录列表 ==================== */
.record-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.record-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    position: relative;
}

.record-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.record-date {
    font-size: 13px;
    color: var(--text-secondary);
}

.record-body {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.record-main {
    flex: 1;
}

.record-kwh {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.record-kwh .unit {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 2px;
}

.record-meta {
    display: flex;
    gap: 12px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.record-meta span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 4px;
}

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

.record-price .amount {
    font-size: 18px;
    font-weight: 600;
    color: var(--danger);
}

.record-price .per-kwh {
    font-size: 11px;
    color: var(--text-secondary);
}

.record-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    line-height: 1;
}

.record-delete:hover { color: var(--danger); }

/* ==================== 标签 ==================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.badge-dc {
    background: #E3F2FD;
    color: #1565C0;
}

.badge-ac {
    background: #E8F5E9;
    color: #2E7D32;
}

.badge-home {
    background: #FFF3E0;
    color: #E65100;
}

.badge-public {
    background: #F3E5F5;
    color: #6A1B9A;
}

.badge-manual {
    background: #ECEFF1;
    color: #546E7A;
}

.badge-ocr {
    background: #E8F5E9;
    color: #2E7D32;
}

.badge-success {
    background: #E8F5E9;
    color: #2E7D32;
}

.badge-danger {
    background: #FFEBEE;
    color: #C62828;
}

/* ==================== 按钮 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.4;
}

.btn:active { transform: scale(0.97); opacity: 0.9; }

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 17px;
    border-radius: 12px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

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

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.form-label.required::after {
    content: ' *';
    color: var(--danger);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    background: var(--card-bg);
    color: var(--text);
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.1);
}

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

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%238E8E93'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.form-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* ==================== 提示消息 ==================== */
.toast {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 999;
    max-width: calc(100% - 32px);
    white-space: nowrap;
    animation: toastIn 0.3s ease;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ==================== 空状态 ==================== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
    display: block;
}

.empty-state-text {
    font-size: 14px;
    margin-bottom: 16px;
}

/* ==================== 横幅 ==================== */
.banner {
    background: linear-gradient(135deg, #E8F8EF, #D4F1E4);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--primary-dark);
}

.banner-icon {
    font-size: 24px;
    flex-shrink: 0;
}

/* ==================== 弹窗 (纯CSS) ==================== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal {
    background: var(--card-bg);
    width: 100%;
    max-width: 512px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 20px 16px 32px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-title {
    font-size: 17px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 16px;
}

.modal-body {
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.modal-actions .btn {
    flex: 1;
}

/* ==================== 筛选栏 ==================== */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.filter-chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ==================== OCR 上传区域 ==================== */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 16px;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-zone-icon {
    font-size: 40px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.upload-zone-text {
    font-size: 14px;
    color: var(--text-secondary);
}

.upload-zone-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ==================== OCR 结果列表 ==================== */
.ocr-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 8px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 12px;
}

.ocr-item-img {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg);
}

.ocr-item-info {
    flex: 1;
    min-width: 0;
}

.ocr-item-name {
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ocr-item-result {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.ocr-item-status {
    flex-shrink: 0;
}

/* ==================== 分页 ==================== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 0;
}

.page-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--ac-blue);
    text-decoration: none;
    background: var(--card-bg);
}

.page-btn:hover { background: var(--bg); }

.page-info {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ==================== 认证页面 ==================== */
.auth-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 90vh;
    padding: 20px;
}

.auth-logo {
    font-size: 48px;
    margin-bottom: 8px;
}

.auth-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.auth-form {
    width: 100%;
}

.auth-switch {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--primary);
    font-weight: 500;
}

/* ==================== 个人中心 ==================== */
.profile-section {
    margin-bottom: 20px;
}

.profile-section-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding-left: 4px;
}

.menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--card-bg);
    border-radius: var(--radius);
    margin-bottom: 2px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s;
}

.menu-item:active { background: var(--bg); }

.menu-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.menu-item-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

.menu-item-label {
    font-size: 15px;
}

.menu-item-value {
    font-size: 14px;
    color: var(--text-secondary);
}

.menu-item-arrow {
    color: var(--text-muted);
    font-size: 14px;
}

/* ==================== 图表区域(简单柱状图) ==================== */
.chart-bar {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 120px;
    padding: 0 8px;
}

.chart-bar-item {
    flex: 1;
    position: relative;
}

.chart-bar-fill {
    background: var(--primary);
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    transition: height 0.5s ease;
}

.chart-bar-label {
    text-align: center;
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.chart-bar-value {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 2px;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 8px;
    font-size: 12px;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chart-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* ==================== 加载动画 ==================== */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 14px;
}

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== 图片预览 ==================== */
.image-preview-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.image-preview-overlay img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
}

/* ==================== 分割线 ==================== */
.divider {
    height: 1px;
    background: var(--border);
    margin: 16px 0;
}

/* ==================== 进度条 ==================== */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ==================== 响应式微调 ==================== */
@media (max-width: 360px) {
    .stat-value { font-size: 18px; }
    .record-kwh { font-size: 20px; }
    .stat-grid { gap: 8px; }
}
