/* ================================================================
   Kindo Sandbox Manager — Component Library (Sprint 1 Consolidation)
   Standardized modal, form, card, toast, skeleton, breadcrumb patterns.
   ================================================================ */

/* ── Modals (standardized) ─────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay[style*="display: flex"],
.modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.modal,
.modal-dialog,
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg, 12px);
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 6px;
  transition: background var(--transition), color var(--transition);
  line-height: 1;
}

.modal-close:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.modal-close:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

.modal-body {
  padding: 20px 24px;
}

.modal-footer,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border-color);
}

.modal-dialog.modal-danger .modal-header {
  border-bottom-color: rgba(232, 98, 10, 0.25);
}

.modal-dialog.modal-danger .modal-header h3 {
  color: var(--brand-danger);
}

/* ── Forms (unified .form-control) ─────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control,
.form-input,
.filter-select,
.search-input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  font-size: 0.875rem;
  font-family: var(--font-family);
  color: var(--text-primary);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus,
.form-input:focus,
.filter-select:focus,
.search-input:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(99, 32, 232, 0.15);
}

.form-control::placeholder,
.form-input::placeholder,
.search-input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

textarea.form-control,
textarea.form-input {
  resize: vertical;
  min-height: 72px;
}

select.form-control,
select.filter-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236d6888' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  color: var(--brand-danger);
  font-size: 0.85rem;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: rgba(232, 98, 10, 0.08);
  border: 1px solid rgba(232, 98, 10, 0.2);
  margin-bottom: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-label-with-tooltip {
  display: flex;
  align-items: center;
  gap: 6px;
}

.env-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(99, 32, 232, 0.12);
  color: var(--brand-primary);
  vertical-align: middle;
  margin-left: 4px;
}

.required {
  color: var(--brand-danger);
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

/* ── Cards (unified) ───────────────────────────────────────── */
.card,
.panel,
.content-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
  transition: border-color var(--transition);
}

.card:hover,
.panel:hover {
  border-color: var(--border-light);
}

.card-header,
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.card-header h3,
.panel-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body,
.panel-body {
  padding: 20px;
}

.card-danger {
  border-color: rgba(232, 98, 10, 0.3);
}

.card-danger .card-header {
  background: rgba(232, 98, 10, 0.05);
}

/* ── Toast Notifications ───────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 400px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastSlideIn 0.3s ease;
  min-width: 280px;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.toast.toast-leaving {
  animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.toast-body {
  flex: 1;
  min-width: 0;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
  border-radius: 4px;
  transition: color var(--transition);
}

.toast-close:hover { color: var(--text-primary); }

.toast-success { border-left: 3px solid var(--status-green); }
.toast-success .toast-icon { color: var(--status-green); }

.toast-error { border-left: 3px solid var(--brand-danger); }
.toast-error .toast-icon { color: var(--brand-danger); }

.toast-warning { border-left: 3px solid var(--status-yellow); }
.toast-warning .toast-icon { color: var(--status-yellow); }

.toast-info { border-left: 3px solid var(--brand-primary); }
.toast-info .toast-icon { color: var(--brand-primary); }

/* ── Skeleton Loaders ──────────────────────────────────────── */
@keyframes skeletonShimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg,
    var(--bg-surface-hover) 25%,
    var(--border-light) 50%,
    var(--bg-surface-hover) 75%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius);
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  border-radius: 4px;
}

.skeleton-text.w-75 { width: 75%; }
.skeleton-text.w-50 { width: 50%; }
.skeleton-text.w-25 { width: 25%; }

.skeleton-row {
  height: 44px;
  margin-bottom: 6px;
}

.skeleton-row-wrap td {
  padding: 4px 0;
}

.skeleton-card {
  height: 120px;
  margin-bottom: 12px;
}

.skeleton-stat {
  height: 72px;
  border-radius: var(--radius);
}

/* Skeleton loading state wrapper */
.is-loading .data-content {
  display: none;
}

.is-loading .skeleton-content {
  display: block;
}

.skeleton-content {
  display: none;
}

/* ── Breadcrumbs ───────────────────────────────────────────── */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.breadcrumbs a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition);
}

.breadcrumbs a:hover {
  color: var(--brand-primary);
  text-decoration: underline;
}

.bc-sep {
  color: var(--text-muted);
  opacity: 0.5;
  user-select: none;
}

.bc-current {
  color: var(--text-primary);
  font-weight: 500;
}

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.4;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-success, .badge-active, .badge-running, .badge-ok, .badge-ready, .badge-available, .badge-healthy {
  background: rgba(34, 197, 94, 0.12);
  color: var(--status-green);
}
.badge-success .badge-dot, .badge-active .badge-dot, .badge-running .badge-dot, .badge-ok .badge-dot, .badge-ready .badge-dot, .badge-available .badge-dot, .badge-healthy .badge-dot {
  background: var(--status-green);
}

