/* ══════════════════════════════════════════════
   Department & Org Chart Styles
   ══════════════════════════════════════════════ */

/* ── View Toggle Tabs ── */
.dept-view-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 28px;
  border-bottom: 2px solid #e5e7eb;
}

.dept-view-toggle .toggle-btn {
  padding: 10px 24px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease;
}

.dept-view-toggle .toggle-btn:hover {
  color: #374151;
}

.dept-view-toggle .toggle-btn.active {
  color: #2563eb;
}

.dept-view-toggle .toggle-btn.active::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: #2563eb;
  border-radius: 2px 2px 0 0;
}

/* ── Cards View Grid ── */
.dept-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

/* ── Department Card ── */
.dept-card {
  background: #fff;
  border-radius: 10px;
  border-left: 4px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  padding: 20px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.dept-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1), 0 4px 10px rgba(0, 0, 0, 0.06);
}

.dept-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.dept-card-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: #111827;
}

.dept-card-header .expand-icon {
  font-size: 18px;
  color: #9ca3af;
  transition: transform 0.3s ease;
}

.dept-card.expanded .dept-card-header .expand-icon {
  transform: rotate(180deg);
}

.dept-card-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.dept-card-meta .meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #6b7280;
}

.dept-card-meta .meta-row .meta-icon {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.dept-card-meta .meta-row .meta-value {
  font-weight: 600;
  color: #374151;
}

/* ── Mini Team List ── */
.dept-mini-team {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid #f3f4f6;
}

.dept-mini-team .team-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  margin-bottom: 2px;
}

.dept-mini-team .team-member-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #4b5563;
}

.dept-mini-team .team-member-mini .avatar-initial {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.dept-mini-team .more-members {
  font-size: 12px;
  color: #9ca3af;
  font-style: italic;
  padding-left: 32px;
}

/* ── Expanded Full Member List ── */
.dept-expanded-members {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.3s ease;
  opacity: 0;
}

.dept-card.expanded .dept-expanded-members {
  max-height: 600px;
  opacity: 1;
}

.dept-expanded-members .full-team-list {
  padding-top: 14px;
  margin-top: 12px;
  border-top: 1px dashed #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dept-expanded-members .full-team-list .team-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  margin-bottom: 2px;
}

.dept-expanded-members .full-member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.dept-expanded-members .full-member-row .avatar-initial {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.dept-expanded-members .full-member-row .member-info {
  display: flex;
  flex-direction: column;
}

.dept-expanded-members .full-member-row .member-info .member-name {
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
}

.dept-expanded-members .full-member-row .member-info .member-role {
  font-size: 11px;
  color: #9ca3af;
}

.dept-expanded-members .full-member-row .member-status {
  margin-left: auto;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-weight: 600;
}

.dept-expanded-members .full-member-row .member-status.status-active {
  background: #d1fae5;
  color: #065f46;
}

.dept-expanded-members .full-member-row .member-status.status-on-leave {
  background: #fef3c7;
  color: #92400e;
}

.dept-expanded-members .full-member-row .member-status.status-inactive {
  background: #fee2e2;
  color: #991b1b;
}

/* ══════════════════════════════════════════════
   Org Chart View
   ══════════════════════════════════════════════ */
.org-chart-wrapper {
  overflow-x: auto;
  padding: 20px 0 40px;
}

.org-chart {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: max-content;
  padding: 0 40px;
}

/* ── Connector Lines ── */
.org-chart .org-level {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

/* Vertical line from CEO to department row */
.org-chart .org-connector-down {
  width: 2px;
  height: 32px;
  background: #d1d5db;
}

/* Horizontal connector bar spanning department heads */
.org-chart .org-connector-horizontal {
  height: 2px;
  background: #d1d5db;
  align-self: stretch;
  margin: 0 auto;
  position: relative;
}

/* ── Department Columns ── */
.org-dept-row {
  display: flex;
  justify-content: center;
  gap: 0;
  position: relative;
}

.org-dept-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  min-width: 160px;
  padding: 0 12px;
}

/* Vertical connector from horizontal bar to department head node */
.org-dept-col::before {
  content: "";
  width: 2px;
  height: 20px;
  background: #d1d5db;
}

/* ── Report Columns ── */
.org-reports-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 4px;
  position: relative;
}

/* Vertical line from dept head to first report */
.org-reports-group::before {
  content: "";
  width: 2px;
  height: 16px;
  background: #d1d5db;
}

.org-report-item {
  display: flex;
  align-items: center;
  position: relative;
  margin-top: 0;
}

/* Vertical + horizontal branch for each report */
.org-reports-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  position: relative;
  padding-left: 20px;
}

.org-reports-list::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 12px;
  width: 2px;
  background: #d1d5db;
}

.org-reports-list .org-report-node {
  position: relative;
  margin-top: 8px;
}

.org-reports-list .org-report-node::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 50%;
  width: 20px;
  height: 2px;
  background: #d1d5db;
}

/* ── Org Node Boxes ── */
.org-node {
  background: #fff;
  border-radius: 10px;
  padding: 12px 18px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
  text-align: center;
  position: relative;
  white-space: nowrap;
  border: 1px solid #f3f4f6;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.org-node:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}

.org-node.ceo-node {
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  color: #fff;
  padding: 16px 28px;
  border: none;
}

.org-node.ceo-node .org-node-name {
  color: #fff;
}

.org-node.ceo-node .org-node-role {
  color: rgba(255, 255, 255, 0.8);
}

.org-node .org-node-name {
  font-size: 13px;
  font-weight: 700;
  color: #111827;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.org-node .org-node-role {
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
}

.org-node .dept-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.org-node.ceo-node .dept-color-dot {
  background: rgba(255, 255, 255, 0.6);
}

.org-node.head-node {
  border-top: 3px solid #e5e7eb;
}

.org-node.report-node {
  padding: 8px 14px;
  font-size: 12px;
}

.org-node.report-node .org-node-name {
  font-size: 12px;
}

.org-node.report-node .org-node-role {
  font-size: 10px;
}

/* ── No Reports Placeholder ── */
.org-no-reports {
  font-size: 11px;
  color: #d1d5db;
  margin-top: 8px;
  font-style: italic;
}

/* ══════════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {
  .dept-cards-grid {
    grid-template-columns: 1fr;
  }

  .org-chart-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 20px 16px 40px;
  }

  .dept-view-toggle .toggle-btn {
    padding: 8px 16px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .dept-card {
    padding: 16px;
  }

  .dept-card-header h3 {
    font-size: 15px;
  }
}
