﻿/* HRDI org chart v2 — faithful import for About/Structure2 */
/* Source: hrdi_orgchart_v2.zip */

.hrdi-orgchart {
  --bg:        transparent;
  --bg-card:   #FFFFFF;
  --board-bg:  #37474F;
  --board-tx:  #FFFFFF;
  --dir-bg:    #2E7D32;
  --dir-tx:    #FFFFFF;
  --l2-bg:     #1B5E20;
  --l2-bd:     #666666;
  --l2-tx:     #FFFFFF;
  --l2-sub:    #DCEDC8;
  --adv-bg:    #1B5E20;
  --adv-bd:    #666666;
  --adv-tx:    #FFFFFF;
  --staff-bg:  #F5F0DC;
  --staff-bd:  #666666;
  --staff-tx:  #3D3000;
  --dh-g:      #558B2F;
  --dh-t:      #2E7D32;
  --dh-tx:     #FFFFFF;
  --unit-g-bg: #F1F8E9;
  --unit-g-bd: #666666;
  --unit-g-tx: #1B5E20;
  --unit-t-bg: #E0F2F1;
  --unit-t-bd: #666666;
  --unit-t-tx: #004D40;
  --line:      #666666;
  --line-dash: #999999;
  --fg:        #1A1A1A;

  background: var(--bg);
  color: var(--fg);
  font-family: 'IBM Plex Sans Thai', sans-serif;
  position: relative;
  border-radius: 8px;
  padding-bottom: 16px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hrdi-orgchart *,
.hrdi-orgchart *::before,
.hrdi-orgchart *::after { box-sizing: border-box; }

.hrdi-orgchart .page-header {
  text-align: center;
  padding: 16px 20px 10px;
}
.hrdi-orgchart .page-header h1 {
  font-size: 16px !important; /* zip 14 + ~15% */
  font-weight: 600;
  color: var(--fg);
  opacity: 0.75;
  letter-spacing: 0.02em;
}

.hrdi-orgchart .scroll-wrap {
  overflow: hidden;
  width: 100%;
  display: block;
  padding: 0 max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  box-sizing: border-box;
}

.hrdi-orgchart .chart-scale-wrap {
  width: 100%;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.hrdi-orgchart .chart {
  /*
   * Fixed design width; JS scales the whole chart to fit the container.
   * Advisor clearance via asymmetric padding (optical center).
   */
  width: 1200px;
  min-width: 1200px;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: relative;
  font-size: 16px !important;
  gap: 0 !important;
  transform-origin: top center;
  transition: none !important;
  padding-left: 16px;
  padding-right: 106px;
  box-sizing: border-box;
}

/* Hidden until JS has applied fit-to-width (avoids a zoom-in flash at 1200px) */
.hrdi-orgchart:not(.is-ready) {
  visibility: hidden;
}

.hrdi-orgchart .box,
.hrdi-orgchart .staff-box,
.hrdi-orgchart .adv-box,
.hrdi-orgchart .dept-header,
.hrdi-orgchart .unit-cell {
  position: relative;
  z-index: 3;
  box-sizing: border-box;
  flex-grow: 0;
  flex-shrink: 0;
  transform: none !important;
}

/* Clickable executive / board targets */
.hrdi-orgchart a.hrdi-oc-link {
  text-decoration: none !important;
  cursor: pointer;
  transition: filter 0.15s ease, box-shadow 0.15s ease, outline-color 0.15s ease;
}
.hrdi-orgchart a.hrdi-oc-link:hover,
.hrdi-orgchart a.hrdi-oc-link:focus {
  filter: brightness(1.08);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 0 0 4px rgba(46, 125, 50, 0.55);
  outline: none;
  text-decoration: none !important;
}
.hrdi-orgchart a.hrdi-oc-link:focus-visible {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9), 0 0 0 4px rgba(27, 94, 32, 0.75);
}

/* Site <a> styles force dark text — restore light text on dark boxes */
.hrdi-orgchart a.board-box,
.hrdi-orgchart a.board-box .main,
.hrdi-orgchart a.board-box .sub,
.hrdi-orgchart a.dir-box,
.hrdi-orgchart a.dir-box .main,
.hrdi-orgchart a.l2-box,
.hrdi-orgchart a.l2-box .main,
.hrdi-orgchart a.adv-box,
.hrdi-orgchart a.adv-box span,
.hrdi-orgchart a.dept-header,
.hrdi-orgchart a.dept-header .main,
.hrdi-orgchart a.dept-header .sub {
  color: #ffffff !important;
}
.hrdi-orgchart a.l2-box .sub {
  color: #DCEDC8 !important; /* --l2-sub */
}
.hrdi-orgchart a.staff-box {
  color: #3D3000 !important; /* cream staff box keeps dark text */
}
.hrdi-orgchart .box {
  border-radius: 8px;
  padding: 8px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  line-height: 1.35;
}
.hrdi-orgchart .box .main { font-weight: 700; }
.hrdi-orgchart .box .sub  { font-weight: 400; }

.hrdi-orgchart .board-box {
  background: var(--board-bg);
  color: var(--board-tx);
  width: 220px;
  min-width: 220px;
  max-width: 220px;
  font-size: 15px !important; /* zip 13px + ~15% */
  font-weight: 700;
}
.hrdi-orgchart .board-box .sub { font-size: 13px !important; } /* zip 11px + ~15% */

.hrdi-orgchart .dir-box {
  background: var(--dir-bg);
  color: var(--dir-tx);
  border: 1.5px solid rgba(255,255,255,0.4);
  width: 200px;
  min-width: 200px;
  max-width: 200px;
  font-size: 15px !important; /* zip 13px + ~15% */
  font-weight: 700;
  border-radius: 10px;
  /* Match height of staff boxes (กลุ่มกฎหมาย / หน่วยตรวจสอบภายใน) */
  min-height: 42px;
  justify-content: center;
  box-sizing: border-box;
}
.hrdi-orgchart .staff-box {
  background: var(--staff-bg);
  border: 1.5px solid var(--staff-bd);
  color: var(--staff-tx);
  font-size: 13px !important; /* zip 11px + ~15% */
  font-weight: 600;
  border-radius: 6px;
  padding: 6px 10px;
  white-space: nowrap;
  width: auto;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.hrdi-orgchart .l2-box {
  background: var(--l2-bg);
  border: 1.5px solid var(--l2-bd);
  color: var(--l2-tx);
  width: 185px;
  min-width: 185px;
  max-width: 185px;
  font-size: 13px !important; /* zip 11.5px + ~15% */
  border-radius: 8px;
}
.hrdi-orgchart .l2-box .main { font-size: 13px !important; }
.hrdi-orgchart .l2-box .sub  { font-size: 12px !important; color: var(--l2-sub); } /* zip 10px + ~15% */

.hrdi-orgchart .adv-box {
  background: var(--adv-bg);
  border: 1.5px solid var(--adv-bd);
  color: var(--adv-tx);
  width: 150px;
  min-width: 150px;
  max-width: 150px;
  font-size: 13px !important; /* zip 11.5px + ~15% */
  border-radius: 8px;
  padding: 8px 12px;
  text-align: center;
  font-weight: 700;
}

.hrdi-orgchart .dept-header {
  border-radius: 7px;
  padding: 7px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--dh-tx);
  width: 100%;
}
.hrdi-orgchart .dept-header.green { background: var(--dh-g); }
.hrdi-orgchart .dept-header.teal  { background: var(--dh-t); }
.hrdi-orgchart .dept-header .main { font-size: 13px !important; font-weight: 700; line-height: 1.3; } /* zip 11.5 + ~15% */
.hrdi-orgchart .dept-header .sub  { font-size: 11px !important; opacity: 0.85; } /* zip 9.5 + ~15% */

.hrdi-orgchart .unit-cell {
  border-radius: 5px;
  padding: 5px 7px;
  font-size: 12px !important; /* zip 10.5 + ~15% */
  line-height: 1.4;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
}
.hrdi-orgchart .unit-cell.green {
  background: var(--unit-g-bg);
  border: 1px solid var(--unit-g-bd);
  color: var(--unit-g-tx);
}
.hrdi-orgchart .unit-cell.teal {
  background: var(--unit-t-bg);
  border: 1px solid var(--unit-t-bd);
  color: var(--unit-t-tx);
}

.hrdi-orgchart #rowBoard {
  display: flex;
  justify-content: center;
  margin-bottom: 0;
}

