:root {
  --pmu-primary: #1e3a8a;
  --pmu-primary-hover: #172554;
  --pmu-secondary: #0d9488;
  --pmu-bg: #f8fafc;
  --pmu-card-bg: #ffffff;
  --pmu-text: #1e293b;
  --pmu-text-muted: #64748b;
  --pmu-border: #e2e8f0;
  --pmu-sidebar: #0f172a;
}

html, body {
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden; /* Prevent full-window scrollbar */
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--pmu-bg);
  color: var(--pmu-text);
  display: flex;
  flex-direction: column;
}

/* Custom Slim Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  color: white;
  border-bottom: 3px solid #0d9488;
  flex-shrink: 0;
  z-index: 100;
}

/* Main Layout */
main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
}

.tab-content {
  flex: 1;
  min-height: 0;
  height: 100%;
}

.tab-pane {
  height: 100%;
  min-height: 0;
}

.row.app-view-row {
  height: 100%;
  min-height: 0;
}

/* Navigation Tabs */
.nav-pills .nav-link {
  color: #94a3b8;
  font-weight: 500;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}
.nav-pills .nav-link:hover {
  color: #f8fafc;
  background-color: rgba(255, 255, 255, 0.1);
}
.nav-pills .nav-link.active {
  background-color: #0d9488;
  color: white;
}

/* 1. Left Sidebar: Kho Văn Bản (Independent Scroll) */
.doc-sidebar {
  background-color: var(--pmu-card-bg);
  border: 1px solid var(--pmu-border);
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow-y: auto;
  border-radius: 10px;
}

.category-header {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--pmu-text-muted);
  padding: 12px 16px 4px 16px;
}

.doc-item {
  padding: 10px 14px;
  display: block;
  color: var(--pmu-text);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
  font-size: 0.9rem;
}
.doc-item:hover {
  background-color: #f1f5f9;
  color: var(--pmu-primary);
}
.doc-item.active {
  background-color: #eff6ff;
  color: var(--pmu-primary);
  font-weight: 600;
  border-left-color: var(--pmu-primary);
}

/* 2. Middle Content: Trang Xem Văn Bản (Independent Scroll) */
.doc-viewer {
  background-color: var(--pmu-card-bg);
  border-radius: 10px;
  border: 1px solid var(--pmu-border);
  padding: 20px 28px;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow-y: auto;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  scroll-behavior: smooth;
}

#searchResultsContainer {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow-y: auto;
  background-color: var(--pmu-card-bg);
  border-radius: 10px;
  border: 1px solid var(--pmu-border);
  padding: 16px 20px;
}

.legal-content {
  line-height: 1.85;
  font-size: 1.04rem;
  color: #1e293b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: -0.01em;
}
.legal-content h1 {
  font-size: 1.35rem;
  color: var(--pmu-primary);
  margin-top: 1.8rem;
  margin-bottom: 0.8rem;
  font-weight: 700;
  text-align: center;
}
.legal-content h2 {
  font-size: 1.2rem;
  color: #0f172a;
  margin-top: 1.6rem;
  margin-bottom: 0.7rem;
  font-weight: 700;
}
.legal-content h3 {
  font-size: 1.12rem;
  color: #0f172a;
  margin-top: 1.5rem;
  margin-bottom: 0.6rem;
  font-weight: 700;
}
.legal-content h4 {
  font-size: 1.06rem;
  color: #0f172a;
  margin-top: 1.4rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
}
.legal-content p {
  margin-bottom: 0.75rem;
  text-align: justify;
}
.legal-content ul, .legal-content ol {
  padding-left: 1.4rem;
  margin-bottom: 0.75rem;
}
.legal-content li {
  margin-bottom: 0.35rem;
}
.legal-content table {
  width: 100%;
  margin: 1.5rem 0;
  border-collapse: collapse;
  font-size: 0.9rem;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.legal-content th, .legal-content td {
  border: 1px solid #cbd5e1;
  padding: 8px 12px;
  vertical-align: top;
  line-height: 1.5;
}
.legal-content th {
  background-color: #f1f5f9;
  color: #0f172a;
  font-weight: 600;
  text-align: left;
}
.legal-content th:first-child,
.legal-content td:first-child {
  text-align: center;
  font-weight: 500;
}
.legal-content tr:nth-child(even) td {
  background-color: #f8fafc;
}
.legal-content tr:hover td {
  background-color: #f1f5f9;
}

/* 3. Right Sidebar: Mục lục Điều (Independent Scroll) */
.toc-panel {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow-y: auto;
  font-size: 0.88rem;
  background-color: var(--pmu-card-bg);
  border: 1px solid var(--pmu-border);
  border-radius: 10px;
  padding: 14px 12px;
}
.toc-item {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  color: var(--pmu-text-muted);
  text-decoration: none;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.15s ease;
  font-size: 0.86rem;
  line-height: 1.4;
  margin-bottom: 2px;
}
.toc-item .toc-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toc-item.toc-level-1 {
  font-weight: 600;
  color: #1e293b;
  margin-top: 4px;
}
.toc-item.toc-level-2 {
  padding-left: 20px;
  font-size: 0.82rem;
  color: #475569;
}
.toc-item.toc-level-3 {
  padding-left: 32px;
  font-size: 0.78rem;
  color: #64748b;
}
.toc-item.toc-level-4 {
  padding-left: 44px;
  font-size: 0.76rem;
  color: #64748b;
}
.toc-item:hover {
  background-color: #f1f5f9;
  color: var(--pmu-primary);
}
.toc-item.active {
  background-color: #e0e7ff !important;
  color: #1d4ed8 !important;
  font-weight: 600;
  border-left: 3px solid #2563eb;
}

/* Search Results Card */
.search-result-card {
  border: 1px solid var(--pmu-border);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 12px;
  background-color: white;
  transition: all 0.2s ease;
  cursor: pointer;
}
.search-result-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: #93c5fd;
  transform: translateY(-1px);
}

