/* ==========================================
   THƯƠNG CHÂU - ADMIN PANEL
   Shared Stylesheet v5.0
   ========================================== */

:root {
    --sidebar-width: 252px;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active-bg: rgba(231,76,60,.16);
    --sidebar-active-border: #e74c3c;
    --sidebar-active-color: #f8b4ab;
    --sidebar-text: #94a3b8;
    --sidebar-heading: #475569;
    --sidebar-border: rgba(255,255,255,.06);

    --topbar-height: 60px;
    --topbar-bg: #ffffff;
    --topbar-border: #e2e8f0;

    --accent: #e74c3c;
    --accent-hover: #c0392b;
    --accent-light: rgba(231,76,60,.1);

    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --bg-table-head: #f8fafc;
    --bg-row-hover: rgba(231,76,60,.03);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --success: #10b981;
    --success-bg: rgba(16,185,129,.08);
    --warning: #f59e0b;
    --warning-bg: rgba(245,158,11,.08);
    --danger: #ef4444;
    --danger-bg: rgba(239,68,68,.08);
    --info: #3b82f6;
    --info-bg: rgba(59,130,246,.08);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06),0 1px 2px rgba(0,0,0,.04);
    --shadow: 0 4px 6px -1px rgba(0,0,0,.07),0 2px 4px -1px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08),0 4px 6px -2px rgba(0,0,0,.04);
    --transition: .15s ease;
}

*,*::before,*::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

/* ===== SIDEBAR ===== */
.admin-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    overflow-y: auto;
    scrollbar-width: none;
    border-right: 1px solid var(--sidebar-border);
    transition: transform var(--transition), width var(--transition);
}
.admin-sidebar::-webkit-scrollbar { display: none; }

/* ===== SIDEBAR COLLAPSE (icon rail) — dùng chung cho Admin + mọi portal nhân viên
   (mọi portal share cùng class .admin-sidebar/.admin-main nên chỉ cần 1 khối CSS này) ===== */
.sidebar-collapse-toggle {
    position: absolute;
    top: 22px; right: -12px;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--sidebar-active-border);
    color: #fff;
    border: 2px solid var(--sidebar-bg);
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1041;
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.sidebar-collapse-toggle:hover { filter: brightness(1.12); }
.sidebar-collapse-toggle i { display: inline-block; transition: transform .25s cubic-bezier(.4,0,.2,1); }
html.admin-sidebar-collapsed .sidebar-collapse-toggle i { transform: rotate(180deg); }

@media (min-width: 769px) {
    html.admin-sidebar-collapsed .admin-sidebar { width: 76px; }
    html.admin-sidebar-collapsed .admin-main { margin-left: 76px; }

    html.admin-sidebar-collapsed .brand-text,
    html.admin-sidebar-collapsed .nav-section,
    html.admin-sidebar-collapsed .nav-subsection,
    html.admin-sidebar-collapsed .nav-section-toggle span,
    html.admin-sidebar-collapsed .nav-section-toggle .nav-chevron,
    html.admin-sidebar-collapsed .sidebar-link span,
    html.admin-sidebar-collapsed .sidebar-footer,
    html.admin-sidebar-collapsed .admin-lang-bar,
    html.admin-sidebar-collapsed #adminNotifBar span,
    html.admin-sidebar-collapsed #adminNotifBar select,
    html.admin-sidebar-collapsed #snhubMuteBtn { display: none; }

    html.admin-sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0 8px; gap: 0; }
    html.admin-sidebar-collapsed .sidebar-link,
    html.admin-sidebar-collapsed .nav-section-toggle { justify-content: center; padding: 10px 0; gap: 0; }
    html.admin-sidebar-collapsed #adminNotifBar,
    html.admin-sidebar-collapsed #snhubBellBtn { justify-content: center; gap: 0; }

    /* Thu gọn thì accordion không còn ý nghĩa nhóm — hiện phẳng toàn bộ icon như 1 dải công cụ,
       bất kể mục đó đang "đóng" hay "mở" ở chế độ bình thường. */
    html.admin-sidebar-collapsed .collapse { display: block !important; height: auto !important; }

    /* Layout thay thế ".sidebar/.main-content" (COMPAT bên dưới, dùng bởi purchasing-staff) —
       cùng cơ chế thu gọn, đặt tên biến khác ".sidebar.collapsed" (vốn đã có nghĩa riêng: ẩn hẳn
       trên mobile) nên không xung đột. */
    html.admin-sidebar-collapsed .sidebar:not(.admin-sidebar) { width: 76px; }
    html.admin-sidebar-collapsed .main-content:not(.admin-main) { margin-left: 76px; }
    html.admin-sidebar-collapsed .sidebar-header .sidebar-brand,
    html.admin-sidebar-collapsed .sidebar .nav-item span { display: none; }
    html.admin-sidebar-collapsed .sidebar-header { justify-content: center; padding: 0 8px; }
    html.admin-sidebar-collapsed .sidebar .nav-item { justify-content: center; padding: 8px 0; gap: 0; margin-right: 0; border-radius: 6px; }
}

