/* ============================================
   CDK发卡网 - 主样式表
   Modern e-commerce design system
   ============================================ */

:root {
    --primary: #1677ff;
    --primary-hover: #0958d9;
    --primary-bg: #e6f4ff;
    --success: #52c41a;
    --success-bg: #f6ffed;
    --danger: #ff4d4f;
    --danger-bg: #fff2f0;
    --warning: #faad14;
    --warning-bg: #fffbe6;
    --text: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --bg: #f7f8fa;
    --white: #ffffff;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --radius: 6px;
    --radius-sm: 4px;
    --radius-lg: 8px;
    --shadow: 0 4px 18px rgba(0,0,0,0.05);
    --shadow-hover: 0 8px 30px rgba(0,0,0,0.08);
    --transition: 0.2s ease;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    --container: 1120px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    font-size: 13px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ========== TOP NAVBAR ========== */
.navbar-main {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 1000;
}
.navbar-inner {
    max-width: var(--container);
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}
.navbar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    flex-shrink: 0;
}
.navbar-logo .logo-icon {
    width: 28px; height: 28px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}
.navbar-links {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
    margin: 0 16px;
}
.navbar-links a {
    display: block;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    white-space: nowrap;
}
.navbar-links a:hover,
.navbar-links a.active {
    color: var(--primary);
    background: var(--primary-bg);
}
.navbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.btn-nav-order {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}
.btn-nav-order:hover { background: var(--primary-hover); color: white; }
.navbar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text);
    cursor: pointer;
    padding: 4px;
}

/* ========== MERCHANT INFO ========== */
.merchant-section {
    max-width: var(--container);
    margin: 16px auto 0;
    padding: 0 16px;
}
.merchant-info {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}
.merchant-avatar {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: #e6f4ff;
    border: 2px solid var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--primary);
    overflow: hidden;
}
.merchant-avatar img { width: 100%; height: 100%; object-fit: cover; }
.merchant-detail { flex: 1; min-width: 0; }
.merchant-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.merchant-name {
    font-size: 16px;
    font-weight: 600;
}
.badge-verified {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #fffbe6;
    color: #d48806;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}
.btn-merchant {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--text-secondary);
}
.btn-merchant:hover { border-color: var(--primary); color: var(--primary); }
.btn-merchant.green { border-color: var(--success); color: var(--success); }
.merchant-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.merchant-announce {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    align-items: flex-start;
}
.merchant-announce .announce-icon {
    color: var(--warning);
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 2px;
}
.merchant-announce .announce-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.8;
    word-break: break-word;
}

/* ========== MAIN CONTENT PANEL ========== */
.content-area {
    max-width: var(--container);
    margin: 16px auto 32px;
    padding: 0 16px;
}
.product-panel {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
}
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}
.panel-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    font-weight: 600;
}
.panel-title i { color: var(--warning); font-size: 16px; }
.search-input-group {
    display: flex;
    align-items: center;
    background: #f3f4f6;
    border-radius: var(--radius);
    width: 220px;
    height: 34px;
    overflow: hidden;
    border: 1px solid transparent;
    transition: all var(--transition);
}
.search-input-group:focus-within {
    background: var(--white);
    border-color: var(--primary);
}
.search-input-group input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0 10px;
    font-size: 13px;
    outline: none;
    color: var(--text);
    min-width: 0;
}
.search-input-group input::placeholder { color: var(--text-muted); }
.search-input-group button {
    background: none;
    border: none;
    padding: 0 10px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
}

/* ========== CATEGORIES ========== */
.category-tabs {
    white-space: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    font-size: 0;
}
.category-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    vertical-align: top;
    width: 140px;
    height: 64px;
    margin-right: 12px;
    font-size: 13px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: #f9fafb;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    text-decoration: none;
    flex-shrink: 0;
    align-content: center;
}
.cat-tab:hover {
    border-color: var(--primary);
}
.cat-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}
.cat-tab.active::after {
    content: "\2713";
    position: absolute;
    right: 8px;
    bottom: 4px;
    font-size: 10px;
    opacity: 0.5;
}
.cat-tab .cat-icon {
    font-size: 16px;
    margin-right: 4px;
    line-height: 1;
}
.cat-tab .cat-name {
    font-size: 13px;
    font-weight: 500;
}
.cat-tab .cat-count {
    font-size: 11px;
    opacity: 0.7;
    width: 100%;
    text-align: center;
    line-height: 1;
}
.cat-tab.active .cat-icon,
.cat-tab.active .cat-name,
.cat-tab.active .cat-count { color: var(--white); }

/* ========== SECTION ========== */
.section-label {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 14px;
    color: var(--text);
}

/* ========== PRODUCT GRID ========== */
.product-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}
.product-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition);
}
.product-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}
.product-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.product-card.disabled:hover { transform: none; box-shadow: none; }
.product-img {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: cover;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: #d1d5db;
}
.product-img img { width: 100%; height: 100%; object-fit: cover; }
.product-body {
    padding: 12px;
}
.product-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 6px;
}
.product-prices {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 6px;
}
.product-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
}
.product-original-price {
    font-size: 12px;
    color: var(--text-muted);
    text-decoration: line-through;
}
.product-stock {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-weight: 500;
}
.product-stock.in-stock {
    background: #e6f4ff;
    color: var(--primary);
}
.product-stock.out-stock {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 48px; display: block; margin-bottom: 12px; }

/* ========== FOOTER ========== */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 20px 0;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--white);
}

