/* ============================================================
   LCPL Organization Chart — Design System
   Palette: deep industrial navy + steel + amber (vacancy) accent
   ============================================================ */

:root {
  --navy-950: #0a1628;
  --navy-900: #0f1f36;
  --navy-800: #16283f;
  --navy-700: #1f3654;
  --navy-600: #2b4a70;
  --steel-500: #4a6b8a;
  --steel-300: #8ba3bd;
  --connector-line: #1e293b; /* dark, prominent org-chart connector lines */
  --steel-100: #dbe4ee;
  --ink: #16283f;
  --paper: #f5f7fa;
  --paper-card: #ffffff;
  --line: #e2e8f0;

  --accent: #2563a8;       /* primary corporate blue */
  --accent-deep: #1a4a80;
  --teal: #0d9488;
  --amber: #c27803;        /* vacant */
  --amber-bg: #fef3e0;
  --violet: #7c3aed;       /* contract */
  --red: #dc2626;

  --exec: #1a2a4a;
  --senior: #2563a8;
  --mgmt: #0d9488;
  --officer: #4a6b8a;
  --staff: #94a3b8;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(15, 31, 54, 0.08), 0 1px 2px rgba(15,31,54,.06);
  --shadow-md: 0 4px 16px rgba(15, 31, 54, 0.10), 0 2px 4px rgba(15,31,54,.06);
  --shadow-lg: 0 12px 32px rgba(15, 31, 54, 0.16), 0 4px 8px rgba(15,31,54,.08);
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font-family: inherit; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- App shell ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 64px 1fr;
  grid-template-areas: "header header" "sidebar main";
  min-height: 100vh;
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; grid-template-areas: "header" "main"; }
  .sidebar { display: none; }
  .sidebar.open { display: block; position: fixed; z-index: 60; inset: 64px 0 0 0; }
}

/* ---------- Header ---------- */
.topbar {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: linear-gradient(180deg, var(--navy-950), var(--navy-900));
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-md);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: .2px;
  white-space: nowrap;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--teal));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text .name { font-size: 15px; }
.brand-text .sub { font-size: 11px; color: var(--steel-300); font-weight: 400; }

.topbar-search { flex: 1; max-width: 480px; position: relative; }
.topbar-search input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.08);
  color: #fff;
  font-size: 13.5px;
}
.topbar-search input::placeholder { color: rgba(255,255,255,.5); }
.topbar-search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); opacity: .6; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 9px; border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.06); color: #fff; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.16); }
.btn-admin-login {
  padding: 8px 16px; border-radius: 8px; border: 1px solid rgba(255,255,255,.2);
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}

/* ---------- Sidebar ---------- */
.sidebar {
  grid-area: sidebar;
  background: var(--navy-900);
  color: var(--steel-100);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.side-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 9px; font-size: 13.5px; font-weight: 500;
  color: var(--steel-100); text-decoration: none; cursor: pointer;
  transition: background .12s;
  border: 1px solid transparent;
}
.side-link svg { flex-shrink: 0; opacity: .85; }
.side-link:hover { background: rgba(255,255,255,.06); }
.side-link.active { background: rgba(37,99,168,.35); border-color: rgba(37,99,168,.5); color: #fff; }
.side-divider { height: 1px; background: rgba(255,255,255,.08); margin: 10px 4px; }
.side-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--steel-300); padding: 10px 12px 4px; }