.sidebar-brand {
    padding: 0 18px;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 14.5px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}
.sidebar-brand:hover { color: #fff; }

.brand-icon {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--accent), #ff7043);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(231,76,60,.4);
}

.brand-text .brand-name { display: block; font-size: 13.5px; font-weight: 700; color: #f1f5f9; letter-spacing: -.2px; }
.brand-text .brand-ver  { display: block; font-size: 10px; color: var(--sidebar-heading); font-weight: 400; }

.sidebar-nav { flex: 1; padding: 8px 0 14px; }

.nav-section {
    padding: 14px 14px 4px;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--sidebar-heading);
}
.nav-section:first-child { padding-top: 8px; }

/* Nhóm phụ bên trong 1 nav-section (VD: liệt kê menu con của khu vực khác trong khối "Chuyển khu
   vực (toàn quyền)") — thụt lề nhẹ + nhỏ hơn nav-section để phân biệt cấp bậc, không tách hẳn
   thành nav-section riêng (sẽ lặp lại tiêu đề "Chuyển khu vực" nhiều lần trông rối). */
.nav-subsection {
    padding: 10px 14px 3px 22px;
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: var(--sidebar-heading);
    opacity: .75;
}

/* Collapsible nav groups */
.nav-section-toggle {
    width: 100%;
    background: transparent;
    border: none;
    padding: 14px 14px 4px;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--sidebar-heading);
    display: flex;
    align-items: center;
    cursor: pointer;
    text-align: left;
    line-height: 1.6;
    transition: color .15s;
}
.nav-section-toggle:hover { color: #64748b; }
.nav-section-toggle:first-child { padding-top: 8px; }
.nav-section-toggle .nav-chevron {
    margin-left: auto;
    font-size: 8px;
    opacity: .5;
    transition: transform .2s ease;
}
.nav-section-toggle[aria-expanded="false"] .nav-chevron { transform: rotate(-90deg); }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background var(--transition), color var(--transition);
    margin: 1px 0;
}
.sidebar-link:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.sidebar-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-color);
    border-left-color: var(--sidebar-active-border);
}
.sidebar-link .nav-icon { width: 20px; text-align: center; font-size: 14px; flex-shrink: 0; opacity: .85; }
.sidebar-link.active .nav-icon { opacity: 1; }

.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--sidebar-border);
    font-size: 11px;
    color: var(--sidebar-heading);
    line-height: 1.8;
}