/* ========== MODAL (ORDER DIALOG) ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
.modal-dialog {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 520px;
    max-width: calc(100vw - 32px);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    animation: scaleIn 0.15s ease;
    overflow: hidden;
}
.modal-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 52px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.modal-title {
    font-size: 16px;
    font-weight: 600;
}
.modal-close {
    background: none;
    border: none;
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 18px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.modal-close:hover { background: #f3f4f6; color: var(--text); }
.modal-body-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}
.modal-body-scroll::-webkit-scrollbar { width: 4px; }
.modal-body-scroll::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }
.modal-footer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    gap: 12px;
    background: #fafafa;
}
.modal-footer-bar .modal-total {
    font-size: 14px;
    color: var(--text-secondary);
}
.modal-footer-bar .modal-total strong {
    font-size: 18px;
    color: var(--primary);
    font-weight: 700;
}
.modal-footer-bar .btn-group {
    display: flex;
    gap: 8px;
}

/* ========== ORDER FORM ELEMENTS ========== */
.order-product-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.order-product-name {
    font-size: 15px;
    font-weight: 600;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.order-product-qty {
    font-size: 14px;
    color: var(--text-secondary);
    flex-shrink: 0;
    margin-left: 12px;
}
.order-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.8;
    max-height: 140px;
    overflow-y: auto;
    padding: 10px 0;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
    word-break: break-word;
}
.order-desc a { color: var(--primary); }
.order-desc::-webkit-scrollbar { width: 4px; }
.order-desc::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }
.tag-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 500;
    height: 22px;
}
.tag-green { background: var(--success-bg); color: var(--success); }
.tag-blue { background: var(--primary-bg); color: var(--primary); }
.form-group {
    margin-bottom: 14px;
}
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text);
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-input {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: var(--font);
    color: var(--text);
    background: var(--white);
    outline: none;
    transition: border-color var(--transition);
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(22,119,255,0.1); }
.form-input.error { border-color: var(--danger); }
.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}
.form-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
}

/* Quantity stepper */
.qty-stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.qty-stepper button {
    width: 32px; height: 32px;
    border: none;
    background: #f9fafb;
    cursor: pointer;
    font-size: 16px;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.qty-stepper button:hover:not(:disabled) { background: var(--primary-bg); color: var(--primary); }
.qty-stepper button:disabled { color: var(--text-muted); cursor: not-allowed; }
.qty-stepper input {
    width: 48px;
    height: 32px;
    border: none;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    outline: none;
}

/* Price + Qty Row */
.price-qty-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 12px;
}
.price-qty-row .total-price {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

/* Payment methods */
.pay-methods {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.pay-method {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    background: var(--white);
    transition: all var(--transition);
    user-select: none;
}
.pay-method:hover { border-color: var(--primary); }
.pay-method.active {
    border-color: var(--primary);
    background: var(--primary-bg);
    color: var(--primary);
}
.pay-method i { font-size: 18px; }

/* Coupon */
.coupon-row {
    margin-bottom: 14px;
}
.coupon-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-secondary);
}
.coupon-row input[type="checkbox"] { accent-color: var(--primary); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 16px;
    height: 38px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn-primary {
    background: var(--primary);
    color: var(--white);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { background: #91caff; cursor: not-allowed; }
.btn-secondary {
    background: var(--white);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-lg { height: 42px; padding: 0 24px; font-size: 14px; }

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Alerts */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 12px;
}
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #ffa39e; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #b7eb8f; }
.alert-warning { background: var(--warning-bg); color: #d48806; border: 1px solid #ffe58f; }

/* ========== RESPONSIVE ========== */
@media (max-width: 1200px) {
    .product-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 768px) {
    .navbar-links { display: none; }
    .navbar-links.open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 52px;
        left: 0;
        right: 0;
        background: var(--white);
        border-bottom: 1px solid var(--border);
        padding: 8px;
        gap: 2px;
    }
    .navbar-toggle { display: block; }
    .search-input-group { width: 100%; }
    .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .product-body { padding: 8px; }
    .product-title { font-size: 12px; }
    .product-price { font-size: 14px; }
    .cat-tab { width: 120px; height: 56px; min-width: 100px; }
    .category-tabs { gap: 8px; }
    .modal-dialog {
        width: 100%;
        max-width: 100vw;
        max-height: 92vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        margin-top: auto;
    }
    .modal-overlay { align-items: flex-end; }
    .panel-header { flex-direction: column; align-items: stretch; }
}
@media (max-width: 480px) {
    .product-grid { gap: 8px; }
    .product-body { padding: 6px; }
    .panel-header { gap: 8px; }
    .merchant-info { flex-wrap: wrap; }
}

/* ========== ADMIN (uses Bootstrap) ========== */
.admin-sidebar { width: 240px; min-height: 100vh; position: sticky; top: 0; }
.admin-sidebar .nav-link { padding: 10px 16px; border-radius: 8px; margin-bottom: 2px; transition: all 0.15s; }
.admin-sidebar .nav-link:hover { background: rgba(255,255,255,0.12); }
.admin-sidebar .nav-link.active { background: var(--primary); }
#page-content { min-width: 0; background: #f8f9fa; }
.admin-login { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; }
.card { border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-header { background: var(--white); border-bottom: 1px solid var(--border); font-weight: 600; }
.card-info-box { background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; font-family: monospace; font-size: 13px; white-space: pre-wrap; word-break: break-all; max-height: 400px; overflow-y: auto; }
.table th { font-weight: 600; font-size: 13px; }
.btn { font-family: var(--font); }
