/* ======================================
   优选商城 - 后台管理样式（响应式完整版）
   ====================================== */

:root {
    --primary: #e74c3c;
    --primary-dark: #c0392b;
    --primary-light: #fdecea;
    --sidebar-w: 220px;
    --text: #333;
    --text-light: #666;
    --bg: #f5f6fa;
    --white: #fff;
    --border: #e8e8e8;
    --radius: 8px;
    --shadow: 0 2px 12px rgba(0,0,0,.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ===== Login ===== */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 40px; width: 380px; max-width: 90vw; text-align: center; }
.login-card h1 { font-size: 22px; margin-bottom: 8px; color: var(--primary); }
.login-card p { color: var(--text-light); font-size: 14px; margin-bottom: 24px; }
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; text-align: left; }
.form-group label { font-size: 13px; color: var(--text-light); }
.form-group input, .form-group select, .form-group textarea { padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; outline: none; transition: border-color .2s; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); }
.form-group textarea { resize: vertical; min-height: 60px; }
.btn { padding: 10px 24px; border-radius: 6px; font-size: 14px; cursor: pointer; border: none; font-weight: 600; transition: all .2s; }
.btn-primary { background: var(--primary); color: #fff; width: 100%; padding: 12px; font-size: 16px; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-sm { padding: 8px 16px; font-size: 13px; min-height: 36px; }
.btn-outline { background: var(--white); color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-success { background: #27ae60; color: #fff; }
.btn-warning { background: #f39c12; color: #fff; }

/* ===== Layout ===== */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: #1e1e2d; color: #fff; position: fixed; top: 0; left: 0; bottom: 0; overflow-y: auto; z-index: 10; transition: transform .3s, width .3s; }
.sidebar-logo { padding: 20px; font-size: 18px; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; gap: 8px; }
.sidebar-nav { padding: 12px 0; }
.sidebar-nav a { display: flex; align-items: center; gap: 10px; padding: 12px 20px; color: rgba(255,255,255,.6); text-decoration: none; font-size: 14px; transition: all .2s; cursor: pointer; white-space: nowrap; }
.sidebar-nav a:hover, .sidebar-nav a.active { color: #fff; background: rgba(255,255,255,.08); }
.sidebar-nav a .icon { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }
.main { margin-left: var(--sidebar-w); flex: 1; padding: 24px; transition: margin-left .3s; }
.main-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.main-header h2 { font-size: 20px; }
.user-info { display: flex; align-items: center; gap: 12px; font-size: 14px; }

/* ===== 汉堡菜单按钮（手机端显示）===== */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1001;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
    transition: background .2s;
}
.sidebar-toggle:hover { background: var(--primary-dark); }

/* ===== Card ===== */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.card-title { font-size: 16px; font-weight: 600; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
th { background: #fafafa; font-weight: 600; color: var(--text-light); position: sticky; top: 0; }
tr:hover td { background: #fafafa; }
.status-tag { padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-pending { background: #fff3cd; color: #856404; }
.status-paid { background: #d4edda; color: #155724; }
.status-shipped { background: #cce5ff; color: #004085; }
.status-completed { background: #d4edda; color: #155724; }
.status-cancelled { background: #f8d7da; color: #721c24; }

/* ===== Modal ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal { background: var(--white); border-radius: var(--radius); box-shadow: 0 8px 40px rgba(0,0,0,.15); width: 600px; max-width: 90vw; max-height: 80vh; overflow-y: auto; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* ===== Stats ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; display: flex; align-items: center; gap: 16px; }
.stat-icon { font-size: 36px; flex-shrink: 0; }
.stat-val { font-size: 28px; font-weight: 700; }
.stat-label { font-size: 13px; color: var(--text-light); }

/* ===== Tags / Image Upload / Toast / Pagination ===== */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-item { padding: 4px 12px; background: #f0f0f0; border-radius: 4px; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.img-preview { width: 120px; height: 120px; border-radius: 6px; border: 2px dashed var(--border); display: flex; align-items: center; justify-content: center; cursor: pointer; overflow: hidden; margin-bottom: 8px; }
.img-preview img { max-width: 100%; max-height: 100%; object-fit: cover; }
.img-preview .placeholder { color: var(--text-light); font-size: 13px; }
.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); padding: 12px 28px; border-radius: 6px; color: #fff; font-size: 14px; z-index: 999; opacity: 0; transition: opacity .3s; pointer-events: none; }
.toast.show { opacity: 1; }
.toast-success { background: #27ae60; }
.toast-error { background: #e74c3c; }
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.pagination button { padding: 6px 14px; border: 1px solid var(--border); border-radius: 4px; background: var(--white); cursor: pointer; font-size: 13px; transition: all .15s; }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ========================================================
   响应式断点
   ======================================================== */

/* ===== 平板端（769px ~ 1024px）===== */
@media (max-width: 1024px) {
    :root { --sidebar-w: 200px; }
    .sidebar-logo { padding: 16px 12px; font-size: 16px; }
    .sidebar-nav a { padding: 10px 14px; font-size: 13px; }
    .main { padding: 20px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .modal { width: 88vw; }
}

/* ===== 手机端（<= 768px）===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 260px;
        z-index: 1000;
        box-shadow: 4px 0 24px rgba(0,0,0,.35);
    }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; padding: 16px 12px; }
    .sidebar-toggle { display: flex !important; }
    .main-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .main-header h2 { font-size: 18px; }
    .stats-grid { grid-template-columns: 1fr; }
    .modal { width: 96vw; max-height: 85vh; }
    table { font-size: 12px; }
    th, td { padding: 8px 6px; }
    .btn, .btn-sm { min-height: 38px; font-size: 14px; }
    .card { padding: 14px; }
    .card-header { flex-direction: column; align-items: flex-start; }
    .pagination { gap: 4px; }
    .pagination button { padding: 6px 10px; font-size: 12px; }
    /* Overlay 点击关闭侧边栏 */
    .sidebar-overlay {
        display: none;
        position: fixed; inset: 0;
        background: rgba(0,0,0,.4);
        z-index: 999;
    }
    .sidebar-overlay.show { display: block; }
}

/* ===== 小屏手机（<= 480px）===== */
@media (max-width: 480px) {
    .main { padding: 10px 8px; }
    .card { padding: 12px; }
    .modal { width: 99vw; max-height: 92vh; border-radius: 8px; }
    .modal-body { padding: 12px; }
    .modal-footer { padding: 12px; flex-direction: column; }
    .modal-footer .btn { width: 100%; }
    .login-card { padding: 24px 16px; }
    .sidebar { width: 85vw; max-width: 300px; }
    .sidebar-logo { font-size: 15px; padding: 14px 12px; }
    .sidebar-nav a { padding: 10px 12px; font-size: 13px; }
    .stats-grid { gap: 10px; }
    .stat-card { padding: 14px; gap: 12px; }
    .stat-icon { font-size: 28px; }
    .stat-val { font-size: 22px; }
}

/* ===== 客服消息面板（保持原有功能）===== */
.chat-sessions-panel { min-width: 220px; }
.chat-session-item {
    padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .15s;
}
.chat-session-item:hover { background: #f8f9fa; }
.chat-session-item.active { background: var(--primary-light); border-left: 3px solid var(--primary); }
.chat-session-item.closed { opacity: .5; }
.chat-session-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.chat-session-id { font-size: 13px; font-weight: 600; }
.chat-session-preview { font-size: 12px; color: var(--text-light); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-session-time { font-size: 11px; color: #aaa; margin-top: 2px; }
.chat-badge { background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 10px; }
.chat-msg-row { margin-bottom: 12px; }
.chat-msg-row.chat-admin { text-align: right; }
.chat-msg-row.chat-customer { text-align: left; }
.chat-msg-bubble {
    display: inline-block; max-width: 75%; padding: 10px 14px; border-radius: 16px;
    font-size: 14px; line-height: 1.5; word-break: break-word; text-align: left;
}
.chat-admin .chat-msg-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-customer .chat-msg-bubble { background: #f0f2f5; color: var(--text); border-bottom-left-radius: 4px; }
.chat-msg-time { font-size: 11px; color: #aaa; margin-top: 3px; padding: 0 4px; }
