/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --bg: #f0f4f8;
    --card-bg: #ffffff;
    --border: #e5e7eb;
    --radius: 10px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --transition: 0.2s ease;
}

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== Header ===== */
.header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    color: white;
    padding: 16px 0;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    flex-shrink: 0;
}

.site-title {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
}

.site-subtitle {
    font-size: 12px;
    opacity: 0.7;
    font-weight: 400;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-online {
    background: #4ade80;
    box-shadow: 0 0 6px #4ade80;
    animation: pulse 2s infinite;
}

.status-offline {
    background: #f87171;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.btn-contact {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-contact:hover {
    background: rgba(255,255,255,0.25);
}

.contact-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: white;
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: 16px;
    min-width: 240px;
    z-index: 200;
}

.header-contact {
    position: relative;
}

.contact-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
}

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

.contact-label {
    font-size: 13px;
    color: var(--gray-500);
    font-weight: 500;
}

.contact-value {
    font-size: 14px;
    color: var(--gray-800);
    font-weight: 600;
}

/* ===== Stats Bar ===== */
.stats-bar {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 14px 0;
}

.stats-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-number {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

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

/* ===== Main Content ===== */
.main-content {
    padding: 24px 0 48px;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-box svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
}

.search-box input {
    width: 100%;
    padding: 10px 12px 10px 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    background: white;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.filter-group {
    display: flex;
    gap: 8px;
}

.filter-btn {
    padding: 8px 18px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    color: var(--gray-600);
}

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

.filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== Loading ===== */
.loading {
    text-align: center;
    padding: 80px 0;
    color: var(--gray-400);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

/* ===== Categories ===== */
.categories-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.category-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.category-header:hover {
    background: var(--gray-100);
}

.category-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.category-icon svg {
    width: 20px;
    height: 20px;
    color: var(--primary);
}

.category-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.category-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-800);
}

.category-desc {
    font-size: 12px;
    color: var(--gray-500);
}

.category-count {
    background: var(--primary-light);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.category-toggle {
    color: var(--gray-400);
    transition: var(--transition);
}

.category-toggle.collapsed {
    transform: rotate(-90deg);
}

/* ===== Product Table ===== */
.products-wrapper {
    overflow-x: auto;
}

.product-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.product-table thead {
    display: none;
}

.product-table th {
    padding: 10px 20px;
    text-align: left;
    font-size: 12px;
    color: var(--gray-500);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    background: var(--gray-50);
}

.product-row {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 12px;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--gray-100);
    transition: var(--transition);
}

.product-row:hover {
    background: var(--gray-50);
}

.product-row:last-child {
    border-bottom: none;
}

.product-row.hidden {
    display: none;
}

.product-name-cell {
    min-width: 0;
}

.product-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-800);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.product-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--gray-100);
    color: var(--gray-600);
}

.product-tag.tag-hot {
    background: var(--danger-light);
    color: var(--danger);
}

.product-tag.tag-new {
    background: var(--success-light);
    color: var(--success);
}

.product-tag.tag-premium {
    background: var(--warning-light);
    color: var(--warning);
}

.product-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--danger);
    white-space: nowrap;
    min-width: 70px;
    text-align: right;
}

.product-price .currency {
    font-size: 12px;
    font-weight: 500;
}

.product-stock {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 90px;
}

.stock-badge {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 6px;
    font-weight: 600;
}

.stock-in {
    background: var(--success-light);
    color: var(--success);
}

.stock-out {
    background: var(--gray-100);
    color: var(--gray-400);
}

.stock-low {
    background: var(--warning-light);
    color: var(--warning);
}

.product-action {
    min-width: 80px;
    text-align: right;
}

.btn-buy {
    padding: 6px 20px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    background: var(--primary);
    color: white;
}

.btn-buy:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

.btn-buy:disabled {
    background: var(--gray-200);
    color: var(--gray-400);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ===== Expand/Collapse ===== */
.products-body {
    display: block;
}

.products-body.collapsed {
    display: none;
}

.show-more {
    text-align: center;
    padding: 12px;
    border-top: 1px solid var(--gray-100);
}

.show-more button {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    padding: 6px 16px;
    border-radius: 6px;
    transition: var(--transition);
}

.show-more button:hover {
    background: var(--primary-light);
}

/* ===== No Results ===== */
.no-results {
    text-align: center;
    padding: 80px 0;
    color: var(--gray-400);
}

.no-results svg {
    margin-bottom: 16px;
}

/* ===== Footer ===== */
.footer {
    background: var(--gray-800);
    color: var(--gray-300);
    padding: 24px 0;
    text-align: center;
    font-size: 13px;
}

.footer-note {
    margin-top: 4px;
    font-size: 12px;
    color: var(--gray-500);
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-400);
    padding: 0;
    line-height: 1;
}

.modal-body {
    padding: 20px;
}

.modal-body .detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
}

.modal-body .detail-label {
    color: var(--gray-500);
    font-size: 14px;
}

.modal-body .detail-value {
    color: var(--gray-800);
    font-size: 14px;
    font-weight: 600;
}

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

.btn-secondary {
    padding: 8px 20px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    color: var(--gray-600);
    transition: var(--transition);
}

.btn-secondary:hover {
    background: var(--gray-50);
}

