/* ========================================
   金铺管家 - 黄金回收店铺管理 PWA
   移动端优先 · 金色主题
   ======================================== */

:root {
    --gold: #D4AF37;
    --gold-light: #F4D160;
    --gold-dark: #B8860B;
    --gold-gradient: linear-gradient(135deg, #D4AF37, #B8860B);
    --bg: #F5F5F0;
    --card-bg: #FFFFFF;
    --text: #2C2C2C;
    --text-secondary: #888888;
    --border: #E8E8E8;
    --danger: #E53935;
    --success: #43A047;
    --info: #1E88E5;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --nav-height: 60px;
    --header-height: 52px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
}

/* ========== 顶部标题栏 ========== */
.app-header {
    height: var(--header-height);
    background: var(--gold-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(180,140,11,0.3);
}

.app-header h1 {
    font-size: 18px;
    font-weight: 600;
}

.header-action {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    opacity: 0.9;
}
.header-action:active { opacity: 1; }

/* ========== 主内容区 ========== */
#main-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(var(--nav-height) + 20px);
}

.view {
    display: none;
    padding: 12px;
}
.view.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

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

/* ========== 仪表盘 ========== */
.dashboard-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.dashboard-date {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-item {
    padding: 12px;
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
}
.stat-item::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px; height: 100%;
}
.stat-recycle { background: #FFF8E1; }
.stat-recycle::before { background: var(--gold); }
.stat-sale { background: #E8F5E9; }
.stat-sale::before { background: var(--success); }
.stat-expense { background: #FFEBEE; }
.stat-expense::before { background: var(--danger); }
.stat-profit { background: #E3F2FD; }
.stat-profit::before { background: var(--info); }

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}
.stat-sub {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ========== 金价网格 ========== */
.gold-price-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.gold-price-item {
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gold-price-name {
    font-size: 13px;
    font-weight: 500;
}

.gold-price-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--gold-dark);
}

/* ========== 库存 ========== */
.inventory-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.inventory-header h2 {
    font-size: 15px;
}
.inventory-total {
    font-size: 16px;
    font-weight: 700;
    color: var(--gold-dark);
}

.inventory-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.inventory-tag {
    background: #FFF8E1;
    border: 1px solid #F0E0A0;
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 12px;
}
.inventory-tag b { color: var(--gold-dark); }

/* ========== 快捷操作 ========== */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

.quick-btn {
    background: var(--card-bg);
    border: none;
    border-radius: var(--radius);
    padding: 16px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform 0.1s;
    color: var(--text);
}
.quick-btn:active { transform: scale(0.96); }
.quick-recycle { color: var(--gold-dark); }
.quick-sale { color: var(--success); }
.quick-expense { color: var(--danger); }
.quick-btn span { font-size: 12px; font-weight: 500; }

/* ========== 区块标题 ========== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 16px 0 8px;
}
.section-header h2 {
    font-size: 15px;
    font-weight: 600;
}

.link-btn {
    background: none;
    border: none;
    color: var(--gold-dark);
    font-size: 13px;
    cursor: pointer;
}

/* ========== 列表 ========== */
.list-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.search-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    background: var(--card-bg);
}
.search-input:focus { border-color: var(--gold); }

.filter-btn {
    padding: 10px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

.date-filter {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    padding: 8px;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}
.date-filter input[type="date"] {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 13px;
    flex: 1;
    min-width: 0;
}
.date-filter span { font-size: 12px; color: var(--text-secondary); }

.btn-small {
    padding: 6px 14px;
    background: var(--gold);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.btn-text {
    background: none;
    color: var(--text-secondary);
    text-decoration: underline;
}

.list-summary {
    background: #FFF8E1;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--text);
    display: none;
}
.list-summary.show { display: block; }
.list-summary b { color: var(--gold-dark); }

.record-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

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

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

.record-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-right: 6px;
}
.badge-recycle { background: #FFF3CD; color: #856404; }
.badge-sale { background: #D4EDDA; color: #155724; }
.badge-expense { background: #F8D7DA; color: #721C24; }

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

.record-info {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    font-size: 13px;
    margin-bottom: 6px;
}
.record-info-item {
    display: flex;
    gap: 4px;
}
.record-info-item .label { color: var(--text-secondary); }

.record-amount {
    font-size: 18px;
    font-weight: 700;
}
.record-amount.income { color: var(--success); }
.record-amount.expense { color: var(--danger); }

.record-photos {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.record-photo-thumb {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    object-fit: cover;
    cursor: pointer;
    border: 1px solid var(--border);
}

.record-notes {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    background: #FAFAFA;
    padding: 6px 8px;
    border-radius: 6px;
}

.record-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}
.record-actions button {
    background: none;
    border: none;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}
.btn-edit { color: var(--info); }
.btn-delete { color: var(--danger); }

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}
.empty-state svg {
    width: 56px; height: 56px;
    margin-bottom: 12px;
    opacity: 0.3;
}

/* ========== 统计页 ========== */
.stats-toolbar {
    margin-bottom: 12px;
}
.stats-toolbar select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--card-bg);
    outline: none;
}

.profit-overview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.profit-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    text-align: center;
}
.profit-card.highlight {
    grid-column: span 2;
    background: var(--gold-gradient);
    color: #fff;
}
.profit-card.highlight .profit-label,
.profit-card.highlight .profit-value {
    color: #fff;
}

.profit-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.profit-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.chart-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}
.chart-section h3 {
    font-size: 14px;
    margin-bottom: 10px;
}
.chart-container {
    position: relative;
    height: 200px;
}

.detail-table {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 10px;
    background: #FAFAFA;
    border-radius: 6px;
    font-size: 13px;
}
.detail-row b { color: var(--gold-dark); }

/* ========== 底部导航 ========== */
.bottom-nav {
    height: var(--nav-height);
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    display: flex;
    position: absolute;
    bottom: 0; left: 0; right: 0;
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}

.nav-item {
    flex: 1;
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    color: #999;
    font-size: 11px;
    transition: color 0.2s;
}
.nav-item.active {
    color: var(--gold-dark);
}

/* ========== 浮动按钮 ========== */
.fab {
    position: absolute;
    bottom: calc(var(--nav-height) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gold-gradient);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(180,140,11,0.4);
    z-index: 99;
    transition: transform 0.1s;
}
.fab:active { transform: scale(0.92); }
.fab.hidden { display: none; }

/* ========== 弹窗 ========== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: flex-end;
}
.modal-overlay.show {
    display: flex;
    animation: fadeIn 0.2s;
}

.modal-content {
    background: var(--card-bg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: slideUp 0.25s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 10;
    border-radius: 20px 20px 0 0;
}
.modal-header h2 {
    font-size: 17px;
    font-weight: 600;
}
.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

.modal-body {
    padding: 16px 20px 24px;
}

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

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

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
    background: #FAFAFA;
    transition: border-color 0.2s;
    font-family: inherit;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--gold);
    background: #fff;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.form-computed {
    background: #FFF8E1;
    border-color: #F0E0A0;
    font-weight: 600;
    color: var(--gold-dark);
}

/* 照片上传 */
.photo-upload-area {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.photo-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
}
.photo-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
}
.photo-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    border: none;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
}