.hrdi-orgchart #rowDir {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  position: relative;
}
.hrdi-orgchart #rowDir .staff-wrap-l {
  display: flex;
  align-items: center;
  flex: 1;
  justify-content: flex-end;
}
.hrdi-orgchart #rowDir .staff-wrap-r {
  display: flex;
  align-items: center;
  flex: 1;
  justify-content: flex-start;
}
.hrdi-orgchart .spacer-h { min-width: 20px; max-width: 50px; flex: 1; }

.hrdi-orgchart #rowL2 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
  padding: 0 20px;
  gap: 5px;
  align-items: end;
  position: relative;
}
.hrdi-orgchart .l2-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hrdi-orgchart #l2Adv {
  position: absolute;
  right: 85px;
  top: 0;
  transform: translateX(calc(100% + 5px));
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hrdi-orgchart #colWrap {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
  column-gap: 16px;
  row-gap: 5px;
  padding: 0 20px;
  align-items: flex-start;
  margin-top: 0;
}
.hrdi-orgchart .dept-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.hrdi-orgchart .dept-header + .unit-cell {
  margin-top: 20px;
}

.hrdi-orgchart .conn-space {
  width: 100%;
  flex: 0 0 auto;
  margin: 0 !important;
  padding: 0 !important;
  border: 0;
  pointer-events: none;
  overflow: hidden;
}
/* Fixed zip connector gaps — never changed by JS */
.hrdi-orgchart .conn-space--bd { height: 20px; min-height: 20px; max-height: 20px; }
.hrdi-orgchart .conn-space--dl { height: 52px; min-height: 52px; max-height: 52px; }
.hrdi-orgchart .conn-space--ld { height: 46px; min-height: 46px; max-height: 46px; }

.hrdi-orgchart .conn-main {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 2;
}

/* Floating meeting resolution note — bottom-left, no layout shift */
.hrdi-orgchart-note {
  position: absolute;
  left: 10px;
  bottom: 6px;
  z-index: 6;
  margin: 0;
  padding: 8px 4px 8px 14px;
  max-width: 250px;
  pointer-events: none;
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.55;
  letter-spacing: 0.015em;
  color: #3d3d3d;
  background: transparent;
}
.hrdi-orgchart-note::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 2px;
  border-radius: 1px;
  background: #2E7D32;
}

.hrdi-orgchart .footer {
  display: flex;
  justify-content: space-between;
  font-size: 12px !important; /* zip 10 + ~15% */
  color: var(--fg);
  opacity: 0.45;
  padding: 12px max(20px, env(safe-area-inset-left, 0px));
  margin-top: 10px;
}
