/**
 * 全站统一UI样式
 * 设计风格：现代、简洁、电商感
 * 主色：品牌橙 #ff6900
 * 背景：浅灰 #f5f5f5
 * 卡片：白色 #ffffff
 */

/* ========== 基础重置 ========== */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    color: #1a1a1a;
    background: #f5f5f5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
}

a {
    color: #1a1a1a;
    text-decoration: none;
}

a:hover {
    color: #ff6900;
}

img {
    max-width: 100%;
    height: auto;
}

/* ========== 颜色变量 ========== */
:root {
    --primary-color: #ff6900;
    --primary-hover: #e65c00;
    --primary-active: #cc5200;
    --text-primary: #1a1a1a;
    --text-secondary: #6b6b6b;
    --text-muted: #9b9b9b;
    --bg-page: #f5f5f5;
    --bg-card: #ffffff;
    --border-color: #e5e5e5;
    --border-input: #d1d1d1;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
}

/* ========== 布局容器 ========== */
.container {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px;
}

.page-wrapper {
    min-height: 100vh;
    background: var(--bg-page);
    padding-bottom: 60px; /* 为底部导航留空间 */
}

/* ========== 卡片组件 ========== */
.card {
    background: var(--bg-card);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-color);
    margin-bottom: 16px;
    overflow: hidden;
}

.card-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 16px;
}

.card-body {
    padding: 16px;
}

.card-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background: #fafafa;
}

/* ========== 顶部导航 ========== */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 480px;
    margin: 0 auto;
}

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

.header-back {
    display: flex;
    align-items: center;
    color: var(--text-primary);
    font-size: 24px;
}

.header-action {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-action a,
.header-action button {
    color: var(--text-primary);
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
}

/* ========== 底部导航 ========== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: nowrap; /* 禁止换行 */
    justify-content: space-between;
    align-items: stretch;
    padding: 6px 0;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
    z-index: 100;
    max-width: 100%;
    overflow: hidden; /* 防止溢出 */
}

.nav-item {
    flex: 1 1 0; /* 平分空间 */
    min-width: 0; /* 允许收缩 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px 2px;
    color: var(--text-muted);
    font-size: 10px;
    text-decoration: none;
    transition: color 0.2s;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item i {
    font-size: 22px;
    margin-bottom: 2px;
    flex-shrink: 0;
}

.nav-item span {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

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

/* 小屏幕优化 */
@media (max-width: 360px) {
    .nav-item {
        font-size: 9px;
        padding: 4px 1px;
    }
    .nav-item i {
        font-size: 20px;
    }
}

/* ========== 按钮组件 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.5;
}

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

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

.btn-primary:active {
    background: var(--primary-active);
    transform: scale(0.98);
}

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

.btn-secondary:hover {
    border-color: var(--text-primary);
}

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

.btn-outline:hover {
    background: var(--primary-color);
    color: #ffffff;
}

.btn-block {
    width: 100%;
}

.btn-lg {
    height: 48px;
    font-size: 16px;
}

.btn-sm {
    height: 36px;
    padding: 8px 16px;
    font-size: 13px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

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

.form-control {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-input);
    border-radius: 8px;
    transition: all 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.form-control:hover {
    border-color: var(--text-primary);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(255, 105, 0, 0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

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

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

/* ========== 列表组件 ========== */
.list-group {
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.list-item:last-child {
    border-bottom: none;
}

.list-item:active {
    background: #f5f5f5;
}

.list-item-content {
    flex: 1;
}

.list-item-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.list-item-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

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

.list-item-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 8px;
    margin-right: 12px;
    color: var(--primary-color);
    font-size: 20px;
}

/* ========== 余额卡片 ========== */
.balance-card {
    background: linear-gradient(135deg, var(--primary-color) 0%, #ff8533 100%);
    border-radius: 12px;
    padding: 24px;
    color: #ffffff;
    margin-bottom: 16px;
}

.balance-label {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 8px;
}

.balance-amount {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 16px;
}

.balance-actions {
    display: flex;
    gap: 12px;
}

.balance-btn {
    flex: 1;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.balance-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ========== 统计网格 ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat-item {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 4px;
}

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

/* ========== 功能网格 ========== */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding: 16px;
}

.feature-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-primary);
}

