/* ==========================================================================
   IVEACER Organization Structure Chart - Stylesheet
   สถาบันการอาชีวศึกษาเกษตรภาคกลาง (Institute of Vocational Education : Central Region)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700;800&family=Prompt:wght@400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --font-heading: 'Kanit', 'Prompt', sans-serif;
  --font-body: 'Prompt', 'Inter', sans-serif;
  
  /* Department Theme Colors */
  --col-office: #0f766e;        /* เขียวหัวเป็ด / สำนักงาน ผอ. */
  --col-office-light: #ecfdf5;
  --col-strategy: #1e40af;      /* น้ำเงินคราม / ยุทธศาสตร์ */
  --col-strategy-light: #eff6ff;
  --col-academic: #6d28d9;      /* ม่วงเข้ม / พัฒนาวิชาการ */
  --col-academic-light: #f5f3ff;
  --col-research: #c2410c;      /* ส้มสด / ศูนย์วิจัยและพัฒนา */
  --col-research-light: #fff7ed;
  --col-bachelor: #be185d;      /* ชมพูมาเจนต้า / อาชีวศึกษาบัณฑิต */
  --col-bachelor-light: #fdf2f8;
  --col-colleges: #1d4ed8;      /* น้ำเงินสด / วิทยาลัยในสังกัด 10 แห่ง */
  --col-colleges-light: #eff6ff;

  --line-default: #94a3b8;
  --line-active: #10b981;
}

body {
  font-family: var(--font-body);
  background-color: #f8fafc;
  color: #1e293b;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6, .font-heading {
  font-family: var(--font-heading);
}

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

/* Chart Canvas Wrapper & Pan/Zoom Container */
.chart-viewport {
  position: relative;
  width: 100%;
  min-height: 840px;
  overflow: auto;
  cursor: grab;
  user-select: none;
  touch-action: pan-x pan-y;
  background-color: #fcfdfd;
  background-image: radial-gradient(#e2e8f0 1.2px, transparent 1.2px);
  background-size: 24px 24px;
  border-radius: 20px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
}

.chart-viewport.grabbing {
  cursor: grabbing;
}

.chart-container {
  position: relative;
  min-width: 1420px;
  padding: 30px 24px 80px 24px;
  margin: 0 auto;
  transform-origin: top center;
  transition: transform 0.15s ease-out;
}

/* SVG Line Layer */
.connector-svg-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.tree-line {
  fill: none;
  stroke: var(--line-default);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.3s ease, stroke-width 0.3s ease, filter 0.3s ease;
}

.tree-line.active {
  stroke-width: 3.8;
  filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.6));
}

.tree-line-dashed {
  stroke-dasharray: 6 5;
  animation: dashMove 20s linear infinite;
}

@keyframes dashMove {
  to {
    stroke-dashoffset: -100;
  }
}

/* Level 1 Capsules */
.node-capsule-l1 {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 10px 26px;
  border-radius: 9999px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 20;
  cursor: pointer;
}

.node-capsule-l1:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 20px 30px -10px rgba(0, 0, 0, 0.18);
}

.node-council {
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%);
  color: #ffffff;
  border: 2px solid #3b82f6;
}

.node-director {
  background: linear-gradient(135deg, #14532d 0%, #15803d 100%);
  color: #ffffff;
  border: 2px solid #22c55e;
}

/* Level 2 Sub-Executive Capsules */
.node-capsule-l2 {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  border-radius: 9999px;
  background: #ffffff;
  border: 2px solid #16a34a;
  color: #166534;
  font-weight: 600;
  font-size: 14.5px;
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.12);
  transition: all 0.25s ease;
  position: relative;
  z-index: 20;
  cursor: pointer;
}

.node-capsule-l2:hover {
  transform: translateY(-2px);
  background: #f0fdf4;
  border-color: #15803d;
  box-shadow: 0 8px 20px rgba(22, 163, 74, 0.22);
}

/* Department Column Cards */
.dept-column {
  background: #ffffff;
  border-radius: 24px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 8px 20px -4px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 20;
  overflow: hidden;
}

.dept-column:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 32px -8px rgba(0, 0, 0, 0.12);
}

.dept-column.highlighted {
  border-width: 2px;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.35), 0 20px 35px -10px rgba(0, 0, 0, 0.15);
}

.dept-column.dimmed {
  opacity: 0.35;
  filter: grayscale(40%);
}

/* Department Headers with Rounded Arch */
.dept-header {
  padding: 16px 14px 14px 14px;
  text-align: center;
  color: #ffffff;
  position: relative;
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  cursor: pointer;
  transition: filter 0.2s ease;
}

.dept-header:hover {
  filter: brightness(1.08);
}