/* Chat Assistant */
.chat-card {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px;
}
.chat-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 12px;
  line-height: 1.65;
  font-size: 0.95rem;
}
.chat-bubble.user {
  background-color: var(--pmu-primary);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}
.chat-bubble.assistant {
  background-color: white;
  border: 1px solid var(--pmu-border);
  color: var(--pmu-text);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.quick-question-btn {
  font-size: 0.82rem;
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  border-radius: 20px;
  padding: 4px 12px;
  margin-right: 6px;
  margin-bottom: 6px;
  display: inline-block;
  cursor: pointer;
  transition: all 0.15s;
}
.quick-question-btn:hover {
  background-color: #e2e8f0;
  border-color: #94a3b8;
  color: var(--pmu-primary);
}

/* Legal Matrix Panel */
.matrix-container {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow-y: auto;
}

/* Legal Cross-Reference Interactive Links (Thanh thoát, chuẩn văn bản pháp quy) */
.legal-cross-link {
  color: #0284c7;
  text-decoration: underline dotted #0284c7;
  text-underline-offset: 3px;
  font-weight: 600;
  padding: 0;
  margin: 0;
  border-radius: 2px;
  background-color: transparent;
  border: none;
  transition: all 0.15s ease;
  display: inline;
  cursor: pointer;
}
.legal-cross-link:hover {
  color: #0369a1;
  background-color: rgba(2, 132, 199, 0.12);
  text-decoration: underline solid #0369a1;
  box-shadow: none;
}
.legal-cross-link.doc-ref {
  color: #0d9488;
  text-decoration: underline dotted #0d9488;
  font-weight: 600;
}
.legal-cross-link.doc-ref:hover {
  color: #0f766e;
  background-color: rgba(13, 148, 136, 0.12);
  text-decoration: underline solid #0f766e;
}

/* Custom Interactive Reference Tooltip / Popover */
.ref-preview-card {
  max-width: 480px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  border: 1px solid #cbd5e1;
  font-size: 0.88rem;
  line-height: 1.55;
  color: #1e293b;
}
.ref-preview-card .ref-header {
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 6px;
  margin-bottom: 8px;
}
.ref-preview-card .ref-body {
  max-height: 220px;
  overflow-y: auto;
  background: #f8fafc;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

/* Article, Clause, and Point Anchor Targets and Highlighting */
.article-anchor-target,
.clause-anchor-target,
.point-anchor-target {
  display: block;
  position: relative;
  top: -12px;
  visibility: hidden;
  height: 0;
  margin: 0;
  padding: 0;
}

.article-highlight {
  animation: pulse-article-highlight 2.8s ease-out;
  border-left: 4px solid #0d9488 !important;
  background: linear-gradient(90deg, rgba(254, 240, 138, 0.45) 0%, rgba(254, 240, 138, 0.05) 100%) !important;
  padding-left: 10px !important;
  border-radius: 4px;
  transition: all 0.5s ease;
}

@keyframes pulse-article-highlight {
  0% {
    background: linear-gradient(90deg, rgba(253, 224, 71, 0.8) 0%, rgba(253, 224, 71, 0.2) 100%);
    box-shadow: 0 0 0 4px rgba(234, 179, 8, 0.25);
  }
  60% {
    background: linear-gradient(90deg, rgba(254, 240, 138, 0.5) 0%, rgba(254, 240, 138, 0.1) 100%);
  }
/* Tab 5: Workflow Matrix & Authority Suite Styles */
.matrix-container .form-select-sm {
  font-size: 0.82rem;
  border-radius: 6px;
}
.matrix-container .badge {
  font-weight: 600;
  letter-spacing: 0.3px;
}
.matrix-container #matrixSubTab .nav-link {
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  border-radius: 6px;
  background: transparent;
  transition: all 0.2s ease;
}
.matrix-container #matrixSubTab .nav-link.active {
  color: #ffffff;
  background-color: #0284c7;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.35);
}
.matrix-container #matrixSubTab .nav-link:hover:not(.active) {
  background: #f1f5f9;
  color: #0f172a;
}
.chk-item-input {
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
}
@media print {
  body * {
    visibility: hidden;
  }
  #matrix-view, #matrix-view * {
    visibility: visible;
  }
  #matrix-view {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }
}

/* Document Images & PDF Evidence */
.document-content img,
#docContent img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  margin: 16px auto;
  border: 1px solid #dee2e6;
  display: block;
  background-color: #fff;
  cursor: zoom-in;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.document-content img:hover,
#docContent img:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* Jev Decision Engine Audit Trail */
.decision-audit-trail {
  font-family: system-ui, -apple-system, sans-serif;
  transition: all 0.2s ease;
}
.decision-audit-trail:hover {
  background-color: #f1f5f9 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