.feature-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff5eb;
    border-radius: 12px;
    margin-bottom: 8px;
    color: var(--primary-color);
    font-size: 24px;
}

.feature-label {
    font-size: 12px;
    text-align: center;
}

/* ========== 订单卡片 ========== */
.order-card {
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 12px;
    overflow: hidden;
}

.order-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #fafafa;
    border-bottom: 1px solid var(--border-color);
}

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

.order-status {
    font-size: 13px;
    font-weight: 500;
}

.order-status.pending {
    color: var(--warning-color);
}

.order-status.completed {
    color: var(--success-color);
}

.order-status.cancelled {
    color: var(--danger-color);
}

.order-body {
    display: flex;
    padding: 16px;
    gap: 12px;
}

.order-image {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    background: #f5f5f5;
}

.order-info {
    flex: 1;
}

.order-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.order-price {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-color);
}

.order-commission {
    font-size: 13px;
    color: var(--success-color);
}

.order-footer {
    display: flex;
    justify-content: flex-end;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    gap: 12px;
}

/* ========== 商品卡片 ========== */
.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 16px;
}

.product-card {
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.product-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: #f5f5f5;
}

.product-info {
    padding: 12px;
}

.product-title {
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.product-price {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-color);
}

/* ========== 空状态 ========== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-text {
    font-size: 14px;
}

/* ========== 加载状态 ========== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ========== 弹窗遮罩 ========== */
.modal-overlay {
    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: 24px;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 12px;
    width: 100%;
    max-width: 360px;
    overflow: hidden;
}

.modal-header {
    padding: 20px;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
}

.modal-body {
    padding: 0 20px 20px;
}

.modal-footer {
    display: flex;
    border-top: 1px solid var(--border-color);
}

.modal-footer .btn {
    flex: 1;
    border-radius: 0;
    height: 48px;
}

.modal-footer .btn + .btn {
    border-left: 1px solid var(--border-color);
}

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

.badge-primary {
    background: #fff5eb;
    color: var(--primary-color);
}

.badge-success {
    background: #e8f5e9;
    color: var(--success-color);
}

.badge-warning {
    background: #fff8e1;
    color: #f57c00;
}

.badge-danger {
    background: #ffebee;
    color: var(--danger-color);
}

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

.divider-text {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    font-size: 12px;
}

.divider-text::before,
.divider-text::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.divider-text::before {
    margin-right: 12px;
}

.divider-text::after {
    margin-left: 12px;
}

/* ========== 工具类 ========== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--primary-color); }
.text-success { color: var(--success-color); }
.text-warning { color: var(--warning-color); }
.text-danger { color: var(--danger-color); }
.text-muted { color: var(--text-muted); }

.font-bold { font-weight: 600; }
.font-normal { font-weight: 400; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.p-0 { padding: 0; }
.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }

.hidden { display: none; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }

/* ========== 动画 ========== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

.animate-slide-up {
    animation: slideUp 0.3s ease-out;
}

/* ========== 响应式 ========== */
@media (max-width: 480px) {
    .container {
        padding: 0 12px;
    }
    
    .card-body {
        padding: 12px;
    }
    
    .feature-grid {
        gap: 12px;
        padding: 12px;
    }
    
    .product-grid {
        gap: 8px;
        padding: 12px;
    }
}

/* ========== 安全区域适配 ========== */
@supports (padding: max(0px)) {
    .page-wrapper {
        padding-bottom: max(60px, calc(60px + env(safe-area-inset-bottom)));
    }
}