.dept-header-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 10px auto;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}

.dept-column:hover .dept-header-icon {
  transform: scale(1.1) rotate(5deg);
}

/* Department Specific Colors */
.dept-office .dept-header {
  background: linear-gradient(180deg, #115e59 0%, #0f766e 100%);
  border-bottom: 3px solid #0d9488;
}
.dept-office {
  border-color: #ccfbf1;
}

.dept-strategy .dept-header {
  background: linear-gradient(180deg, #1e3a8a 0%, #1e40af 100%);
  border-bottom: 3px solid #2563eb;
}
.dept-strategy {
  border-color: #dbeafe;
}

.dept-academic .dept-header {
  background: linear-gradient(180deg, #581c87 0%, #6d28d9 100%);
  border-bottom: 3px solid #7c3aed;
}
.dept-academic {
  border-color: #ede9fe;
}

.dept-research .dept-header {
  background: linear-gradient(180deg, #9a3412 0%, #c2410c 100%);
  border-bottom: 3px solid #ea580c;
}
.dept-research {
  border-color: #ffedd5;
}

.dept-bachelor .dept-header {
  background: linear-gradient(180deg, #831843 0%, #be185d 100%);
  border-bottom: 3px solid #db2777;
}
.dept-bachelor {
  border-color: #fce7f3;
}

.dept-colleges .dept-header {
  background: linear-gradient(180deg, #1d4ed8 0%, #2563eb 100%);
  border-bottom: 3px solid #3b82f6;
}
.dept-colleges {
  border-color: #dbeafe;
}

/* Sub-items in Department Cards */
.sub-group-item {
  padding: 10px 12px;
  border-radius: 12px;
  margin: 4px 8px;
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  font-size: 13.5px;
  line-height: 1.4;
  color: #334155;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sub-group-item:hover {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  transform: translateX(3px);
}

.sub-group-item.highlight-match {
  background: #fef08a !important;
  border-color: #eab308 !important;
  color: #713f12 !important;
  font-weight: 600;
  transform: scale(1.02);
}

.bullet-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.sub-group-item:hover .bullet-dot {
  transform: scale(1.4);
}

/* Landscape Agriculture Footer Graphics */
.agri-landscape-footer {
  position: relative;
  width: 100%;
  height: 120px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(220, 252, 231, 0.35) 50%, rgba(187, 247, 208, 0.65) 100%);
  overflow: hidden;
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
  pointer-events: none;
}

.agri-vector-svg {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 110px;
  opacity: 0.85;
}

/* Search Highlights */
mark.search-matched {
  background-color: #fde047;
  color: #854d0e;
  padding: 0 2px;
  border-radius: 3px;
  font-weight: 600;
}

/* Modal Details */
.modal-backdrop {
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  transition: opacity 0.25s ease;
}

.modal-container {
  transform: scale(0.95);
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-active .modal-container {
  transform: scale(1);
  opacity: 1;
}

/* Dark Mode Overrides */
.dark body {
  background-color: #090d16;
  color: #f1f5f9;
}

.dark .chart-viewport {
  background-color: #0b1120;
  background-image: radial-gradient(#1e293b 1.2px, transparent 1.2px);
  border-color: #1e293b;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
}

.dark .dept-column {
  background: #131b2e;
  border-color: #1e293b;
  box-shadow: 0 8px 25px -4px rgba(0, 0, 0, 0.4);
}

.dark .node-capsule-l2 {
  background: #0f231c;
  border-color: #22c55e;
  color: #4ade80;
  box-shadow: 0 4px 14px rgba(34, 197, 94, 0.15);
}
.dark .node-capsule-l2:hover {
  background: #14352b;
}

.dark .sub-group-item {
  background: #182339;
  border-color: #1e293b;
  color: #cbd5e1;
}
.dark .sub-group-item:hover {
  background: #212f4c;
  border-color: #334155;
  color: #ffffff;
}

.dark .agri-landscape-footer {
  background: linear-gradient(180deg, rgba(11, 17, 32, 0) 0%, rgba(13, 38, 30, 0.4) 60%, rgba(20, 83, 45, 0.4) 100%);
}

/* Print Mode Optimization */
@media print {
  @page {
    size: landscape;
    margin: 8mm;
  }
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .no-print, header, .top-control-bar, .chart-controls, footer {
    display: none !important;
  }
  .chart-viewport {
    border: none !important;
    box-shadow: none !important;
    overflow: visible !important;
    height: auto !important;
    background: none !important;
  }
  .chart-container {
    transform: none !important;
    padding: 0 !important;
    min-width: 100% !important;
  }
  .dept-column {
    box-shadow: none !important;
    border: 1px solid #cbd5e1 !important;
  }
}
