/* ==========================================================================
   SOVEREIGN ROSTER — COMPONENTS
   Buttons, Tags, Tables, Panels, Dropdowns, Modals, Empty States, Toolbars
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-height);
  padding: 0 var(--space-4);
  font-family: var(--font-body);
  font-size: var(--font-size-body);
  font-weight: 500;
  line-height: var(--control-height);
  text-decoration: none;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
  border: var(--border-hairline-width) solid transparent;
  border-radius: var(--radius-button);
  background-color: var(--surface);
  color: var(--text-primary);
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
  text-decoration: none;
  background-color: var(--fill-subtle);
}

.btn:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

.btn-sm {
  height: var(--control-height-sm);
  padding: 0 var(--space-2);
  font-size: var(--font-size-table);
  line-height: var(--control-height-sm);
}

.btn-lg {
  height: 40px;
  padding: 0 var(--space-5);
  font-size: 15px;
  line-height: 40px;
}

/* Primary Button */
.btn-primary {
  background-color: var(--blue-600);
  border-color: var(--blue-600);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--blue-800);
  border-color: var(--blue-800);
  color: #ffffff;
}
.btn-primary:active {
  background-color: var(--blue-900);
  border-color: var(--blue-900);
  color: #ffffff;
}

/* Secondary / Outline Button */
.btn-secondary,
.btn-outline,
.btn-default {
  background-color: var(--surface);
  border-color: var(--border-input);
  color: var(--text-secondary);
}
.btn-secondary:hover,
.btn-outline:hover,
.btn-default:hover {
  background-color: var(--fill-subtle);
  border-color: var(--border-hairline);
  color: var(--text-primary);
}

/* Danger Button (Outline per spec) */
.btn-danger {
  background-color: var(--surface);
  border-color: var(--status-danger-text);
  color: var(--status-danger-text);
}
.btn-danger:hover {
  background-color: var(--status-danger-bg);
  border-color: var(--status-danger-text);
  color: #8c1e1e;
}
.btn-danger:active {
  background-color: #f8cfcf;
  border-color: #8c1e1e;
  color: #8c1e1e;
}


/* Link Button */
.btn-link {
  background: none;
  border-color: transparent;
  color: var(--blue-600);
  padding: 0 var(--space-1);
}
.btn-link:hover {
  background: none;
  text-decoration: underline;
  color: var(--blue-800);
}

/* --------------------------------------------------------------------------
   2. Status Tags / Badges (Text on Tint, WCAG AA compliant)
   -------------------------------------------------------------------------- */
.tag,
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-body);
  font-size: var(--font-size-meta);
  font-weight: 600;
  line-height: 1.4;
  padding: 2px 6px;
  border-radius: var(--radius-tag);
  white-space: nowrap;
}

.tag-success,
.status-valid,
.status-active {
  background-color: var(--status-success-bg);
  color: var(--status-success-text);
}

.tag-warning,
.status-expiring {
  background-color: var(--status-warning-bg);
  color: var(--status-warning-text);
}

.tag-danger,
.status-expired,
.status-blocked,
.status-missing {
  background-color: var(--status-danger-bg);
  color: var(--status-danger-text);
}

.tag-info {
  background-color: var(--status-info-bg);
  color: var(--status-info-text);
}

.tag-neutral,
.status-inactive {
  background-color: var(--status-neutral-bg);
  color: var(--status-neutral-text);
}

/* Section Chip */
.chip-cat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-meta);
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--cat, var(--blue-600));
  background-color: color-mix(in srgb, var(--cat, var(--blue-600)) 12%, white);
}
.chip-cat.chip-extra {
  background-color: transparent;
  border: 1px dashed color-mix(in srgb, var(--cat, var(--blue-600)) 50%, white);
}

/* --------------------------------------------------------------------------
   3. Tables (Compact, 40px row height, hairline borders)
   -------------------------------------------------------------------------- */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: var(--border-hairline-width) solid var(--border-hairline);
  border-radius: var(--radius-panel);
  background: var(--surface);
}

table.table,
.table-dense {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-table);
  text-align: left;
}

table.table th,
.table-dense th {
  height: 36px;
  padding: var(--space-1) var(--space-3);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background-color: #eef2f8;
  border-bottom: var(--border-hairline-width) solid var(--border-hairline);
  white-space: nowrap;
}