.badge-warning, .badge-pending, .badge-starting, .badge-stopping, .badge-initializing, .badge-building {
  background: rgba(251, 191, 36, 0.12);
  color: var(--status-yellow);
}
.badge-warning .badge-dot, .badge-pending .badge-dot, .badge-starting .badge-dot, .badge-stopping .badge-dot, .badge-initializing .badge-dot, .badge-building .badge-dot {
  background: var(--status-yellow);
}

.badge-danger, .badge-error, .badge-terminated, .badge-revoked, .badge-failed, .badge-unhealthy {
  background: rgba(248, 113, 113, 0.12);
  color: var(--status-red);
}
.badge-danger .badge-dot, .badge-error .badge-dot, .badge-terminated .badge-dot, .badge-revoked .badge-dot, .badge-failed .badge-dot, .badge-unhealthy .badge-dot {
  background: var(--status-red);
}

.badge-info, .badge-secondary {
  background: rgba(99, 32, 232, 0.1);
  color: var(--brand-primary-light, #7b3ff2);
}
.badge-info .badge-dot, .badge-secondary .badge-dot {
  background: var(--brand-primary-light, #7b3ff2);
}

.badge-admin {
  background: rgba(99, 32, 232, 0.12);
  color: var(--brand-primary);
}

.badge-operator {
  background: rgba(245, 166, 35, 0.12);
  color: var(--brand-accent);
}

.badge-viewer {
  background: rgba(107, 143, 168, 0.15);
  color: var(--text-secondary);
}

/* ── Sortable Table Headers ────────────────────────────────── */
.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 24px;
  transition: color var(--transition);
}

.data-table th.sortable:hover {
  color: var(--text-primary);
}

.sort-indicator {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  opacity: 0.3;
}

.sort-indicator::after {
  content: "\2195";
}

th.sorted-asc .sort-indicator { opacity: 1; }
th.sorted-asc .sort-indicator::after { content: "\2191"; }

th.sorted-desc .sort-indicator { opacity: 1; }
th.sorted-desc .sort-indicator::after { content: "\2193"; }

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs-strip {
  display: flex;
  border-bottom: 2px solid var(--border-color);
  gap: 0;
  margin-bottom: 16px;
}

.tab-btn {
  padding: 10px 18px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ── Bulk Actions Bar ──────────────────────────────────────── */
.bulk-action-bar {
  position: fixed;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-lg);
  z-index: 500;
  transition: bottom 0.3s ease;
  font-size: 0.85rem;
}

.bulk-action-bar.visible {
  bottom: 24px;
}

.bulk-count {
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state-desc {
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.empty-state-sm {
  padding: 24px 16px;
}

.loading-state {
  text-align: center;
  padding: 32px 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Detail Grid ───────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.detail-value {
  font-size: 0.9rem;
  color: var(--text-primary);
  word-break: break-word;
}

.detail-description {
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ── Key-specific components ───────────────────────────────── */
.key-display-box {
  margin: 16px 0;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
}

.key-display-box label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.key-display-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.key-display-value {
  flex: 1;
  padding: 8px 12px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  word-break: break-all;
  user-select: all;
}

.key-info-box,
.key-warning-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.key-info-box {
  background: rgba(99, 32, 232, 0.06);
  border: 1px solid rgba(99, 32, 232, 0.15);
  color: var(--text-secondary);
}

.key-warning-box {
  background: rgba(245, 166, 35, 0.08);
  border: 1px solid rgba(245, 166, 35, 0.2);
  color: var(--text-secondary);
}

.key-warning-box svg { color: var(--brand-accent); flex-shrink: 0; margin-top: 2px; }
.key-info-box svg { color: var(--brand-primary); flex-shrink: 0; margin-top: 2px; }

.key-name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.key-icon { color: var(--text-muted); flex-shrink: 0; }

.key-prefix-code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  padding: 2px 8px;
  background: var(--bg-surface);
  border-radius: 4px;
  color: var(--text-secondary);
}

.key-created-success {
  text-align: center;
  padding: 16px 0;
}

.key-created-success svg { margin-bottom: 8px; }
.key-created-success h4 { font-size: 1rem; margin: 0 0 4px; color: var(--status-green); }
.key-created-name { color: var(--text-muted); font-size: 0.85rem; }

/* ── Config list ───────────────────────────────────────────── */
.config-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.config-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.config-list li:last-child { border-bottom: none; }

.config-list code {
  background: var(--bg-surface);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--brand-primary-light, #7b3ff2);
}

/* ── RBAC Grid ─────────────────────────────────────────────── */
.rbac-roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.rbac-role-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--bg-surface);
}

.rbac-role-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.rbac-perm-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.rbac-perm-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.rbac-perm-tag {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-surface-hover);
  color: var(--text-secondary);
}

/* ── AMI Catalog ───────────────────────────────────────────── */
.ami-catalog-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ami-catalog-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--bg-surface);
}

