/* ═══════════════════════════════════════════════════════════════
   STAFF DIRECTORY PANEL
   Card grid, avatars, search, filters, modal
   ═══════════════════════════════════════════════════════════════ */

/* ─── Stats Bar ─── */
.sd-stats-bar {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}
.sd-stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  flex: 1;
  min-width: 140px;
}
.sd-stat-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-1);
}
.sd-stat-value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

/* ─── Controls Row ─── */
.sd-controls {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}
.sd-search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}
.sd-search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: var(--text-sm);
  pointer-events: none;
}
.sd-search {
  width: 100%;
  padding: var(--space-2) var(--space-4) var(--space-2) calc(var(--space-3) + 20px);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  transition: border-color var(--duration-normal) var(--ease-default);
}
.sd-search:focus {
  outline: none;
  border-color: var(--border-focus);
}
.sd-search::placeholder {
  color: var(--text-muted);
}

/* ─── Filter Chips ─── */
.sd-filters {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}
.sd-chip {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
  white-space: nowrap;
}
.sd-chip:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background: var(--bg-hover);
}
.sd-chip.active {
  background: var(--accent-muted);
  color: var(--accent-text);
  border-color: var(--accent);
}
.sd-chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.08);
  font-size: 0.65rem;
  margin-left: var(--space-1);
}
.sd-chip.active .sd-chip-count {
  background: rgba(16,163,127,0.3);
}

/* ─── Card Grid ─── */
.sd-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}
@media (max-width: 1400px) { .sd-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1000px) { .sd-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .sd-grid { grid-template-columns: 1fr; } }

/* ─── Staff Card ─── */
.sd-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: all var(--duration-normal) var(--ease-default);
  position: relative;
}
.sd-card:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-md);
}
.sd-card-top {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

/* ─── Avatar ─── */
.sd-avatar {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
/* Department colors */
.sd-avatar.dept-executive    { background: linear-gradient(135deg, #d4a017, #b8860b); }
.sd-avatar.dept-operations   { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.sd-avatar.dept-engineering  { background: linear-gradient(135deg, #22c55e, #16a34a); }
.sd-avatar.dept-marketing    { background: linear-gradient(135deg, #a855f7, #9333ea); }
.sd-avatar.dept-finance      { background: linear-gradient(135deg, #f59e0b, #d97706); }
.sd-avatar.dept-compliance   { background: linear-gradient(135deg, #ef4444, #dc2626); }
.sd-avatar.dept-hr           { background: linear-gradient(135deg, #ec4899, #db2777); }
.sd-avatar.dept-sales        { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.sd-avatar.dept-unknown      { background: linear-gradient(135deg, #737373, #525252); }

/* ─── Card Info ─── */
.sd-card-info { flex: 1; min-width: 0; }
.sd-name {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sd-role {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}
.sd-dept-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 4px;
}
.sd-dept-badge.executive    { background: rgba(212,160,23,0.15); color: #d4a017; }
.sd-dept-badge.operations   { background: var(--info-muted); color: var(--info); }
.sd-dept-badge.engineering  { background: var(--success-muted); color: var(--success); }
.sd-dept-badge.marketing    { background: var(--purple-muted); color: var(--purple); }
.sd-dept-badge.finance      { background: var(--warning-muted); color: var(--warning); }
.sd-dept-badge.compliance   { background: var(--error-muted); color: var(--error); }
.sd-dept-badge.hr           { background: rgba(236,72,153,0.12); color: #ec4899; }
.sd-dept-badge.sales        { background: rgba(6,182,212,0.12); color: #06b6d4; }

/* ─── Card Detail Rows ─── */
.sd-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.sd-detail-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.sd-detail-row .sd-detail-icon {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  font-size: var(--text-xs);
}
.sd-detail-row a {
  color: var(--accent-text);
  text-decoration: none;
  transition: color var(--duration-fast);
}
.sd-detail-row a:hover {
  color: var(--accent);
  text-decoration: underline;
}
.sd-note {
  font-size: var(--text-xs);
  color: var(--warning);
  background: var(--warning-muted);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  margin-top: var(--space-2);
}

/* ─── Card Actions ─── */
.sd-card-actions {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  display: flex;
  gap: var(--space-1);
  opacity: 0;
  transition: opacity var(--duration-normal);
}
.sd-card:hover .sd-card-actions {
  opacity: 1;
}
.sd-card-action-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  transition: all var(--duration-fast);
}
.sd-card-action-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.sd-card-action-btn.delete:hover {
  background: var(--error-muted);
  border-color: var(--error);
  color: var(--error);
}

/* ─── Modal ─── */
.sd-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.sd-modal-overlay.open {
  display: flex;
}
.sd-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
}
.sd-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}
.sd-modal-header h3 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}
.sd-modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: var(--text-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast);
}
.sd-modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.sd-modal-body {
  padding: var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.sd-field label {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-1);
}
.sd-field input,
.sd-field select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  transition: border-color var(--duration-normal);
}
.sd-field input:focus,
.sd-field select:focus {
  outline: none;
  border-color: var(--border-focus);
}
.sd-field input::placeholder {
  color: var(--text-muted);
}
.sd-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
}

/* ─── Loading / Error / Empty ─── */
.sd-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-16) 0;
  color: var(--text-secondary);
  font-size: var(--text-sm);
}
.sd-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: sd-spin 0.8s linear infinite;
}
@keyframes sd-spin { to { transform: rotate(360deg); } }

.sd-error {
  text-align: center;
  padding: var(--space-12) 0;
}
.sd-error-icon { font-size: var(--text-3xl); margin-bottom: var(--space-3); }
.sd-error-msg { color: var(--text-secondary); font-size: var(--text-sm); margin-bottom: var(--space-4); }

.sd-empty {
  text-align: center;
  padding: var(--space-12) 0;
  color: var(--text-tertiary);
}
.sd-empty-icon { font-size: 3rem; margin-bottom: var(--space-3); }
.sd-empty-text { font-size: var(--text-sm); }