table.table td,
.table-dense td {
  height: var(--table-row-height);
  padding: var(--space-1) var(--space-3);
  vertical-align: middle;
  border-bottom: var(--border-hairline-width) solid var(--border-hairline);
  color: var(--text-primary);
}

table.table tr:last-child td,
.table-dense tr:last-child td {
  border-bottom: 0;
}

table.table tbody tr:hover,
.table-dense tbody tr:hover {
  background-color: var(--blue-50);
}

/* Numeric columns right-aligned with tabular figures */
table.table td.num,
table.table th.num,
table.table td.text-end,
table.table th.text-end {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Long text truncated with tooltip */
.cell-truncate {
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  vertical-align: middle;
}

.loading-text {
  font-size: var(--font-size-meta);
  color: var(--text-muted);
  font-style: italic;
}


/* --------------------------------------------------------------------------
   4. Panels & Cards (Flat, 4px radius, 1px border)
   -------------------------------------------------------------------------- */
.panel,
.card {
  background: var(--surface);
  border: var(--border-hairline-width) solid var(--border-hairline);
  border-radius: var(--radius-panel);
  box-shadow: none;
  margin-bottom: var(--space-4);
  position: relative;
}

.panel-header,
.card-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-hairline-width) solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--surface);
  border-radius: var(--radius-panel) var(--radius-panel) 0 0;
}

.panel-title,
.card-title {
  font-family: var(--font-display);
  font-size: var(--font-size-card);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.panel-body,
.card-body {
  padding: var(--space-4);
}

.panel-footer,
.card-footer {
  padding: var(--space-3) var(--space-4);
  border-top: var(--border-hairline-width) solid var(--border-hairline);
  background-color: var(--fill-subtle);
  border-radius: 0 0 var(--radius-panel) var(--radius-panel);
}

/* --------------------------------------------------------------------------
   5. Stat Tiles (KPI strip)
   -------------------------------------------------------------------------- */
.stat-tile {
  background: var(--surface);
  border: var(--border-hairline-width) solid var(--border-hairline);
  border-radius: var(--radius-panel);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
}

.stat-tile-label {
  font-size: var(--font-size-label);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}

.stat-tile-num,
.stat-num,
.kpi-num {
  font-family: var(--font-display);
  font-size: var(--font-size-kpi);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-tile-sub {
  font-size: var(--font-size-meta);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* --------------------------------------------------------------------------
   6. Table Toolbar & Bulk Bar
   -------------------------------------------------------------------------- */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: var(--border-hairline-width) solid var(--border-hairline);
  border-bottom: 0;
  border-radius: var(--radius-panel) var(--radius-panel) 0 0;
  flex-wrap: wrap;
}

.bulkbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: var(--blue-50);
  border: var(--border-hairline-width) solid var(--blue-100);
  border-radius: var(--radius-panel);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   7. Empty States
   -------------------------------------------------------------------------- */
.empty-state,
.empty-hint {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--text-muted);
}

.empty-state-icon,
.empty-hint i {
  font-size: 32px;
  color: var(--border-input);
  margin-bottom: var(--space-2);
  display: block;
}

.empty-state-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.empty-state-description {
  font-size: var(--font-size-body);
  max-width: 44ch;
  margin: 0 auto var(--space-3);
}

/* --------------------------------------------------------------------------
   8. Dropdowns & Modals (Only places with subtle elevation)
   -------------------------------------------------------------------------- */
.dropdown-menu {
  background: var(--surface);
  border: var(--border-hairline-width) solid var(--border-hairline);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-dropdown);
  padding: var(--space-1) 0;
  min-width: 180px;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-body);
  color: var(--text-primary);
  text-decoration: none;
}
.dropdown-item:hover {
  background-color: var(--fill-subtle);
  color: var(--blue-600);
}

.modal-content {
  background: var(--surface);
  border: var(--border-hairline-width) solid var(--border-hairline);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}

.modal-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-hairline-width) solid var(--border-hairline);
  background-color: var(--surface);
}

.modal-body {
  padding: var(--space-4);
}

.modal-footer {
  padding: var(--space-3) var(--space-4);
  border-top: var(--border-hairline-width) solid var(--border-hairline);
  background-color: var(--fill-subtle);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}