/* ---------- Main ---------- */
.main {
  grid-area: main;
  padding: 22px 26px 60px;
  overflow-x: hidden;
}
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font-family: var(--font-display); font-size: 26px; font-weight: 600; margin: 0 0 4px; color: var(--navy-950); }
.page-sub { font-size: 13px; color: var(--steel-500); margin: 0; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); background: #fff; color: var(--navy-800);
  cursor: pointer; transition: all .12s;
}
.btn:hover { border-color: var(--steel-300); background: var(--paper); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); border-color: transparent; color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { border-color: #fca5a5; color: var(--red); }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---------- Chart toolbar ---------- */
.chart-toolbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px; margin-bottom: 14px; box-shadow: var(--shadow-sm);
}
.chart-toolbar .group { display: flex; gap: 2px; padding-right: 8px; margin-right: 8px; border-right: 1px solid var(--line); }
.chart-toolbar .group:last-child { border-right: none; }
.tb-btn {
  width: 32px; height: 32px; border-radius: 7px; border: none; background: transparent;
  color: var(--navy-700); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.tb-btn:hover { background: var(--paper); }
.tb-btn.active { background: var(--accent); color: #fff; }
.zoom-label { font-size: 12px; color: var(--steel-500); min-width: 40px; text-align: center; }

/* ---------- Legend ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--steel-500); margin-bottom: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Org chart canvas ---------- */
.chart-viewport {
  position: relative;
  background:
    radial-gradient(circle at 1px 1px, #dbe4ee 1px, transparent 0) 0 0/22px 22px,
    var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  height: calc(100vh - 260px);
  min-height: 480px;
}
.chart-viewport.fullscreen { position: fixed; inset: 0; z-index: 100; height: 100vh; border-radius: 0; }
.chart-canvas {
  position: absolute; top: 0; left: 0;
  transform-origin: 0 0;
  padding: 50px;
  cursor: grab;
}
.chart-canvas.dragging { cursor: grabbing; }

.org-tree { display: flex; justify-content: center; }
.org-node { display: flex; flex-direction: column; align-items: center; }
.org-node-row { display: flex; align-items: flex-start; }
.org-children { display: flex; padding-top: 34px; position: relative; }
.org-children::before {
  content: ""; position: absolute; top: 0; left: 50%; width: 1.5px; height: 34px; background: var(--connector-line);
  transform: translateX(-0.75px);
}
.org-child-wrap { position: relative; padding: 0 14px; display: flex; flex-direction: column; align-items: center; }
.org-child-wrap::before {
  content: ""; position: absolute; top: 0; left: 50%; width: 1.5px; height: 34px; background: var(--connector-line);
}
.org-child-wrap::after {
  content: ""; position: absolute; top: 0; height: 1.5px; background: var(--connector-line);
  left: 0; right: 0;
}
.org-child-wrap:first-child::after { left: 50%; }
.org-child-wrap:last-child::after { right: 50%; }
.org-child-wrap:only-child::after { display: none; }

/* ---------- Shared avatar & pill (used in directory, management view, detail panel, search) ---------- */
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.4);
  overflow: hidden;
  background-size: cover; background-position: center;
}
.avatar.vacant-avatar { background: #fff !important; color: var(--amber); border: 2px dashed #eab776; }
.pill {
  font-size: 10px; padding: 2px 7px; border-radius: 999px; font-weight: 600;
  background: var(--steel-100); color: var(--navy-700);
}
.pill.dept { background: rgba(37,99,168,.1); color: var(--accent-deep); }
.pill.contract { background: rgba(124,58,237,.1); color: var(--violet); }

/* ---------- Employee card (photo-forward, minimal) ---------- */
.emp-card {
  width: 176px;
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .14s, box-shadow .14s, border-color .14s;
  position: relative;
  margin-top: 34px;
}
.org-node > .emp-card { margin-top: 0; }
.emp-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--steel-300); }
.emp-card.highlight { outline: 2px solid var(--accent); box-shadow: 0 0 0 4px rgba(37,99,168,.18), var(--shadow-lg); }
.emp-card.vacant { border-style: dashed; border-color: #eab776; }
.emp-card .level-bar { position: absolute; top: 0; left: 0; right: 0; height: 4px; z-index: 2; }
.emp-photo-block {
  width: 100%; height: 132px;
  background-size: cover; background-position: center top;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 32px; letter-spacing: .3px;
}
.emp-photo-block.vacant-photo-block { background: var(--amber-bg); }
.emp-photo-block.vacant-photo-block span {
  width: 46px; height: 46px; border-radius: 50%; background: #fff;
  border: 2px dashed #eab776; color: var(--amber); font-size: 18px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.emp-card-body { padding: 10px 12px 14px; text-align: center; }
.emp-name { font-size: 13.5px; font-weight: 700; line-height: 1.25; color: var(--navy-950); }
.emp-name.is-vacant { color: var(--amber); font-style: italic; font-weight: 600; }
.emp-desig { font-size: 11.5px; color: var(--steel-500); margin-top: 3px; line-height: 1.3; }
.emp-card[draggable="true"] { cursor: grab; }
.emp-card.drag-over { outline: 2px dashed var(--teal); }

/* ---------- Directory card (richer info card — name, dept, status; used only on the Directory page) ---------- */
.dir-card {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .14s, box-shadow .14s, border-color .14s;
  position: relative;
}
.dir-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--steel-300); }
.dir-card .level-bar { position: absolute; top: 0; left: 14px; right: 14px; height: 3px; border-radius: 0 0 3px 3px; }
.dir-card-top { display: flex; gap: 10px; align-items: center; }
.dir-card-meta { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Modal / detail panel ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,22,40,.55); z-index: 200;
  display: flex; align-items: center; justify-content: flex-end;
  backdrop-filter: blur(2px);
}
.modal-backdrop.center { align-items: center; justify-content: center; }
.detail-panel {
  width: 420px; max-width: 92vw; height: 100%; background: #fff; box-shadow: var(--shadow-lg);
  overflow-y: auto; animation: slideIn .22s ease;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.dialog {
  width: 520px; max-width: 92vw; max-height: 88vh; overflow-y: auto; background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); animation: pop .16s ease;
}
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.detail-header {
  padding: 20px; background: linear-gradient(135deg, var(--navy-950), var(--navy-800)); color: #fff; position: relative;
}
.detail-header .close-btn { position: absolute; top: 14px; right: 14px; }
.detail-header .avatar { width: 64px; height: 64px; font-size: 22px; margin-bottom: 12px; }
.detail-header h2 { margin: 0; font-size: 18px; font-family: var(--font-display); }
.detail-header p { margin: 3px 0 0; font-size: 13px; color: var(--steel-300); }
.detail-body { padding: 18px 20px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.detail-field label { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--steel-500); margin-bottom: 3px; }
.detail-field div { font-size: 13.5px; font-weight: 600; color: var(--navy-950); }
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 12.5px; margin-bottom: 16px; }
.breadcrumb a { color: var(--accent); text-decoration: none; cursor: pointer; padding: 3px 7px; border-radius: 6px; }
.breadcrumb a:hover { background: var(--paper); }
.breadcrumb .sep { color: var(--steel-300); }
.section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--steel-500); margin: 16px 0 8px; font-weight: 700; }
.reports-list { display: flex; flex-direction: column; gap: 6px; }
.report-row {
  display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer;
}
.report-row:hover { background: var(--paper); }
.report-row .avatar { width: 30px; height: 30px; font-size: 11px; }
.report-row .rr-name { font-size: 12.5px; font-weight: 600; }
.report-row .rr-desig { font-size: 11px; color: var(--steel-500); }

