/* =============================================
   Shared Components — Buttons, Badges, Modal, Toast
   ============================================= */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition), transform 0.1s, box-shadow var(--transition);
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }

.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-hover); box-shadow: var(--shadow-md); }

.btn-success { background: var(--c-success); color: #fff; }
.btn-success:hover { background: #15803d; }

.btn-warning { background: var(--c-warning); color: #fff; }
.btn-warning:hover { background: #b45309; }

.btn-danger { background: var(--c-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-outline {
  background: transparent;
  border: 2px solid var(--c-primary);
  color: var(--c-primary);
}
.btn-outline:hover { background: var(--c-primary-light); }

.btn-ghost { background: transparent; color: var(--c-text-secondary); }
.btn-ghost:hover { background: var(--c-bg); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.7rem 2rem; font-size: 1rem; }

.btn-close {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--c-text-secondary);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}
.btn-close:hover { background: var(--c-bg); color: var(--c-text); }
.btn-close:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-submitted { background: var(--c-info-light); color: #0e7490; }
.badge-in-review { background: var(--c-warning-light); color: #92400e; }
.badge-approved { background: var(--c-success-light); color: #166534; }
.badge-qualtrics { background: #e0e7ff; color: #3730a3; }
.badge-fulfilled { background: #f0fdf4; color: #14532d; border: 1px solid #86efac; }
.badge-denied { background: var(--c-danger-light); color: #991b1b; border: 1px solid #fca5a5; }

.badge-low { background: #f0fdf4; color: #166534; }
.badge-medium { background: var(--c-warning-light); color: #92400e; }
.badge-high { background: #fed7aa; color: #9a3412; }
.badge-urgent { background: var(--c-danger-light); color: #991b1b; }

.badge-in-area { background: var(--c-success-light); color: #166534; }
.badge-out-of-area { background: var(--c-danger-light); color: #991b1b; }
.badge-review-needed { background: var(--c-warning-light); color: #92400e; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(2px);
}
.modal-overlay.visible {
  display: flex;
}
.modal {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--c-border);
}
.modal-body { padding: 1.25rem; font-size: 0.9rem; }
.modal-footer {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--c-border);
}

/* ---------- Staff Assignment Box (detail panel) ---------- */
.staff-assign-box {
  background: var(--c-bg);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.staff-assign-box.assigned {
  border-color: var(--c-success);
  background: var(--c-success-light);
}
.staff-assign-box.no-match {
  align-items: flex-start;
}
.sab-ai-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-primary);
}
.sab-match-row, .sab-assigned-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.sab-avatar {
  width: 34px !important;
  height: 34px !important;
  font-size: 0.72rem !important;
  flex-shrink: 0;
}
.sab-reason {
  font-size: 0.77rem;
  color: var(--c-text-secondary);
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 0.3rem 0.55rem;
  line-height: 1.4;
}
.sab-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ---------- Chart Hover Tooltip ---------- */
.chart-hover-tooltip {
  position: fixed;
  z-index: 300;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.65rem 0.85rem;
  font-size: 0.82rem;
  min-width: 190px;
  max-width: 260px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.chart-hover-tooltip.visible { opacity: 1; }
.cht-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.25rem;
}
.cht-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cht-label { font-weight: 600; color: var(--c-text); }
.cht-count { color: var(--c-text-secondary); margin-bottom: 0.4rem; font-size: 0.78rem; }
.cht-cases { border-top: 1px solid var(--c-border); padding-top: 0.35rem; }
.cht-case {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--c-text);
  line-height: 1.6;
}
.cht-more { color: var(--c-text-secondary); font-style: italic; margin-top: 0.15rem; }

/* ---------- Chart Drilldown Popup ---------- */
.chart-drilldown-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(2px);
}
.chart-drilldown-overlay.visible {
  display: flex;
}
.chart-drilldown {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  width: 92%;
  max-width: 720px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}
.chart-drilldown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}
.chart-drilldown-header h3 { margin: 0; font-size: 1rem; }
.chart-drilldown-body {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  font-size: 0.875rem;
}
.drilldown-table {
  width: 100%;
  border-collapse: collapse;
}
.drilldown-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--c-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
.drilldown-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--c-border-light, #f1f5f9);
  vertical-align: middle;
}
.drilldown-table tbody tr:last-child td { border-bottom: none; }
.drilldown-table tbody tr:hover { background: var(--c-bg); }

/* Timeline detail modal layout */
.td-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1.25rem;
}
.td-section { margin-bottom: 0.25rem; }
.td-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-text-secondary);
  margin-bottom: 0.4rem;
}
.td-row {
  display: flex;
  gap: 0.5rem;
  font-size: 0.83rem;
  line-height: 1.6;
}
.td-label {
  color: var(--c-text-secondary);
  min-width: 80px;
  flex-shrink: 0;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--c-text);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  z-index: 300;
  animation: toastIn 0.3s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
