/* =========================================================================
   COMPANIES / ORGANIZATION DIRECTORY
   Tight, professional layout — matches the shadcn zinc palette from
   shadcn.css. No emoji noise, subtle stat pills, icon-only auxiliary
   actions in the delegate row.
   ========================================================================= */

/* ---------- KPI metric cards (top of the panel) ----------
   These fix a class-name mismatch: the HTML uses .metrics-grid,
   .metric-icon, .metric-data, .metric-hint — none of which have
   rules in shadcn.css. Without this block the four KPIs collapse
   into full-width stacked bands. Scoped to #companiesPanel so the
   Overview panel (which uses a different structure) is untouched. */
#companiesPanel .metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

#companiesPanel .metric-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border-radius: 10px;
  background-color: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.03);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  min-height: 118px;
}

#companiesPanel .metric-card:hover {
  border-color: hsl(240 5.9% 82%);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.06);
  transform: none;
}

#companiesPanel .metric-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#companiesPanel .metric-icon i[data-lucide] {
  width: 18px;
  height: 18px;
}

#companiesPanel .metric-data {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

#companiesPanel .metric-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  line-height: 1.3;
}

#companiesPanel .metric-value {
  font-family: 'Sora', var(--font-sans);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: hsl(var(--foreground));
  line-height: 1.1;
  overflow-wrap: anywhere;
}

#companiesPanel .metric-hint {
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  line-height: 1.3;
}

@media (max-width: 1024px) {
  #companiesPanel .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 520px) {
  #companiesPanel .metrics-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Toolbar tightening on the Companies panel ---------- */
#companiesPanel .shadcn-toolbar {
  padding: 12px 0 4px;
}

#companiesPanel .shadcn-toolbar .toolbar-left {
  gap: 8px !important;
}

#companiesPanel .shadcn-toolbar .search-input-wrapper {
  min-width: 200px !important;
  flex: 1 1 220px !important;
}

#companiesPanel .shadcn-toolbar .search-input-wrapper .shadcn-input {
  height: 34px;
  font-size: 0.83rem;
}

#companiesPanel #companySelectDropdown,
#companiesPanel #companySortSelect {
  height: 34px;
  font-size: 0.82rem;
  font-weight: 500 !important;
  min-width: 190px !important;
  max-width: 240px !important;
  padding: 4px 26px 4px 10px;
}

#companiesPanel .shadcn-segmented {
  height: 34px;
}

#companiesPanel .shadcn-segmented .segmented-btn {
  padding: 5px 12px;
  font-size: 0.78rem;
}

/* ---------- Company card ---------- */
.company-group-card {
  background-color: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.company-group-card:hover {
  border-color: hsl(240 5.9% 82%);
}

.company-group-card.expanded {
  border-color: hsl(240 5.9% 78%);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}

/* ---------- Header bar ---------- */
.company-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.12s ease;
}

.company-card-header:hover {
  background-color: hsl(240 4.8% 97.5%);
}

.company-group-card.expanded .company-card-header {
  background-color: hsl(240 4.8% 97.5%);
  border-bottom: 1px solid hsl(var(--border));
}

.company-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.company-icon-avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Sora', var(--font-sans);
  font-weight: 700;
  font-size: 0.92rem;
  color: hsl(var(--foreground));
  background-color: hsl(240 4.8% 93%);
  border: 1px solid hsl(var(--border));
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

.company-info-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.company-name-heading {
  font-size: 0.9rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  letter-spacing: -0.005em;
  line-height: 1.3;
  margin: 0;
  overflow-wrap: anywhere;
}

/* ---------- Stat pills (replace emoji badges) ---------- */
.company-badges-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.company-stat {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  line-height: 1.5;
  white-space: nowrap;
  letter-spacing: 0.005em;
}

.company-stat-total {
  color: hsl(240 5.9% 22%);
  background-color: hsl(240 4.8% 95%);
  border-color: hsl(var(--border));
  font-weight: 600;
}

.company-stat-approved {
  color: hsl(153 65% 25%);
  background-color: hsl(151 68% 95%);
  border-color: hsl(153 55% 82%);
}

.company-stat-pending {
  color: hsl(32 80% 32%);
  background-color: hsl(48 96% 94%);
  border-color: hsl(38 85% 80%);
}

.company-stat-rejected {
  color: hsl(0 65% 40%);
  background-color: hsl(0 85% 96%);
  border-color: hsl(0 70% 85%);
}

.company-stat-attended {
  color: hsl(198 75% 30%);
  background-color: hsl(198 90% 95%);
  border-color: hsl(198 70% 82%);
}

/* ---------- Header actions ---------- */
.company-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.company-card-actions .shadcn-btn {
  height: 30px;
  padding: 0 10px;
  font-size: 0.76rem;
  font-weight: 500;
  gap: 5px;
}

.company-card-actions .shadcn-btn i[data-lucide] {
  width: 13px !important;
  height: 13px !important;
}

.company-expand-chevron {
  transition: transform 0.2s ease;
}

.company-group-card.expanded .company-expand-chevron {
  transform: rotate(180deg);
}

/* ---------- Collapsible delegate table ---------- */
.company-people-container {
  display: none;
  padding: 8px 12px 12px;
  background-color: hsl(var(--card));
}

.company-group-card.expanded .company-people-container {
  display: block;
  animation: companyPanelReveal 0.18s ease;
}

@keyframes companyPanelReveal {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: translateY(0); }
}

.company-people-container .shadcn-table-wrapper {
  margin-top: 0 !important;
  overflow-x: auto;
  border-radius: 6px !important;
}

.company-people-container .shadcn-table {
  width: 100%;
  min-width: 640px;
  font-size: 0.82rem;
}

.company-people-container .shadcn-table th {
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  padding: 8px 10px;
}

.company-people-container .shadcn-table td {
  padding: 8px 10px;
  vertical-align: middle;
}

/* Tighten the delegate action cluster and demote QR/pass buttons to icon-only */
.company-people-container .shadcn-btn {
  height: 28px;
  padding: 0 8px;
  font-size: 0.74rem;
  gap: 4px;
}

.company-people-container .btn-copy-card-img,
.company-people-container .btn-copy-card-novip-img,
.company-people-container .btn-copy-qr-img,
.company-people-container .btn-open-qr-modal,
.company-people-container .btn-company-delegate-delete {
  width: 28px;
  padding: 0;
  justify-content: center;
}

.company-people-container .btn-copy-card-img span,
.company-people-container .btn-copy-card-novip-img span {
  display: none;
}

.company-people-container .shadcn-btn i[data-lucide] {
  width: 13px !important;
  height: 13px !important;
}

/* Attendee avatar in the delegate row — subtler than the top header one */
.company-people-container .attendee-avatar {
  width: 28px;
  height: 28px;
  font-size: 0.72rem;
  font-weight: 600;
  background-color: hsl(240 4.8% 94%);
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
}

.company-people-container .delivery-pill {
  font-size: 0.72rem;
  padding: 1px 6px;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .company-card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }

  .company-card-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .company-title-wrap {
    gap: 10px;
  }

  .company-icon-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
  }

  .company-name-heading {
    font-size: 0.88rem;
  }

  .company-people-container {
    padding: 6px 8px 10px;
  }

  #companiesPanel #companySelectDropdown,
  #companiesPanel #companySortSelect {
    max-width: none !important;
    flex: 1;
  }
}