.btn-primary {
    padding: 8px 20px;
    border: none;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    transition: var(--transition);
}

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

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header-container {
        flex-wrap: wrap;
        gap: 12px;
    }

    .header-actions {
        gap: 12px;
    }

    .stats-container {
        gap: 16px;
        justify-content: space-around;
    }

    .stat-number {
        font-size: 20px;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        max-width: none;
    }

    .product-row {
        grid-template-columns: 1fr auto;
        gap: 8px;
        padding: 12px 16px;
    }

    .product-stock {
        grid-column: 1;
        min-width: 0;
    }

    .product-action {
        grid-column: 2;
        grid-row: 1;
    }

    .product-price {
        grid-column: 2;
        grid-row: 2;
    }

    .btn-contact span {
        display: none;
    }
}

/* ===== Purchase Section (Payment) ===== */
.purchase-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--gray-100);
}

.purchase-quantity,
.purchase-total,
.purchase-contact {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.purchase-label {
    font-size: 14px;
    color: var(--gray-600);
    font-weight: 500;
    white-space: nowrap;
}

.quantity-control {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.qty-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--gray-50);
    font-size: 18px;
    cursor: pointer;
    color: var(--gray-600);
    transition: var(--transition);
    font-family: inherit;
}

.qty-btn:hover {
    background: var(--gray-100);
}

.quantity-control input {
    width: 60px;
    height: 36px;
    text-align: center;
    border: none;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    outline: none;
}

.quantity-control input::-webkit-outer-spin-button,
.quantity-control input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.purchase-amount {
    font-size: 22px;
    font-weight: 700;
    color: var(--danger);
}

.purchase-input {
    flex: 1;
    min-width: 150px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.purchase-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Payment Methods */
.payment-methods {
    margin-bottom: 16px;
}

.payment-methods-label {
    display: block;
    font-size: 14px;
    color: var(--gray-600);
    font-weight: 500;
    margin-bottom: 8px;
}

.payment-methods-list {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.payment-method-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
}

.payment-method-option:hover {
    border-color: var(--primary);
}

.payment-method-option.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.payment-method-option input {
    display: none;
}

.payment-method-name {
    color: var(--gray-700);
    font-weight: 500;
}

.payment-method-option.selected .payment-method-name {
    color: var(--primary);
    font-weight: 600;
}

.payment-loading-hint {
    font-size: 13px;
    color: var(--gray-400);
}

.payment-unavailable {
    font-size: 13px;
    color: var(--gray-400);
    padding: 8px 0;
}

/* Purchase Status */
.purchase-status {
    margin-top: 12px;
}

.status-notice {
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    border: 1px solid;
    margin-top: 8px;
}

.status-warn {
    background: var(--warning-light);
    border-color: var(--warning);
    color: #92400e;
}

.status-error {
    background: var(--danger-light);
    border-color: var(--danger);
    color: #991b1b;
}

/* Contact Purchase Button */
.btn-contact-purchase {
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    color: var(--gray-600);
    transition: var(--transition);
}

.btn-contact-purchase:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

/* ===== Order Result ===== */
.order-result {
    text-align: center;
}

.order-result-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 700;
    color: var(--success);
}

.order-success-icon {
    width: 28px;
    height: 28px;
    background: var(--success-light);
    color: var(--success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.order-result .detail-row {
    text-align: left;
}

.order-actions {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* Payment Redirect */
.payment-redirect {
    margin-top: 20px;
    padding: 20px;
    background: var(--primary-light);
    border-radius: 10px;
    text-align: center;
}

.payment-redirect p {
    margin-bottom: 12px;
    color: var(--primary-dark);
    font-size: 14px;
}

.btn-go-pay {
    display: inline-block;
    padding: 10px 28px;
    text-decoration: none;
    font-size: 15px;
}

/* Payment QR Code */
.payment-qrcode {
    margin-top: 20px;
    padding: 20px;
    background: var(--gray-50);
    border-radius: 10px;
    text-align: center;
}

.qr-placeholder {
    display: flex;
    justify-content: center;
    margin: 16px 0;
}

.qr-box {
    width: 160px;
    height: 160px;
    background: white;
    border: 2px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
}

.qr-amount {
    font-size: 15px;
    color: var(--gray-700);
}

.qr-amount strong {
    color: var(--danger);
    font-size: 18px;
}

/* Payment Crypto */
.payment-crypto {
    margin-top: 20px;
    padding: 20px;
    background: var(--gray-50);
    border-radius: 10px;
    text-align: left;
}

.payment-crypto > p {
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--gray-700);
    text-align: center;
}

.crypto-detail {
    background: white;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
}

.crypto-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--gray-100);
}

.crypto-row:last-child {
    border-bottom: none;
}

.crypto-row span {
    font-size: 13px;
    color: var(--gray-500);
}

.crypto-row code {
    font-size: 13px;
    color: var(--gray-800);
    font-weight: 600;
    font-family: 'Courier New', monospace;
    word-break: break-all;
    text-align: right;
    max-width: 60%;
}

.crypto-warn {
    font-size: 12px !important;
    color: var(--warning) !important;
    text-align: center !important;
}

/* ===== 账号入口（前台头部）===== */
.header-account {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-account {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    white-space: nowrap;
}

.btn-account:hover {
    background: rgba(255, 255, 255, 0.28);
}

.btn-account.solid {
    background: #fff;
    color: #2563eb;
    border-color: #fff;
    font-weight: 600;
}

.btn-account.solid:hover {
    background: #f1f5f9;
}

.account-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

@media (max-width: 768px) {
    .header-account { display: none; }
}

/* 移动端显示账号入口 */
@media (max-width: 768px) {
    .header-account {
        display: flex;
        margin-left: 4px;
    }
    .btn-account {
        padding: 7px 11px;
        font-size: 13px;
    }
    .btn-account .account-avatar { display: none; }
}