.photo-add-btn {
    width: 80px;
    height: 80px;
    border: 2px dashed #DDD;
    border-radius: 8px;
    background: #FAFAFA;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 11px;
}
.photo-add-btn:active { border-color: var(--gold); color: var(--gold); }

.form-submit {
    width: 100%;
    padding: 14px;
    background: var(--gold-gradient);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}
.form-submit:active { opacity: 0.9; }

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

/* ========== 照片查看器 ========== */
.photo-viewer {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.92);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.photo-viewer.show { display: flex; }
.photo-viewer img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

/* ========== Toast ========== */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 3000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    text-align: center;
    max-width: 280px;
}
.toast.show { opacity: 1; }

/* ========== 金价编辑表格 ========== */
.price-edit-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.price-edit-row:last-child { border-bottom: none; }
.price-edit-row label { font-size: 14px; }
.price-edit-row input {
    width: 100px;
    text-align: right;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
}

/* ========== 确认弹窗 ========== */
.confirm-box {
    text-align: center;
    padding: 20px;
}
.confirm-box p {
    margin-bottom: 16px;
    font-size: 15px;
}
.confirm-box .btn-row {
    display: flex;
    gap: 10px;
}
.confirm-box .btn-row button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
}
.btn-cancel { background: #EEE; color: var(--text); }
.btn-confirm { background: var(--danger); color: #fff; }
