/* ==========================================================================
   Design System & Pure Org Tree Chart (Pure White Workspace Background #FFFFFF)
   Struktur Organisasi BKKBN Provinsi Jawa Timur
   ========================================================================== */

:root {
  /* Color Palette */
  --primary-500: #0284C7;
  --primary-600: #0369A1;

  --line-color: #64748B;
  --line-width: 2px;

  /* Slim Compact Card Width */
  --card-width: 235px;

  /* Theme Tokens - Default Light Pure White #FFFFFF */
  --bg-main: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-glass: rgba(255, 255, 255, 0.95);
  --bg-control: #FFFFFF;
  --bg-hover: #F8FAFC;

  --text-main: #0F172A;
  --text-muted: #475569;
  --text-light: #64748B;

  --border-color: #CBD5E1;
  --border-focus: #0284C7;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.12);

  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Tokens */
[data-theme="dark"] {
  --bg-main: #0B0F19;
  --bg-card: #151D2A;
  --bg-glass: rgba(21, 29, 42, 0.95);
  --bg-control: #1E293B;
  --bg-hover: #26334D;
  --line-color: #475569;

  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-light: #64748B;

  --border-color: #26334D;
  --border-focus: #38BDF8;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.35;
  transition: var(--transition);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 0.75rem;
}

/* Header Section Ultra Compact */
.compact-header {
  background: linear-gradient(135deg, #075985 0%, #0F172A 100%);
  color: #FFFFFF;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.header-container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.compact-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #FFFFFF;
  margin: 0;
}

.meta-pill-compact {
  font-size: 0.725rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  color: #BAE6FD;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* Header Toggle Group */
.toggle-group-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  user-select: none;
}

.toggle-item input { display: none; }

.toggle-slider {
  width: 24px;
  height: 14px;
  background-color: rgba(255, 255, 255, 0.3);
  border-radius: 99px;
  position: relative;
  transition: var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #FFFFFF;
  top: 2px;
  left: 2px;
  transition: var(--transition);
}

.toggle-item input:checked + .toggle-slider {
  background-color: #0284C7;
}

.toggle-item input:checked + .toggle-slider::before {
  transform: translateX(10px);
}

.toggle-text {
  font-size: 0.7rem;
  font-weight: 700;
  color: #E0F2FE;
}

/* Compact Search */
.search-box-compact {
  position: relative;
  width: 210px;
}

.search-icon {
  position: absolute;
  left: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  width: 13px;
  height: 13px;
  color: var(--text-muted);
}

.search-box-compact input {
  width: 100%;
  padding: 0.35rem 1.6rem 0.35rem 1.8rem;
  background: var(--bg-control);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.775rem;
  color: var(--text-main);
  outline: none;
}

.search-box-compact input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
}

.clear-btn {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--text-muted);
  cursor: pointer;
}