/* ---------- Directory / table views ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.directory-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--steel-500); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; }
table.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data-table tr:hover td { background: var(--paper); }
.status-badge { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.status-badge.active { background: #dcfce7; color: #15803d; }
.status-badge.vacant { background: var(--amber-bg); color: var(--amber); }
.status-badge.inactive { background: #f1f5f9; color: #64748b; }

/* ---------- Department filter chips ---------- */
.dept-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.dept-chip {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff;
  font-size: 12.5px; font-weight: 600; color: var(--navy-700); cursor: pointer;
}
.dept-chip.active { background: var(--navy-950); color: #fff; border-color: var(--navy-950); }

/* ---------- Stats dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { padding: 18px; }
.stat-card .num { font-family: var(--font-display); font-size: 30px; font-weight: 600; color: var(--navy-950); }
.stat-card .lbl { font-size: 12px; color: var(--steel-500); margin-top: 2px; }
.stat-card .trend { font-size: 11px; margin-top: 8px; display: flex; align-items: center; gap: 4px; }

/* ---------- Search dropdown ---------- */
.search-results {
  position: absolute; top: 44px; left: 0; right: 0; background: #fff; border-radius: 12px;
  box-shadow: var(--shadow-lg); max-height: 380px; overflow-y: auto; z-index: 60; color: var(--ink);
}
.search-result-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--paper); }
.search-result-item .avatar { width: 32px; height: 32px; font-size: 11px; }
mark { background: #fef08a; border-radius: 2px; padding: 0 1px; }

/* ---------- Misc ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--steel-500); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast-wrap { position: fixed; bottom: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--navy-950); color: #fff; padding: 11px 16px; border-radius: 9px; font-size: 13px; box-shadow: var(--shadow-lg); animation: pop .15s ease; }
.toast.error { background: #7f1d1d; }
.toast.success { background: #14532d; }

@media print {
  .topbar, .sidebar, .chart-toolbar, .toolbar, .page-sub { display: none !important; }
  .chart-viewport { height: auto !important; border: none; }
  .main { padding: 0; }
}