/* ── Page Toolbar ──────────────────────────────────────────── */
.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.page-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 16px;
  gap: 8px;
}

/* ── Settings ──────────────────────────────────────────────── */
.settings-page {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.settings-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.settings-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

.settings-success {
  color: var(--status-green);
  font-size: 0.85rem;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.2);
  margin-top: 12px;
}

.settings-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 16px;
}

.modal-error {
  color: var(--brand-danger);
  font-size: 0.85rem;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: rgba(232, 98, 10, 0.08);
  border: 1px solid rgba(232, 98, 10, 0.2);
  margin-top: 12px;
}

/* ── Health Check ──────────────────────────────────────────── */
.health-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.health-healthy, .health-ok { background: rgba(34, 197, 94, 0.12); color: var(--status-green); }
.health-warning { background: rgba(251, 191, 36, 0.12); color: var(--status-yellow); }
.health-error, .health-unhealthy { background: rgba(248, 113, 113, 0.12); color: var(--status-red); }

.health-checks {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.health-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
}

.health-check-ok .health-icon { color: var(--status-green); }
.health-check-warning .health-icon { color: var(--status-yellow); }
.health-check-error .health-icon { color: var(--status-red); }

.health-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.health-name {
  font-weight: 500;
  color: var(--text-primary);
  min-width: 120px;
}

.health-detail {
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
}

/* ── Inline Form ───────────────────────────────────────────── */
.inline-form {
  display: inline;
}

/* ── Status Badge (for data table cells) ───────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-running, .status-active, .status-available, .status-ready, .status-healthy {
  background: rgba(34, 197, 94, 0.12);
  color: var(--status-green);
}

.status-pending, .status-starting, .status-stopping, .status-initializing, .status-building {
  background: rgba(251, 191, 36, 0.12);
  color: var(--status-yellow);
}

.status-terminated, .status-error, .status-failed, .status-unhealthy, .status-revoked, .status-inactive {
  background: rgba(248, 113, 113, 0.12);
  color: var(--status-red);
}

.status-stopped, .status-shutting-down {
  background: rgba(109, 104, 136, 0.12);
  color: var(--status-gray);
}

/* ── Data Table Container ──────────────────────────────────── */
.data-table-container,
.table-container {
  overflow-x: auto;
  border-radius: var(--radius);
}

.table-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.table-empty svg { margin-bottom: 12px; }
.table-empty p { margin-bottom: 12px; }

/* ── Rule Warning ──────────────────────────────────────────── */
.rule-warning {
  background: rgba(232, 98, 10, 0.04);
}

.warning-icon {
  color: var(--brand-accent);
  font-size: 1rem;
  margin-right: 4px;
}

.rule-source {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
}

.rule-source:last-child { margin-bottom: 0; }

/* ── Text utilities ────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Spacing ───────────────────────────────────────────────── */
.mt-lg { margin-top: 24px; }

/* ── Keys page ─────────────────────────────────────────────── */
.keys-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.keys-stat {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.keys-stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
}

.keys-stat-active { color: var(--status-green); }
.keys-stat-revoked { color: var(--status-red); }

.keys-stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.keys-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.keys-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.keys-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.keys-summary {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.summary-count { font-weight: 500; }

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box .search-input {
  padding-left: 32px;
  width: 200px;
}

.filter-select {
  width: auto;
  min-width: 130px;
  padding: 10px 36px 10px 12px;
}

.revoked-label { opacity: 0.5; }

.date-cell { font-size: 0.825rem; }

/* ── Responsiveness ────────────────────────────────────────── */
@media (max-width: 768px) {
  .form-row { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .rbac-roles-grid { grid-template-columns: 1fr; }
  .keys-toolbar { flex-direction: column; align-items: stretch; }
  .keys-toolbar-left, .keys-toolbar-right { justify-content: stretch; }
  .modal, .modal-dialog, .modal-content { width: 95%; max-width: none; }
  .search-box .search-input { width: 100%; }
}

/* ================================================================
   Sprint 3: Data Table Enhancements
   Pagination controls, density toggle, column visibility, confirm modal
   ================================================================ */

/* ── Pagination Controls ───────────────────────────────────── */
.table-pagination-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  font-size: 0.825rem;
  gap: 12px;
  flex-wrap: wrap;
}

.pagination-left {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.pagination-center {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-per-page-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.pagination-per-page {
  appearance: none;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  padding: 4px 28px 4px 8px;
  font-size: 0.8rem;
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font-family);
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236d6888' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  outline: none;
  transition: border-color var(--transition);
}

.pagination-per-page:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 2px rgba(99, 32, 232, 0.12);
}

.pagination-pages {
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 0 8px;
  white-space: nowrap;
  min-width: 90px;
  text-align: center;
}

.btn-pagination {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-pagination:hover:not(:disabled) {
  background: var(--bg-surface-hover);
  border-color: var(--border-light);
  color: var(--text-primary);
}

.btn-pagination:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-pagination:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 1px;
}

/* ── Density Toggle ────────────────────────────────────────── */
.density-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 2px;
  background: var(--bg-surface);
}

