/* ============================================================================
   PANDALEX EXPRESS — ENTERPRISE DESIGN SYSTEM & 4-LAYOUT ENGINE v4.5
   Hỗ trợ chuyển đổi tức thì 4 Mẫu Giao Diện Điều Hành:
   1. sidebar-erp     : Sidebar Trái Chuẩn ERP Quốc Tế (Odoo / SAP / MISA)
   2. workspace-tabs  : Bàn Làm Việc Chia Tab 2 Tầng (Không dùng Dropdown)
   3. launchpad-dock  : Bố Cục Lưới App Trung Tâm & Thanh Dock Nổi (macOS/iPadOS)
   4. classic-topbar  : Thanh Ngang Top-Bar Xổ Xuống Cổ Điển
   ============================================================================ */

:root {
  --pdx-primary: #2563eb;
  --pdx-gold: #f59e0b;
  --pdx-emerald: #10b981;
  --pdx-dark: #090d16;
  --pdx-surface: #ffffff;
  --pdx-sidebar-width: 262px;
}

/* 1. Tối ưu độ mượt phông chữ & cuộn trang */
html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: radial-gradient(circle at 15% 0%, #f1f5f9 0%, #e2e8f0 100%) !important;
  letter-spacing: -0.01em;
}

/* 2. Thanh cuộn (Scrollbar) tinh gọn chuẩn macOS/Enterprise */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(241, 245, 249, 0.5);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.65);
  border-radius: 9999px;
  transition: background 0.2s ease;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(71, 85, 105, 0.85);
}

/* 3. Hiệu ứng chuyển đổi Màn hình (Section Transition) siêu mượt 60fps */
@keyframes pdxSectionEnter {
  0% {
    opacity: 0;
    transform: translateY(6px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

main section:not(.hidden),
div.flex-1 > section:not(.hidden) {
  animation: pdxSectionEnter 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* 4. Header & Thanh điều hướng Glassmorphism */
header.bg-slate-950 {
  background: linear-gradient(90deg, #060913 0%, #0f172a 55%, #090d1a 100%) !important;
  backdrop-filter: blur(14px);
  box-shadow: 0 4px 20px -4px rgba(2, 6, 23, 0.45);
}

nav.bg-slate-900 {
  background: rgba(15, 23, 42, 0.96) !important;
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(51, 65, 85, 0.75) !important;
}

.dropdown-nav-group > div[id^="grp"] > div {
  background: rgba(15, 23, 42, 0.98) !important;
  backdrop-filter: blur(20px);
  border: 1px solid rgba(71, 85, 105, 0.65) !important;
  box-shadow: 0 20px 38px -10px rgba(2, 6, 23, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05) !important;
  animation: pdxSectionEnter 0.16s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ============================================================================
   MẪU 1: SIDEBAR TRÁI CHUẨN ERP QUỐC TẾ (sidebar-erp)
   ============================================================================ */
#pdxErpSidebar {
  display: none;
}

@media (min-width: 1024px) {
  body[data-pdx-layout="sidebar-erp"] #pdxErpSidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--pdx-sidebar-width);
    background: linear-gradient(180deg, #080d1a 0%, #0f172a 100%);
    border-right: 1px solid rgba(51, 65, 85, 0.8);
    z-index: 60;
    box-shadow: 8px 0 28px -8px rgba(2, 6, 23, 0.55);
  }

  body[data-pdx-layout="sidebar-erp"] > div.flex-1 {
    margin-left: var(--pdx-sidebar-width);
  }

  /* Ẩn thanh menu ngang xổ xuống cũ khi dùng Mẫu 1 Sidebar ERP */
  body[data-pdx-layout="sidebar-erp"] nav.bg-slate-900 {
    display: none !important;
  }
}

.pdx-erp-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: #cbd5e1;
  text-align: left;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.pdx-erp-nav-item:hover {
  background: rgba(30, 41, 59, 0.85);
  color: #ffffff;
}

.pdx-erp-nav-item.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.28) 0%, rgba(37, 99, 235, 0.08) 100%);
  color: #38bdf8;
  font-weight: 800;
  border-color: rgba(56, 189, 248, 0.35);
  border-left: 3px solid #38bdf8;
}

/* ============================================================================
   MẪU 2: BÀN LÀM VIỆC CHIA TAB 2 TẦNG KHÔNG DROPDOWN (workspace-tabs)
   ============================================================================ */
#pdxWorkspaceTabsBar {
  display: none;
}

body[data-pdx-layout="workspace-tabs"] nav.bg-slate-900 {
  display: none !important;
}

body[data-pdx-layout="workspace-tabs"] #pdxWorkspaceTabsBar {
  display: block;
}