.action-buttons-compact {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.65rem;
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-blue { background: var(--primary-600); }
.btn-blue:hover { background: #0284C7; }

.btn-emerald { background: #059669; }
.btn-emerald:hover { background: #10B981; }

.btn-icon-compact {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  color: #FFFFFF;
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon-compact:hover { background: rgba(255, 255, 255, 0.25); }
.btn-icon-compact svg { width: 15px; height: 15px; }

[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* Main Content Wrapper */
.main-content {
  padding: 1rem 0.5rem;
  flex: 1;
  background-color: #FFFFFF;
}

[data-theme="dark"] .main-content {
  background-color: var(--bg-main);
}

.search-status {
  padding: 0.4rem 0.85rem;
  background: rgba(2, 132, 199, 0.1);
  border: 1px solid rgba(2, 132, 199, 0.25);
  border-radius: var(--radius-md);
  color: var(--text-main);
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
}

/* ==========================================================================
   PURE CSS TREE ORG CHART (PURE WHITE WORKSPACE BACKGROUND #FFFFFF)
   ========================================================================== */

.tree-wrapper {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  padding: 0.75rem 0;
  scrollbar-width: thin;
  background-color: #FFFFFF;
}

[data-theme="dark"] .tree-wrapper {
  background-color: var(--bg-main);
}

.tree-root-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: max-content;
  margin: 0 auto;
  background-color: #FFFFFF;
}

[data-theme="dark"] .tree-root-container {
  background-color: var(--bg-main);
}

/* Vertical Stem Line */
.stem-line {
  width: var(--line-width);
  height: 20px;
  background-color: var(--line-color);
  flex-shrink: 0;
}

/* Executive Node Box */
.tree-node-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.5rem 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  z-index: 2;
  width: 280px;
}

.tree-node-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-focus);
}

.node-pengarah { border-top: 3px solid #0D9488; background: #F0FDF4; }
.node-koordinator { border-top: 3px solid #0284C7; background: #F0F9FF; }

[data-theme="dark"] .node-pengarah { background: rgba(13, 148, 136, 0.12); }
[data-theme="dark"] .node-koordinator { background: rgba(2, 132, 199, 0.12); }

.node-badge {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  color: #FFFFFF;
  margin-bottom: 0.15rem;
}

.badge-teal { background: #0D9488; }
.badge-blue { background: #0284C7; }

.node-name {
  font-size: 0.875rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.node-role {
  font-size: 0.725rem;
  color: var(--text-muted);
  margin-top: 0.05rem;
}

/* Horizontal Branching System across 9 Teams */
.teams-branch-wrapper {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  position: relative;
  width: 100%;
  padding-top: 20px;
  gap: 0.45rem;
}

.team-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  width: var(--card-width);
  flex-shrink: 0;
}

/* Top Vertical stem connecting to each team column */
.team-column::before {
  content: '';
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: var(--line-width);
  height: 20px;
  background-color: var(--line-color);
}

/* Horizontal connector line linking adjacent team columns */
.team-column::after {
  content: '';
  position: absolute;
  top: -20px;
  height: var(--line-width);
  background-color: var(--line-color);
  left: -0.225rem;
  right: -0.225rem;
}

.team-column:first-child::after { left: 50%; }
.team-column:last-child::after { right: 50%; }
.team-column:only-child::after { display: none; }

/* 9 Slim Uniform Team Cards with Soft Tint Backgrounds */
.team-card {
  width: 100%;
  border-radius: var(--radius-md);
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  border-top-width: 3px;
  border-top-style: solid;
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.team-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* 9 Soft Pastel Colored Card Backgrounds (Light & Dark) */
.team-card[data-id="1"] { border-top-color: #0284C7; background: #F0F9FF; }
.team-card[data-id="1"] .team-number { background: #0284C7; }
.team-card[data-id="1"] .pj-badge { color: #0284C7; }

.team-card[data-id="2"] { border-top-color: #0D9488; background: #F0FDF4; }
.team-card[data-id="2"] .team-number { background: #0D9488; }
.team-card[data-id="2"] .pj-badge { color: #0D9488; }

.team-card[data-id="3"] { border-top-color: #7C3AED; background: #F5F3FF; }
.team-card[data-id="3"] .team-number { background: #7C3AED; }
.team-card[data-id="3"] .pj-badge { color: #7C3AED; }

.team-card[data-id="4"] { border-top-color: #EA580C; background: #FFF7ED; }
.team-card[data-id="4"] .team-number { background: #EA580C; }
.team-card[data-id="4"] .pj-badge { color: #EA580C; }

.team-card[data-id="5"] { border-top-color: #D97706; background: #FFFBEB; }
.team-card[data-id="5"] .team-number { background: #D97706; }
.team-card[data-id="5"] .pj-badge { color: #D97706; }

.team-card[data-id="6"] { border-top-color: #E11D48; background: #FFF1F2; }
.team-card[data-id="6"] .team-number { background: #E11D48; }
.team-card[data-id="6"] .pj-badge { color: #E11D48; }

.team-card[data-id="7"] { border-top-color: #4F46E5; background: #EEF2FF; }
.team-card[data-id="7"] .team-number { background: #4F46E5; }
.team-card[data-id="7"] .pj-badge { color: #4F46E5; }

.team-card[data-id="8"] { border-top-color: #059669; background: #ECFDF5; }
.team-card[data-id="8"] .team-number { background: #059669; }
.team-card[data-id="8"] .pj-badge { color: #059669; }

.team-card[data-id="9"] { border-top-color: #0891B2; background: #ECFEFF; }
.team-card[data-id="9"] .team-number { background: #0891B2; }
.team-card[data-id="9"] .pj-badge { color: #0891B2; }

/* Dark Mode Soft Tint Overrides */
[data-theme="dark"] .team-card[data-id="1"] { background: rgba(2, 132, 199, 0.1); }
[data-theme="dark"] .team-card[data-id="2"] { background: rgba(13, 148, 136, 0.1); }
[data-theme="dark"] .team-card[data-id="3"] { background: rgba(124, 58, 237, 0.1); }
[data-theme="dark"] .team-card[data-id="4"] { background: rgba(234, 88, 12, 0.1); }
[data-theme="dark"] .team-card[data-id="5"] { background: rgba(217, 119, 6, 0.1); }
[data-theme="dark"] .team-card[data-id="6"] { background: rgba(225, 29, 72, 0.1); }
[data-theme="dark"] .team-card[data-id="7"] { background: rgba(79, 70, 229, 0.1); }
[data-theme="dark"] .team-card[data-id="8"] { background: rgba(5, 150, 105, 0.1); }
[data-theme="dark"] .team-card[data-id="9"] { background: rgba(8, 145, 178, 0.1); }

/* Card Content Elements Ultra Compact */
.team-header {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  margin-bottom: 0.45rem;
}

[data-theme="dark"] .team-header {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.team-number {
  width: 22px;
  height: 22px;
  color: #FFFFFF;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.team-title-wrap { flex: 1; }

.team-title {
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text-main);
  margin-bottom: 0.1rem;
}

.team-ketua {
  font-size: 0.725rem;
  color: var(--text-muted);
}

.team-ketua strong {
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
}

.indikator-box {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.5rem;
  margin-bottom: 0.45rem;
  font-size: 0.7rem;
}

[data-theme="dark"] .indikator-box {
  background: rgba(15, 23, 42, 0.5);
  border-color: rgba(255, 255, 255, 0.05);
}

.indikator-header {
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.2rem;
  font-size: 0.625rem;
}

.indikator-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.indikator-list li {
  color: var(--text-main);
  line-height: 1.25;
}

/* Sub-Teams Container (Tree Branching Inside Card) */
.subteams-container {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  position: relative;
}

.subteam-item {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.45rem;
  position: relative;
  margin-left: 0.4rem;
}

[data-theme="dark"] .subteam-item {
  background: var(--bg-card);
}

/* Connected Line from Team to Sub-Team */
.subteam-item::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 12px;
  width: 10px;
  height: var(--line-width);
  background-color: var(--line-color);
}

.subteam-item::after {
  content: '';
  position: absolute;
  left: -10px;
  top: -8px;
  bottom: 12px;
  width: var(--line-width);
  background-color: var(--line-color);
}

.subteam-item:first-child::after { top: 0; }

.subteam-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.15rem;
  line-height: 1.2;
}

.pj-badge {
  display: block;
  font-size: 0.725rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  cursor: pointer;
}

.anggota-label {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 0.2rem;
}

/* Vertical Stacked List for Names Ultra Compact */
.anggota-vertical-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.anggota-vertical-item {
  display: flex;
  align-items: center;
  padding: 0.2rem 0.45rem;
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition);
  line-height: 1.2;
}

[data-theme="dark"] .anggota-vertical-item {
  background: var(--bg-main);
}

.anggota-vertical-item:hover {
  background: var(--primary-500);
  color: #FFFFFF;
  border-color: var(--primary-500);
}

/* Highlight Search */
.highlight {
  background-color: #FEF08A;
  color: #854D0E;
  padding: 0.05rem 0.15rem;
  border-radius: 2px;
  font-weight: 700;
}

[data-theme="dark"] .highlight {
  background-color: rgba(245, 158, 11, 0.35);
  color: #FDE68A;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  max-width: 420px;
  width: 100%;
  padding: 1.25rem;
  position: relative;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: var(--transition);
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #FFFFFF;
  background: var(--primary-600);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.3rem;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.15rem;
}

.modal-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}

.modal-info-group {
  margin-bottom: 0.6rem;
}

.modal-info-group label {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 0.1rem;
}

.modal-info-group p {
  font-size: 0.825rem;
  color: var(--text-main);
  font-weight: 600;
}

/* Footer Compact */
.footer-compact {
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 0.6rem 0;
  margin-top: auto;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Print Styles */
@media print {
  .compact-header, .footer-compact { display: none !important; }
  body { background: #FFF !important; color: #000 !important; }
  .teams-branch-wrapper { display: block !important; padding-top: 0 !important; }
  .team-column { margin-bottom: 1rem !important; width: 100% !important; }
  .stem-line, .team-column::before, .team-column::after { display: none !important; }
  .team-card { break-inside: avoid; box-shadow: none !important; border: 1px solid #999 !important; }
}