.density-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.density-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

.density-btn.active {
  color: var(--brand-primary);
  background: rgba(99, 32, 232, 0.1);
}

.density-btn:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 1px;
}

/* Density variants */
.data-table.density-compact th {
  padding: 8px 12px;
  font-size: 10px;
}

.data-table.density-compact td {
  padding: 6px 12px;
  font-size: 12px;
}

.data-table.density-comfortable th {
  padding: 12px 16px;
}

.data-table.density-comfortable td {
  padding: 14px 16px;
}

.data-table.density-spacious th {
  padding: 16px 20px;
  font-size: 12px;
}

.data-table.density-spacious td {
  padding: 20px 20px;
  font-size: 14px;
}

/* ── Column Visibility ─────────────────────────────────────── */
.col-visibility-wrapper {
  position: relative;
  display: inline-block;
}

.col-visibility-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 8px 0;
  min-width: 180px;
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
}

.col-visibility-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 0.825rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition);
  white-space: nowrap;
}

.col-visibility-item:hover {
  background: var(--bg-surface-hover);
}

.col-visibility-item input[type="checkbox"] {
  accent-color: var(--brand-primary);
  width: 14px;
  height: 14px;
}

/* ── Confirm Modal Enhancements ────────────────────────────── */
.modal-sm {
  max-width: 420px;
}

.modal-header-danger {
  border-bottom-color: rgba(232, 98, 10, 0.25);
}

.modal-header-danger h3 {
  color: var(--brand-danger);
}

/* ── Row click cursor (for click-to-detail) ────────────────── */
.data-table.clickable-rows tbody tr {
  cursor: pointer;
}

.data-table.clickable-rows tbody tr:hover {
  background: var(--bg-surface-hover);
}

.data-table.clickable-rows tbody tr.selected-row {
  background: rgba(99, 32, 232, 0.06);
  border-left: 3px solid var(--brand-primary);
}

/* ── Hidden row utility ────────────────────────────────────── */
.search-hidden {
  display: none !important;
}

.pagination-hidden {
  display: none !important;
}

/* When pagination controls are present, adjust container bottom radius */
.table-container:has(+ .table-pagination-controls) {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* ── Responsive pagination ─────────────────────────────────── */
@media (max-width: 768px) {
  .table-pagination-controls {
    flex-direction: column;
    gap: 8px;
    padding: 8px 12px;
  }
  .pagination-center {
    order: -1;
  }
  .density-toggle {
    display: none;
  }
  .col-visibility-wrapper {
    display: none;
  }
}


/* ══════════════════════════════════════════════════════════════
   Sprint 5 — Component-level transitions
   ═════════════════════════════════════════════════════════════ */

/* ── Confirmation modal transition ──────────────────────────── */
.confirm-modal-overlay {
  transition: opacity 0.2s ease;
}
.confirm-modal-overlay .confirm-modal {
  transition: transform 0.2s ease;
}

/* ── Density toggle focus ───────────────────────────────────── */
.density-btn:focus-visible {
  outline: 2px solid var(--brand-primary, #6320e8);
  outline-offset: 2px;
}

/* ── Column visibility focus ────────────────────────────────── */
.col-vis-checkbox:focus-visible {
  outline: 2px solid var(--brand-primary, #6320e8);
  outline-offset: 2px;
}

/* ── Pagination button focus ────────────────────────────────── */
.page-btn:focus-visible {
  outline: 2px solid var(--brand-primary, #6320e8);
  outline-offset: 2px;
}
.rows-per-page:focus-visible {
  outline: 2px solid var(--brand-primary, #6320e8);
  outline-offset: 2px;
}

/* ── Toast animation refinement ─────────────────────────────── */
.toast-notification {
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* ── Skeleton loader pulse ──────────────────────────────────── */
.skeleton {
  transition: opacity 0.3s ease;
}