.pdx-ws-dept-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 15px;
  border-radius: 11px 11px 0 0;
  font-size: 12px;
  font-weight: 800;
  color: #94a3b8;
  border-bottom: 3px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.pdx-ws-dept-btn:hover {
  color: #f8fafc;
  background: rgba(30, 41, 59, 0.6);
}

.pdx-ws-dept-btn.active {
  color: #fbbf24;
  background: rgba(30, 41, 59, 0.95);
  border-bottom-color: #f59e0b;
}

.pdx-ws-sub-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 9px;
  font-size: 11.5px;
  font-weight: 700;
  color: #334155;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.pdx-ws-sub-btn:hover {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.pdx-ws-sub-btn.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #1d4ed8;
  box-shadow: 0 4px 12px -2px rgba(37, 99, 235, 0.35);
}

/* ============================================================================
   MẪU 3: LƯỚI APP LAUNCHPAD & THANH DOCK NỔI (launchpad-dock)
   ============================================================================ */
#pdxFloatingDock,
#pdxLaunchpadTopStrip {
  display: none;
}

body[data-pdx-layout="launchpad-dock"] nav.bg-slate-900 {
  display: none !important;
}

body[data-pdx-layout="launchpad-dock"] #pdxFloatingDock {
  display: flex;
}

body[data-pdx-layout="launchpad-dock"] #pdxLaunchpadTopStrip {
  display: flex;
}

body[data-pdx-layout="launchpad-dock"] {
  padding-bottom: 76px;
}

/* 5. Nâng cấp Thẻ KPI & Khối nội dung (Cards) */
.bg-white.rounded-2xl.border {
  border-color: rgba(226, 232, 240, 0.9) !important;
  box-shadow: 0 2px 10px -2px rgba(15, 23, 42, 0.04), 0 1px 3px 0 rgba(15, 23, 42, 0.02) !important;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, border-color 0.2s ease;
}

#secDashboard .grid > .bg-white.rounded-2xl:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px -6px rgba(15, 23, 42, 0.08), 0 4px 8px -2px rgba(15, 23, 42, 0.04) !important;
  border-color: rgba(148, 163, 184, 0.45) !important;
}

/* 6. Bảng dữ liệu (Enterprise Data Tables) */
table thead th {
  letter-spacing: 0.04em;
  white-space: nowrap;
}

table tbody tr {
  transition: background-color 0.12s ease;
}

table tbody tr:hover {
  background-color: rgba(241, 245, 249, 0.75) !important;
}

/* 7. Nút bấm & Input tương tác (Micro-interactions) */
button, a[class*="rounded-"] {
  transition: all 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

button:active:not(:disabled) {
  transform: scale(0.97);
}

input:focus, select:focus, textarea:focus {
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18) !important;
  border-color: #3b82f6 !important;
}

/* 8. Command Palette (Ctrl + K) & System Monitor Overlay */
.pdx-modal-backdrop {
  background: rgba(2, 6, 23, 0.65);
  backdrop-filter: blur(6px);
  animation: pdxFadeBackdrop 0.15s ease forwards;
}

@keyframes pdxFadeBackdrop {
  from { opacity: 0; }
  to { opacity: 1; }
}

.pdx-cmd-item {
  transition: all 0.12s ease;
}
.pdx-cmd-item:hover,
.pdx-cmd-item.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.12) 0%, rgba(37, 99, 235, 0.04) 100%);
  border-color: rgba(59, 130, 246, 0.35);
}

/* Toast Notification hiện đại góc phải */
#pdxToastContainer {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.pdx-toast {
  pointer-events: auto;
  min-width: 300px;
  max-width: 440px;
  background: #0f172a;
  color: #f8fafc;
  border-left: 4px solid #10b981;
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: 0 18px 32px -8px rgba(2, 6, 23, 0.55);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: pdxSectionEnter 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