/* ===== MAIN LAYOUT ===== */
.admin-main {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== TOPBAR ===== */
.admin-topbar {
    position: sticky;
    top: 0; z-index: 1030;
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}
.topbar-title { font-weight: 600; font-size: 15.5px; color: var(--text-primary); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.admin-badge {
    display: inline-flex; align-items: center; gap: 5px;
    background: var(--accent-light); color: var(--accent);
    font-size: 11px; font-weight: 700;
    padding: 4px 10px; border-radius: 20px; letter-spacing: .3px;
}
.topbar-logout {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--text-secondary); text-decoration: none;
    font-size: 13px; font-weight: 500;
    padding: 6px 12px; border-radius: var(--radius-sm);
    border: none; background: transparent; cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.topbar-logout:hover { background: var(--danger-bg); color: var(--danger); }
.hamburger-btn {
    display: none; border: none; background: transparent;
    color: var(--text-secondary); font-size: 20px;
    cursor: pointer; padding: 4px 6px; border-radius: var(--radius-sm);
}

/* ===== PAGE BODY ===== */
.admin-page-body { flex: 1; padding: 24px; }
.admin-content   { flex: 1; padding: 24px; }

/* ===== STAT CARDS ===== */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
    position: relative; overflow: hidden;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.stat-card.blue::before  { background: linear-gradient(90deg, var(--accent), #ff7043); }
.stat-card.green::before { background: linear-gradient(90deg, var(--success), #34d399); }
.stat-card.amber::before { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.stat-card.cyan::before  { background: linear-gradient(90deg, var(--info), #60a5fa); }
.stat-card.red::before   { background: linear-gradient(90deg, var(--danger), #f87171); }

.stat-icon-wrap {
    width: 44px; height: 44px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; margin-bottom: 14px;
}
.stat-icon-wrap.blue  { background: var(--accent-light); color: var(--accent); }
.stat-icon-wrap.green { background: var(--success-bg);   color: var(--success); }
.stat-icon-wrap.amber { background: var(--warning-bg);   color: var(--warning); }
.stat-icon-wrap.cyan  { background: var(--info-bg);      color: var(--info); }
.stat-icon-wrap.red   { background: var(--danger-bg);    color: var(--danger); }

.stat-value { font-size: 26px; font-weight: 800; color: var(--text-primary); line-height: 1; letter-spacing: -.5px; }
.stat-label { font-size: 12.5px; color: var(--text-muted); margin-top: 5px; font-weight: 500; }
.stat-sub   { font-size: 12px; margin-top: 8px; color: var(--text-muted); }

/* ===== STAT CHIPS ===== */
.stat-chips { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.stat-chip {
    background: var(--bg-card); border-radius: var(--radius);
    border: 1px solid var(--border); padding: 12px 16px;
    display: flex; align-items: center; gap: 10px;
    box-shadow: var(--shadow-sm); flex: 1; min-width: 150px;
}
.chip-icon { font-size: 18px; }
.chip-value { font-weight: 800; font-size: 20px; line-height: 1; }
.chip-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ===== FILTER BAR ===== */
.filter-bar {
    background: var(--bg-card); border-radius: var(--radius);
    border: 1px solid var(--border); padding: 16px 20px;
    margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.filter-bar .form-label {
    font-size: 11.5px; font-weight: 700; color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: .4px; margin-bottom: 5px;
}

/* ===== TABLE CARD ===== */
.admin-table-card {
    background: var(--bg-card); border-radius: var(--radius-lg);
    border: 1px solid var(--border); overflow: hidden; box-shadow: var(--shadow-sm);
}
.card-header-custom {
    padding: 15px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 8px;
}
.card-header-custom h6 {
    margin: 0; font-weight: 700; font-size: 14px;
    color: var(--text-primary); display: flex; align-items: center; gap: 8px;
}
.header-count {
    font-size: 11.5px; font-weight: 500; color: var(--text-muted);
    background: var(--bg-page); padding: 2px 8px;
    border-radius: 10px; border: 1px solid var(--border);
}

/* ===== TABLE ===== */
.table { margin-bottom: 0; }
.table thead th {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .6px; color: var(--text-muted);
    background: var(--bg-table-head); border-bottom: 2px solid var(--border);
    padding: 10px 16px; white-space: nowrap;
}
.table tbody td {
    padding: 11px 16px; vertical-align: middle;
    font-size: 13.5px; border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--bg-row-hover); }
.table-responsive { overflow-x: auto; }

/* ===== BADGES ===== */
.badge-status {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 20px;
}
.badge-status.success  { background: var(--success-bg); color: #059669; }
.badge-status.warning  { background: var(--warning-bg); color: #d97706; }
.badge-status.danger   { background: var(--danger-bg);  color: #dc2626; }
.badge-status.info     { background: var(--info-bg);    color: #2563eb; }
.badge-status.secondary{ background: #f1f5f9;           color: #64748b; }
.badge-status.dark     { background: #1e293b;           color: #94a3b8; }
.badge-status.primary  { background: var(--accent-light); color: var(--accent); }

.badge-role {
    display: inline-block; font-size: 11px; font-weight: 600;
    padding: 2px 8px; border-radius: var(--radius-sm);
    background: #f1f5f9; color: var(--text-secondary);
    border: 1px solid var(--border);
}
.badge-role.ADMIN     { background: rgba(231,76,60,.1); color: var(--accent); border-color: rgba(231,76,60,.2); }
.badge-role.SUB_ADMIN { background: rgba(139,92,246,.1); color: #7c3aed; border-color: rgba(139,92,246,.2); }
.badge-role.SELLER    { background: rgba(16,185,129,.1); color: #059669; border-color: rgba(16,185,129,.2); }
.badge-role.BUYER,
.badge-role.USER      { background: rgba(59,130,246,.1); color: #2563eb; border-color: rgba(59,130,246,.2); }
.badge-role.MODERATOR { background: rgba(245,158,11,.1); color: #d97706; border-color: rgba(245,158,11,.2); }
.badge-role.SUPPORT   { background: rgba(20,184,166,.1); color: #0d9488; border-color: rgba(20,184,166,.2); }
.badge-role.GUEST     { background: #f8fafc; color: var(--text-muted); border-color: var(--border); }

/* v6.0 active roles */
.badge-role.OPS_MANAGER     { background: rgba(139,92,246,.1);  color: #7c3aed; border-color: rgba(139,92,246,.2); }
.badge-role.FINANCE_OFFICER { background: rgba(16,185,129,.1);  color: #059669; border-color: rgba(16,185,129,.2); }
.badge-role.SALES_AGENT     { background: rgba(59,130,246,.1);  color: #2563eb; border-color: rgba(59,130,246,.2); }
.badge-role.ORDER_PROCESSOR { background: rgba(249,115,22,.1);  color: #ea580c; border-color: rgba(249,115,22,.2); }
.badge-role.WAREHOUSE_STAFF { background: rgba(180,83,9,.1);    color: #b45309; border-color: rgba(180,83,9,.2); }
.badge-role.CONTENT_EDITOR  { background: rgba(236,72,153,.1);  color: #db2777; border-color: rgba(236,72,153,.2); }
.badge-role.SUPPORT_AGENT   { background: rgba(20,184,166,.1);  color: #0d9488; border-color: rgba(20,184,166,.2); }
.badge-role.PARTNER         { background: rgba(6,182,212,.1);   color: #0891b2; border-color: rgba(6,182,212,.2); }
.badge-role.MERCHANT        { background: rgba(16,185,129,.1);  color: #047857; border-color: rgba(16,185,129,.2); }
.badge-role.CUSTOMER        { background: rgba(59,130,246,.08); color: #3b82f6; border-color: rgba(59,130,246,.15); }

/* ===== USER AVATAR ===== */
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #ff7043);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; color: #fff; flex-shrink: 0; overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-name { font-weight: 600; font-size: 13.5px; }
.user-handle { font-size: 11.5px; color: var(--text-muted); }

/* ===== ACTION BUTTONS ===== */
.action-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.btn-action {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11.5px; font-weight: 600; padding: 4px 9px;
    border-radius: var(--radius-sm); border: 1px solid transparent;
    cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: all var(--transition);
}
.btn-action.danger    { color: #dc2626;     border-color: rgba(239,68,68,.3);     background: var(--danger-bg); }
.btn-action.success   { color: #059669;     border-color: rgba(16,185,129,.3);    background: var(--success-bg); }
.btn-action.primary   { color: var(--accent); border-color: rgba(231,76,60,.3);  background: var(--accent-light); }
.btn-action.secondary { color: var(--text-secondary); border-color: var(--border); background: #f8fafc; }
.btn-action.warning   { color: #d97706;     border-color: rgba(245,158,11,.3);    background: var(--warning-bg); }
.btn-action.info      { color: #2563eb;     border-color: rgba(59,130,246,.3);    background: var(--info-bg); }

.btn-action.danger:hover    { background: var(--danger);  color: #fff; border-color: var(--danger); }
.btn-action.success:hover   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-action.primary:hover   { background: var(--accent);  color: #fff; border-color: var(--accent); }
.btn-action.secondary:hover { background: #e2e8f0; color: var(--text-primary); }
.btn-action.warning:hover   { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-action.info:hover      { background: var(--info);    color: #fff; border-color: var(--info); }
.btn-action:disabled { opacity: .55; cursor: not-allowed; }

/* ===== PAGINATION BAR ===== */
.pagination-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 11px 20px; border-top: 1px solid var(--border-light);
    background: var(--bg-table-head); flex-wrap: wrap; gap: 8px;
}
.pagination-info { font-size: 12.5px; color: var(--text-muted); }

/* ===== FORM LABELS ===== */
.edit-label {
    display: block;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 5px;
}

/* ===== SETTINGS ===== */
.settings-card {
    background: var(--bg-card); border-radius: var(--radius-lg);
    border: 1px solid var(--border); overflow: hidden;
    margin-bottom: 20px; box-shadow: var(--shadow-sm);
}
.settings-body { padding: 20px; }

.rate-row {
    display: flex; align-items: center; gap: 14px;
    padding: 13px 0; border-bottom: 1px solid var(--border-light); flex-wrap: wrap;
}
.rate-row:last-child { border-bottom: none; }
.rate-pair { font-weight: 700; font-size: 14px; min-width: 90px; color: var(--text-secondary); }
.rate-value { font-size: 22px; font-weight: 800; color: var(--accent); letter-spacing: -.5px; flex: 1; }
.rate-meta { font-size: 12px; color: var(--text-muted); }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.info-item { background: var(--bg-table-head); border-radius: var(--radius); padding: 14px; border: 1px solid var(--border-light); }
.info-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); margin-bottom: 4px; }
.info-value { font-size: 14px; font-weight: 700; color: var(--text-primary); }

/* ===== TOAST ===== */
#toastContainer {
    position: fixed; top: 20px; right: 20px;
    z-index: 9999; display: flex; flex-direction: column; gap: 10px;
    pointer-events: none;
}
.admin-toast {
    background: #fff; border-radius: 14px;
    padding: 14px 16px 16px; box-shadow: 0 8px 32px rgba(0,0,0,.13);
    display: flex; align-items: flex-start; gap: 12px;
    min-width: 300px; max-width: 400px; position: relative; overflow: hidden;
    pointer-events: all; border-left: 4px solid #d1d5db;
    opacity: 0; transform: translateX(110%) scale(.96);
    transition: opacity .3s ease, transform .35s cubic-bezier(.22,1,.36,1);
}
.admin-toast.show { opacity: 1; transform: translateX(0) scale(1); }
.admin-toast.hide { opacity: 0; transform: translateX(110%) scale(.96); }
.admin-toast.success { border-left-color: #10b981; }
.admin-toast.danger  { border-left-color: #ef4444; }
.admin-toast.warning { border-left-color: #f59e0b; }
.admin-toast.info    { border-left-color: #3b82f6; }
.toast-icon {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; flex-shrink: 0;
}
.admin-toast.success .toast-icon { background: #d1fae5; color: #059669; }
.admin-toast.danger  .toast-icon { background: #fee2e2; color: #dc2626; }
.admin-toast.warning .toast-icon { background: #fef3c7; color: #d97706; }
.admin-toast.info    .toast-icon { background: #dbeafe; color: #2563eb; }
.toast-body { flex: 1; min-width: 0; padding-top: 1px; }
.toast-title { font-size: 13.5px; font-weight: 700; color: #111827; margin-bottom: 3px; }
.toast-message { font-size: 12.5px; color: #6b7280; line-height: 1.45; }
.toast-close {
    border: none; background: none; cursor: pointer;
    color: #9ca3af; font-size: 20px; line-height: 1;
    padding: 0 0 0 4px; flex-shrink: 0; margin-top: -1px;
    transition: color .15s;
}
.toast-close:hover { color: #374151; }
.toast-progress {
    position: absolute; bottom: 0; left: 0; height: 3px; width: 100%;
    transform-origin: left;
    animation: adm-toast-shrink linear forwards;
}
.admin-toast.success .toast-progress { background: #10b981; }
.admin-toast.danger  .toast-progress { background: #ef4444; }
.admin-toast.warning .toast-progress { background: #f59e0b; }
.admin-toast.info    .toast-progress { background: #3b82f6; }
@keyframes adm-toast-shrink {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* ===== ADMIN CONFIRM DIALOG ===== */
.adm-confirm-overlay {
    position: fixed; inset: 0; z-index: 10500;
    background: rgba(0,0,0,.45); backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    opacity: 0; transition: opacity .2s ease;
}
.adm-confirm-overlay.adm-confirm-show { opacity: 1; }
.adm-confirm-box {
    background: #fff; border-radius: 18px; padding: 32px 28px 24px;
    max-width: 420px; width: 100%; text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,.18);
    transform: scale(.92) translateY(12px);
    transition: transform .3s cubic-bezier(.22,1,.36,1);
}
.adm-confirm-overlay.adm-confirm-show .adm-confirm-box { transform: scale(1) translateY(0); }
.adm-confirm-icon {
    width: 64px; height: 64px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; margin: 0 auto 16px;
}
.adm-confirm-icon.danger  { background: #fee2e2; color: #dc2626; }
.adm-confirm-icon.warning { background: #fef3c7; color: #d97706; }
.adm-confirm-icon.info    { background: #dbeafe; color: #2563eb; }
.adm-confirm-icon.success { background: #d1fae5; color: #059669; }
.adm-confirm-title {
    font-size: 17px; font-weight: 700; color: #111827; margin-bottom: 8px;
}
.adm-confirm-msg {
    font-size: 14px; color: #6b7280; line-height: 1.55; margin-bottom: 24px;
}
/* Dùng bởi AdminCore.promptDialog() — ô nhập lý do/ghi chú trong hộp thoại, thay cho prompt() gốc */
.adm-confirm-box:has(.adm-confirm-input-wrap) .adm-confirm-msg { margin-bottom: 14px; }
.adm-confirm-input-wrap { text-align: left; margin-bottom: 22px; }
.adm-confirm-input {
    width: 100%; border: 1.5px solid #e5e7eb; border-radius: 10px;
    padding: 10px 12px; font-size: 14px; color: #111827;
    transition: border-color .15s, box-shadow .15s; resize: vertical;
}
.adm-confirm-input:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.adm-confirm-input.is-invalid { border-color: #dc2626; }
.adm-confirm-input.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220,38,38,.12); }
.adm-confirm-input-error { color: #dc2626; font-size: 12px; margin-top: 6px; display: none; }
.adm-confirm-input-error.show { display: block; }
.adm-confirm-actions {
    display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
}
.adm-confirm-actions .btn { min-width: 110px; }
@media (max-width: 480px) {
    .adm-confirm-actions { flex-direction: column-reverse; }
    .adm-confirm-actions .btn { width: 100%; }
}

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 48px 24px; }
.empty-state-icon { font-size: 38px; color: var(--text-muted); margin-bottom: 12px; opacity: .4; }
.empty-state-title { font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; font-size: 15px; }
.empty-state-sub { font-size: 13px; color: var(--text-muted); }

/* ===== ADMIN LANGUAGE SELECTOR ===== */
.admin-lang-bar {
    padding: 8px 14px;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    justify-content: flex-end;
    background: var(--sidebar-bg);
}
.admin-lang-sel {
    padding: 4px 8px;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 6px;
    font-size: .75rem;
    background: rgba(255,255,255,.08);
    color: var(--sidebar-text);
    cursor: pointer;
    outline: none;
    transition: border-color .15s, background .15s;
}
.admin-lang-sel:hover,
.admin-lang-sel:focus {
    border-color: var(--accent);
    background: rgba(231,76,60,.18);
    color: #e2e8f0;
}
.admin-lang-sel option {
    background: #1e293b;
    color: #e2e8f0;
}

/* ===== TOPBAR LANGUAGE SELECTOR (inline variant) ===== */
.topbar-lang-sel {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .78rem;
    background: var(--bg-page);
    color: var(--text-secondary);
    cursor: pointer;
    outline: none;
    transition: border-color .15s;
}
.topbar-lang-sel:hover,
.topbar-lang-sel:focus { border-color: var(--accent); color: var(--accent); }

/* ===== OVERLAY & MOBILE ===== */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.45); z-index: 1039;
}
.sidebar-overlay.open,
.sidebar-overlay.active { display: block; }

/* ===== SIDEBAR TOGGLE BUTTON (ops-manager / sales-agent portals) ===== */
.sidebar-toggle {
    display: none; border: none; background: transparent;
    color: var(--text-secondary); font-size: 20px;
    cursor: pointer; padding: 4px 6px; border-radius: var(--radius-sm);
    align-items: center; justify-content: center;
    transition: background var(--transition);
}
.sidebar-toggle:hover { background: var(--bg-page); }

/* ===== BOTTOM NAV — mobile only ===== */
.admin-bottom-nav {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    z-index: 1035; /* dưới overlay (1039) + sidebar (1040) để bị che khi drawer mở */
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 16px rgba(0,0,0,.06);
}
.abn-item {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    padding: 6px 2px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 10.5px;
    font-weight: 600;
    border: none; background: transparent; cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color .15s;
}
.abn-item i { font-size: 18px; }
.abn-item.active,
.abn-item:hover { color: var(--accent); }
.abn-icon-wrap { position: relative; display: inline-flex; }
.abn-badge {
    position: absolute; top: -4px; right: -8px;
    background: var(--danger); color: #fff;
    font-size: 9px; font-weight: 800;
    min-width: 15px; height: 15px; border-radius: 8px;
    align-items: center; justify-content: center;
    padding: 0 3px;
}

/* ===== RESPONSIVE — TABLET (max 1024px) ===== */
@media (max-width: 1024px) {
    :root { --sidebar-width: 220px; }
    .admin-page-body, .admin-content { padding: 18px; }
    .stat-chips .stat-chip { min-width: 120px; }
}

/* ===== RESPONSIVE — MOBILE (max 768px) ===== */
@media (max-width: 768px) {
    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform .28s cubic-bezier(.4,0,.2,1);
        box-shadow: 4px 0 28px rgba(0,0,0,.25);
    }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-main { margin-left: 0; }
    .hamburger-btn,
    .sidebar-toggle { display: flex; }
    .admin-page-body, .admin-content { padding: 14px 14px calc(70px + env(safe-area-inset-bottom, 0px)); }
    .admin-bottom-nav { display: flex; }
    .stat-chips { gap: 8px; }
    .stat-chips .stat-chip { min-width: 130px; flex: 1 1 calc(50% - 4px); }
    .admin-topbar { padding: 0 14px; gap: 8px; }
    .topbar-title { font-size: 14px; }
    .admin-badge { display: none; }
    .topbar-logout span.d-none { display: none !important; }
    .admin-table-card { border-radius: var(--radius); }
    .filter-bar { padding: 12px; }
    .card-header-custom { padding: 12px 14px; }
    .table thead th,
    .table tbody td { padding: 8px 10px; font-size: .78rem; }
    .kpi-value { font-size: 1.4rem; }
    .admin-lang-bar { padding: 6px 14px; }
}

/* ===== RESPONSIVE — SMALL MOBILE (max 480px) ===== */
@media (max-width: 480px) {
    .admin-page-body, .admin-content { padding: 10px 10px calc(70px + env(safe-area-inset-bottom, 0px)); }
    .stat-chips .stat-chip { min-width: 100%; flex: 1 1 100%; }
    .row.g-3 > [class*='col-6'] { flex: 0 0 100%; max-width: 100%; }
    /* KPI/rate cards giữ lưới 2 cột ngay cả trên màn hình nhỏ — gọn hơn, đỡ cuộn */
    .row.g-3 > [class*='col-6']:has(.kpi-card),
    .row.g-3 > [class*='col-6']:has(.rate-card) { flex: 0 0 50%; max-width: 50%; }
    .pagination-bar { flex-direction: column; align-items: flex-start; gap: 6px; }
    .action-btns { flex-wrap: wrap; }
    .btn-action { font-size: .7rem; padding: 3px 7px; }
}

/* ===== COMPAT: alternate layout classes used by warehouse portal templates ===== */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed; top: 0; left: 0;
    width: var(--sidebar-width); height: 100vh;
    background: var(--sidebar-bg);
    display: flex; flex-direction: column;
    z-index: 1040; overflow-y: auto; scrollbar-width: none;
    border-right: 1px solid var(--sidebar-border);
    transition: transform var(--transition);
}
.sidebar::-webkit-scrollbar { display: none; }
.sidebar.collapsed { transform: translateX(-100%); }

.sidebar-header {
    padding: 0 18px; height: var(--topbar-height);
    display: flex; align-items: center; gap: 10px;
    color: #fff; border-bottom: 1px solid var(--sidebar-border); flex-shrink: 0;
}
.sidebar-logo { font-size: 20px; }
.sidebar .sidebar-brand { color: #f1f5f9; font-weight: 700; font-size: 14px; }

/* Warehouse portal nav-item (scoped to avoid conflict with Bootstrap .nav-item) */
.sidebar .nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px; color: #94a3b8;
    text-decoration: none; font-size: 13.5px;
    transition: background .12s, color .12s;
    border-radius: 0 6px 6px 0; margin-right: 8px;
}
.sidebar .nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.sidebar .nav-item.active {
    background: linear-gradient(90deg, rgba(231,76,60,.20), rgba(231,76,60,.08));
    color: #f8b4ab; font-weight: 600;
}

.main-content {
    margin-left: var(--sidebar-width); min-height: 100vh;
    display: flex; flex-direction: column; flex: 1;
}

.topbar {
    height: var(--topbar-height); background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; padding: 0 20px; gap: 12px;
    position: sticky; top: 0; z-index: 100;
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
}

/* ===== MOBILE HARDENING (iOS/Android) — 2026-07 ===== */
.table-responsive,
.admin-table-card .table-responsive { -webkit-overflow-scrolling: touch; }

@media (max-width: 768px) {
    /* iOS Safari tự phóng to trang khi focus vào control có font < 16px */
    input:not([type=checkbox]):not([type=radio]),
    select, textarea,
    .form-control, .form-select { font-size: 16px !important; }
    /* Vùng chạm tối thiểu cho nút chính */
    .btn-primary, .btn-success, .btn-danger, .btn-warning,
    button[type=submit] { min-height: 42px; }
    /* Modal Bootstrap sát mép + safe-area */
    .modal-dialog { margin: 8px; }
    .modal-content { border-radius: 16px; }
    .modal-body { max-height: 70vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
}

/* =====================================================================
   GENERIC PANEL PRIMITIVES — dùng chung cho các trang admin không theo
   khung .admin-table-card (consolidation ghép xe, 1688-support, ...).
   Trước đây mỗi template tự khai .section-card trong <style> riêng; gom
   về đây để đồng bộ và để 3 trang consolidation hết "vỡ giao diện".
   ===================================================================== */
.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}
.section-card > h6,
.section-card .section-title {
    margin: 0 0 14px;
    font-size: 13px; font-weight: 800;
    letter-spacing: .3px;
    color: var(--text-primary);
    display: flex; align-items: center; gap: 8px;
}

/* Bảng số liệu gọn dùng trong .section-card */
.section-card .table { font-size: 13px; }
.section-card .table thead th {
    font-size: 10.5px; letter-spacing: .5px;
    background: var(--bg-table-head);
}

/* Nút cực nhỏ trong ô thao tác của bảng (Bootstrap không có .btn-xs) */
.btn-xs {
    --bs-btn-padding-y: .18rem; --bs-btn-padding-x: .5rem;
    --bs-btn-font-size: .74rem; --bs-btn-border-radius: 7px;
    font-weight: 600; line-height: 1.35;
}
.btn-xs + .btn-xs { margin-left: 4px; }

/* Tiện ích đậm nhạt mà template consolidation đang dùng nhưng Bootstrap 5 không có */
.fw-700 { font-weight: 700 !important; }
.fw-600 { font-weight: 600 !important; }

/* Hàng ô lọc phía trên bảng */
.cons-filters { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }
.cons-filters .form-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--text-secondary); margin-bottom: 4px; }
.cons-filters .cons-filter-actions { display: flex; gap: 8px; }

/* Lưới thẻ số liệu tổng quan */
.cons-stat-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 20px; }

/* Bảng cuộn ngang mượt + gợi ý cuộn trên mobile */
.cons-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cons-scroll table { min-width: 720px; }

@media (max-width: 768px) {
    .section-card { padding: 16px 14px; border-radius: var(--radius); }
    .cons-filters { grid-template-columns: 1fr 1fr; }
    .cons-filters .cons-filter-full { grid-column: 1 / -1; }
    .cons-filters .cons-filter-actions { grid-column: 1 / -1; }
    .cons-filters .cons-filter-actions .btn { flex: 1; min-height: 40px; }
    .btn-xs { --bs-btn-font-size: .8rem; --bs-btn-padding-y: .32rem; --bs-btn-padding-x: .6rem; }
    /* Ô thao tác trong bảng: xếp nút theo chiều dọc cho dễ chạm */
    td.cons-actions { white-space: normal; }
    td.cons-actions .btn { margin: 2px 2px 2px 0; }
}
@media (max-width: 480px) {
    .cons-filters { grid-template-columns: 1fr; }
}
