/* ============================================================
   REPORTS.CSS — Reports Engine (standalone page that opens
   from the 1201 "Launch Reports Engine" sidebar menu item)
   ============================================================ */

:root {
  --primary: #0f2b4c;
  --primary-dark: #0a1f38;
  --primary-light: #1a3d6b;
  --secondary: #64748b;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --background: #eef2f7;
  --surface: #ffffff;
  --border: #dbe2ec;
  --text-primary: #0f172a;
  --text-secondary: #52607a;
  --text-muted: #93a2b8;
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--background);
  color: var(--text-primary);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a {
  text-decoration: none;
}

.reports-engine {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   TOPBAR
   ============================================================ */

.reports-topbar {
  height: 60px;
  background: var(--primary-dark);
  color: #fff;
  display: flex;
  align-items: center;
  padding-inline: 20px;
  gap: 20px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(10, 31, 56, 0.35);
  z-index: 20;
}

.reports-brand {
  flex-shrink: 0;
}

.reports-brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}

.reports-brand-icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  font-size: 16px;
  color: #7cc0ff;
}

.reports-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.reports-brand-name {
  font-size: 15px;
  font-weight: 700;
}

.reports-brand-sub {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.55);
}

.reports-topbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.reports-engine-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}

.reports-topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.reports-info {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
}

.reports-close {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.08);
  transition: all 0.2s;
}

.reports-close:hover {
  background: rgba(220, 38, 38, 0.75);
  color: #fff;
}

/* ============================================================
   BODY LAYOUT
   ============================================================ */

.reports-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ============================================================
   SIDEBAR (Treeview)
   ============================================================ */

.reports-sidebar {
  width: 300px;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.reports-sidebar-title {
  padding: 14px 18px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: #f7f9fc;
  flex-shrink: 0;
}

.reports-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.reports-nav::-webkit-scrollbar {
  width: 6px;
}

.reports-nav::-webkit-scrollbar-thumb {
  background: #d3dce8;
  border-radius: 6px;
}

/* Category */
.report-cat {
  margin-bottom: 4px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid transparent;
}

.report-cat.expanded {
  background: #f8fafc;
  border-color: var(--border);
}

.report-cat-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}

.report-cat-toggle:hover {
  background: #f1f5f9;
}

.report-cat-arrow {
  width: 14px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.report-cat.expanded .report-cat-arrow {
  transform: rotate(90deg);
}

.report-cat-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  flex-shrink: 0;
}

.report-cat-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.report-cat-count {
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: #e7edf5;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

/* Report list within category */
.report-cat-list {
  list-style: none;
  display: none;
  padding: 0 0 6px;
  border-top: 1px dashed var(--border);
  margin-top: 4px;
}

.report-cat.expanded .report-cat-list {
  display: block;
}

.report-cat-list li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px 7px 24px;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.report-cat-list li a:hover {
  background: #eef4fc;
  color: var(--primary);
}

.report-cat-list li a.active {
  background: #e7eef7;
  color: var(--primary);
  font-weight: 600;
}

/* Nested sub-category (group) */
.report-sub {
  border-top: 1px dashed var(--border);
  margin-top: 4px;
  padding-top: 4px;
}

.report-sub-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.report-sub-toggle:hover {
  background: #f1f5f9;
}

.report-sub-arrow {
  width: 12px;
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.report-sub.expanded .report-sub-arrow {
  transform: rotate(90deg);
}

.report-sub-title {
  flex: 1;
}

.report-sub-list {
  list-style: none;
  padding: 0;
  display: none;
}

.report-sub.expanded .report-sub-list {
  display: block;
}

.report-sub-list li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 5px 34px;
  font-size: 12.5px;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.report-sub-list li a:hover {
  background: #eef4fc;
  color: var(--primary);
}

.report-sub-list li a .report-code {
  min-width: 38px;
  padding: 1px 5px;
  font-size: 10.5px;
}

.report-code {
  min-width: 40px;
  padding: 2px 6px;
  background: #eef2f8;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  flex-shrink: 0;
}

.report-cat-list li a:hover .report-code,
.report-cat-list li a.active .report-code {
  background: #dbe8f7;
  color: var(--primary);
}

.report-name {
  flex: 1;
  line-height: 1.35;
}

/* ============================================================
   MAIN PANEL
   ============================================================ */

.reports-main {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.reports-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(15, 40, 80, 0.06);
  overflow: hidden;
}

.reports-panel-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: #fbfcfe;
  position: relative;
}

.reports-panel-hd::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}

.hd-blue::before { background: #2563eb; }
.hd-amber::before { background: #d97706; }
.hd-green::before { background: #16a34a; }
.hd-purple::before { background: #7c3aed; }
.hd-red::before { background: #dc2626; }
.hd-cyan::before { background: #0891b2; }
.hd-teal::before { background: #0d9488; }
.hd-indigo::before { background: #4f46e5; }

.reports-panel-hd .hd-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 9px;
}

.reports-panel-hd .hd-title i {
  color: var(--primary);
}

.reports-panel-hd .hd-code {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 4px 10px;
  border-radius: 6px;
}

.reports-panel-bd {
  padding: 16px 18px;
}

/* Report tiles grid */
#report-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
}

.report-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text-primary);
  transition: all 0.15s;
}

.report-tile:hover {
  border-color: var(--primary);
  background: #f6f9fd;
  box-shadow: 0 2px 8px rgba(15, 40, 80, 0.08);
  transform: translateY(-1px);
}

.report-tile-code {
  min-width: 42px;
  padding: 3px 8px;
  background: #eef2f8;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  flex-shrink: 0;
}

.report-tile:hover .report-tile-code {
  background: #dbe8f7;
  color: var(--primary);
}

.report-tile-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
}

.report-tile-arrow {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: color 0.15s;
}

.report-tile:hover .report-tile-arrow {
  color: var(--primary);
}

/* Grouped tiles in content panel */
.report-tile-group {
  grid-column: 1 / -1;
  margin-bottom: 4px;
}

.report-tile-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  padding: 8px 2px 6px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 6px 6px 0 0;
}

.report-tile-group-title i {
  color: var(--text-muted);
  font-size: 13px;
}

.report-tile-group-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
  padding-top: 10px;
  background: #fbfcfe;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 12px;
}

/* ============================================================
   FOOTER
   ============================================================ */

.reports-footer {
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ============================================================
   RTL SUPPORT
   ============================================================ */

[dir="rtl"] .report-cat-arrow,
[dir="rtl"] .report-cat.expanded .report-cat-arrow {
  transform: rotate(180deg);
}

[dir="rtl"] .reports-panel-hd::before {
  left: auto;
  right: 0;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
  .reports-sidebar {
    width: 240px;
  }

  .reports-info {
    display: none;
  }
}

@media (max-width: 560px) {
  .reports-sidebar {
    position: fixed;
    left: 0;
    top: 60px;
    bottom: 0;
    width: 280px;
    z-index: 30;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.12);
  }

  #report-list {
    grid-template-columns: 1fr;
  }
}
