/* ================================================================
   ColorFlow Design System v1.0
   Enterprise component patterns for Walmart CSI Compass

   Prefix: cf-
   Dependencies: variables.css
   ================================================================ */

/* ── Extended Tokens (scoped to design-system) ── */
:root {
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.07);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius-xs: 2px;
  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --duration-fast: 120ms;
  --duration-normal: 200ms;
  --surface-0: #FFFFFF;
  --surface-1: #F9FAFB;
  --surface-2: #F4F4F4;
  --surface-3: #EEEEEE;
  --border-light: #E5E5E5;
  --border-default: #D0D0D0;
  --border-strong: #999999;
  --color-info: #4597C9;
  --color-info-bg: #E8F4FD;
  --color-success: #2D7A50;
  --color-success-light: #E6F5ED;
  --color-warning: #B8860B;
  --color-warning-light: #FFF8E1;
  --color-danger: #CC0000;
  --color-danger-light: #FFF0F0;
  --color-pending: #8B6914;
  --color-pending-bg: #FFF8DC;
}


/* ================================================================
   1. DATA TABLES
   ================================================================ */

.cf-table {
  position: relative;
  font-size: var(--font-size-base);
}

/* Toolbar — search, filters, info row above table */
.cf-table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  gap: 12px;
  flex-wrap: wrap;
}

.cf-table-search {
  position: relative;
}

.cf-table-search input {
  width: 200px;
  padding: 5px 8px 5px 26px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.cf-table-search input:focus {
  outline: none;
  border-color: var(--color-blue);
  box-shadow: 0 0 0 2px rgba(69,151,201,0.15);
}

.cf-table-search::before {
  content: "\2315";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  font-size: 13px;
  pointer-events: none;
}

.cf-table-info {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* Table container — handles overflow scroll on narrow screens */
.cf-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}

.cf-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-base);
}

/* Header */
.cf-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.cf-table thead th {
  padding: 8px 12px;
  background: var(--color-table-header-bg);
  color: var(--color-table-header-text);
  font-weight: 600;
  text-align: left;
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
  border-bottom: 2px solid #222;
  user-select: none;
}

/* Sortable columns */
.cf-sortable {
  cursor: pointer;
  position: relative;
  padding-right: 22px !important;
}

.cf-sortable::after {
  content: "\21C5";
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.35;
  font-size: 11px;
}

.cf-sortable:hover {
  background: #3d3d3d;
}

.cf-sortable:hover::after {
  opacity: 0.7;
}

.cf-sort-asc::after {
  content: "\2191";
  opacity: 1;
  color: var(--color-orange-light);
}

.cf-sort-desc::after {
  content: "\2193";
  opacity: 1;
  color: var(--color-orange-light);
}

/* Body rows */
.cf-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background-color 120ms ease;
}

.cf-table tbody tr:nth-child(odd) {
  background: var(--color-table-odd);
}

.cf-table tbody tr:nth-child(even) {
  background: var(--color-table-even);
}

.cf-table tbody tr:hover {
  background: var(--color-table-hover);
}

.cf-table tbody td {
  padding: 8px 12px;
  vertical-align: middle;
}

/* Row states */
.cf-table tbody tr.cf-row-selected {
  background: var(--color-highlight) !important;
}

.cf-table tbody tr.cf-row-danger {
  border-left: 3px solid var(--color-danger);
}

.cf-table tbody tr.cf-row-warning {
  border-left: 3px solid var(--color-warning);
}

/* Compact variant — tighter padding for dense data */
.cf-table-compact thead th {
  padding: 5px 8px;
  font-size: var(--font-size-xs);
}

.cf-table-compact tbody td {
  padding: 5px 8px;
}

/* Bordered variant — cell borders */
.cf-table-bordered td,
.cf-table-bordered th {
  border: 1px solid var(--border-light);
}

/* Cell utilities */
.cf-cell-num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.cf-cell-center {
  text-align: center;
}

.cf-cell-nowrap {
  white-space: nowrap;
}

.cf-cell-truncate {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cf-cell-actions {
  white-space: nowrap;
  text-align: center;
}

.cf-cell-actions a,
.cf-cell-actions button {
  margin: 0 2px;
  color: var(--color-blue);
  cursor: pointer;
}

.cf-cell-actions a:hover,
.cf-cell-actions button:hover {
  color: var(--color-blue-light);
}

/* Table footer — pagination + info */
.cf-table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  gap: 12px;
  flex-wrap: wrap;
}

/* Loading overlay for table */
.cf-table-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.7);
  z-index: 3;
}


/* ================================================================
   2. PAGINATION
   ================================================================ */

.cf-page {
  display: inline-flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
  user-select: none;
}

.cf-page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-default);
  background: var(--surface-0);
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  font-family: var(--font-family);
  text-decoration: none;
  cursor: pointer;
  line-height: 1;
  transition: background 150ms ease,
              color 150ms ease,
              border-color 150ms ease,
              box-shadow 150ms ease;
}

/* Connected bar — adjacent buttons share borders */
.cf-page-btn + .cf-page-btn {
  margin-left: -1px;
}

.cf-page-btn:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.cf-page-btn:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Only child (single page) */
.cf-page-btn:only-child {
  border-radius: var(--radius-sm);
}

.cf-page-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  z-index: 1;
  position: relative;
}

/* Active page */
.cf-page-active,
.cf-page-active:hover {
  background: var(--color-pagination);
  color: var(--color-white);
  border-color: var(--color-pagination);
  font-weight: 600;
  z-index: 2;
  position: relative;
  box-shadow: 0 1px 3px rgba(51, 102, 153, 0.25);
}

/* Disabled state */
.cf-page-disabled,
.cf-page-disabled:hover {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  background: var(--surface-1);
  color: var(--color-text-muted);
}

/* Ellipsis separator */
.cf-page-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  letter-spacing: 2px;
  border: 1px solid var(--border-default);
  background: var(--surface-0);
  margin-left: -1px;
  cursor: default;
}

/* First/Last & Prev/Next arrows */
.cf-page-first,
.cf-page-last,
.cf-page-prev,
.cf-page-next {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.5px;
}

.cf-page-first,
.cf-page-last {
  font-size: 14px;
  letter-spacing: 0;
}

/* Row info beside pagination */
.cf-page-info {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-left: 16px;
  white-space: nowrap;
}

/* Wrapper — pagination + info aligned horizontally */
.cf-page-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 0 4px;
}

/* Legacy CI4 Pager fallback — map Bootstrap-style .pagination to cf-page */
.pagination {
  display: inline-flex;
  align-items: center;
  gap: 0;
  list-style: none;
  padding: 0;
  margin: 0;
  user-select: none;
}

.pagination li a,
.pagination li span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-default);
  background: var(--surface-0);
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.pagination li + li a,
.pagination li + li span {
  margin-left: -1px;
}

.pagination li:first-child a,
.pagination li:first-child span {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.pagination li:last-child a,
.pagination li:last-child span {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.pagination li a:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  z-index: 1;
  position: relative;
}

.pagination li.active a,
.pagination li.active span {
  background: var(--color-pagination);
  color: var(--color-white);
  border-color: var(--color-pagination);
  font-weight: 600;
  z-index: 2;
  position: relative;
  box-shadow: 0 1px 3px rgba(51, 102, 153, 0.25);
}


/* Workflow Toolbar — pending counts, ARSL/HKSL range, export buttons */
.cf-workflow-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 10px 16px;
  margin-bottom: 4px;
  background: var(--surface-1);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
}

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

.cf-toolbar-right {
  margin-left: auto;
  gap: 6px;
}

/* Pending counts */
.cf-pending-counts {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  color: var(--color-text-secondary);
}

.cf-pending-total {
  color: var(--color-text-primary);
}

.cf-pending-sep {
  color: var(--border-strong);
}

.cf-pending-item {
  padding: 2px 8px;
  background: var(--surface-0);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* ARSL / HKSL range display */
.cf-toolbar-ranges {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.cf-range-label {
  font-weight: 600;
  color: var(--color-text-secondary);
}

.cf-range-value {
  font-family: var(--font-family-mono, monospace);
  font-size: 12px;
  padding: 1px 6px;
  background: var(--surface-0);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
}

.cf-range-sep {
  color: var(--border-strong);
  margin: 0 2px;
}

@media (max-width: 768px) {
  .cf-workflow-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .cf-toolbar-right {
    margin-left: 0;
    justify-content: flex-end;
  }
}


/* ================================================================
   3. DIALOG EXTENSIONS
   ================================================================ */

/* Size variants */
dialog.cf-dialog-sm {
  max-width: 380px;
}

dialog.cf-dialog-md {
  max-width: 520px;
}

dialog.cf-dialog-lg {
  max-width: 720px;
}

dialog.cf-dialog-full {
  max-width: 95vw;
  width: 95vw;
  max-height: 90vh;
}

/* Confirmation dialog — centered icon + message */
.dialog-confirm-body {
  text-align: center;
  padding: 24px 20px;
}

.dialog-confirm-icon {
  font-size: 36px;
  margin-bottom: 12px;
  line-height: 1;
}

.dialog-confirm-icon.warn {
  color: var(--color-warning);
}

.dialog-confirm-icon.danger {
  color: var(--color-danger);
}

.dialog-confirm-icon.info {
  color: var(--color-info);
}

.dialog-confirm-msg {
  font-size: var(--font-size-md);
  color: var(--color-text-primary);
  line-height: 1.5;
}

/* Scrollable dialog body with sticky header/footer */
dialog.cf-dialog-scroll .dialog-body {
  max-height: 50vh;
  overflow-y: auto;
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
}

/* AJAX dialog loading state */
.cf-dialog-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  color: var(--color-text-muted);
  font-size: var(--font-size-base);
  gap: 8px;
}

.cf-dialog-loading::before {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--color-info);
  border-radius: 50%;
  animation: cf-spin 0.6s linear infinite;
}

@keyframes cf-spin {
  to { transform: rotate(360deg); }
}

/* Comment thread inside dialogs */
.cf-comment {
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border-default);
  background: var(--surface-1);
}

.cf-comment--warning {
  border-left-color: var(--color-warning);
  background: var(--color-warning-light);
}

.cf-comment--info {
  border-left-color: var(--color-info);
  background: var(--color-info-bg);
}

.cf-comment--success {
  border-left-color: var(--color-success);
  background: var(--color-success-light);
}

/* Action button group in table cells */
.cf-action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}


/* ================================================================
   4. FORM ENHANCEMENTS
   ================================================================ */

/* Enhanced input — use alongside existing .forms structure */
.cf-input {
  width: var(--input-width);
  height: var(--form-input-height);
  padding: 0 10px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xs);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-text-primary);
  background: var(--surface-0);
  box-sizing: border-box;
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.cf-input:focus {
  outline: none;
  border-color: var(--color-blue);
  box-shadow: 0 0 0 2px rgba(69,151,201,0.15);
}

.cf-input:disabled {
  background: var(--surface-2);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

/* Validation states */
.cf-input.is-invalid,
.is-invalid .cf-input {
  border-color: var(--color-danger);
}

.cf-input.is-invalid:focus {
  box-shadow: 0 0 0 2px rgba(204,0,0,0.12);
}

.cf-input.is-valid {
  border-color: var(--color-success);
}

.cf-input.is-valid:focus {
  box-shadow: 0 0 0 2px rgba(45,122,80,0.12);
}

/* Inline validation message */
.cf-field-error {
  font-size: var(--font-size-sm);
  color: var(--color-danger);
  margin-top: 3px;
}

.cf-field-help {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: 3px;
}


/* Enhanced select */
.cf-select {
  width: var(--select-width);
  height: var(--form-input-height);
  padding: 0 28px 0 10px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xs);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-text-primary);
  background: var(--surface-0) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E") right 10px center no-repeat;
  appearance: none;
  box-sizing: border-box;
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.cf-select:focus {
  outline: none;
  border-color: var(--color-blue);
  box-shadow: 0 0 0 2px rgba(69,151,201,0.15);
}

/* Custom checkbox */
.cf-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: var(--font-size-base);
}

.cf-checkbox input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--color-orange);
  cursor: pointer;
}

/* Required marker */
.cf-required::after {
  content: " *";
  color: var(--color-danger);
  font-size: var(--font-size-sm);
}


/* ================================================================
   5. BUTTON EXTENSIONS
   ================================================================ */

/* Size variants */
.but-sm {
  padding: 2px 10px;
  font-size: var(--font-size-sm);
}

.but-lg {
  padding: 7px 24px;
  font-size: var(--font-size-md);
}

/* Icon-only button */
.but-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--surface-0);
  cursor: pointer;
  font-size: 14px;
  transition: background var(--duration-fast) ease;
}

.but-icon:hover {
  background: var(--surface-2);
}

/* Button group — connected buttons */
.but-group {
  display: inline-flex;
}

.but-group > .but-primary,
.but-group > .but-secondary,
.but-group > .but-ghost {
  border-radius: 0;
}

.but-group > :first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.but-group > :last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.but-group > * + * {
  margin-left: -1px;
}

/* Loading state — spinner replaces text */
.but-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.but-loading::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: cf-spin 0.5s linear infinite;
}

/* Disabled */
.but-primary:disabled,
.but-secondary:disabled,
.but-danger:disabled,
.but-ghost:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Link button — looks like a link, behaves like a button */
.but-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--color-blue);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  cursor: pointer;
  text-decoration: underline;
}

.but-link:hover {
  color: var(--color-blue-light);
}


/* ================================================================
   6. TOAST NOTIFICATIONS
   ================================================================ */

.cf-toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 360px;
  width: 100%;
}

.cf-toast {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-0);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: var(--font-size-base);
  color: var(--color-text-primary);
  pointer-events: auto;
  overflow: hidden;
  position: relative;
  animation: cf-toast-in 0.25s var(--ease-out);
}

@keyframes cf-toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Type accents — left border stripe */
.cf-toast-success { border-left: 3px solid var(--color-success); }
.cf-toast-error   { border-left: 3px solid var(--color-danger); }
.cf-toast-warning { border-left: 3px solid var(--color-warning); }
.cf-toast-info    { border-left: 3px solid var(--color-info); }

.cf-toast-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  font-size: 14px;
  line-height: 18px;
  text-align: center;
}

.cf-toast-success .cf-toast-icon { color: var(--color-success); }
.cf-toast-error   .cf-toast-icon { color: var(--color-danger); }
.cf-toast-warning .cf-toast-icon { color: var(--color-warning); }
.cf-toast-info    .cf-toast-icon { color: var(--color-info); }

.cf-toast-body {
  flex: 1;
  line-height: 1.4;
}

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

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

/* Auto-dismiss progress bar */
.cf-toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: currentColor;
  opacity: 0.2;
  animation: cf-toast-timer linear forwards;
  width: 100%;
}

@keyframes cf-toast-timer {
  from { width: 100%; }
  to   { width: 0%; }
}


/* ================================================================
   7. LOADING STATES
   ================================================================ */

/* Spinner */
.cf-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-light);
  border-top-color: var(--color-orange);
  border-radius: 50%;
  animation: cf-spin 0.55s linear infinite;
}

.cf-spinner-sm { width: 14px; height: 14px; border-width: 2px; }
.cf-spinner-lg { width: 32px; height: 32px; border-width: 3px; }

@keyframes cf-spin {
  to { transform: rotate(360deg); }
}


/* Full overlay */
.cf-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}


/* ================================================================
   8. BADGES & STATUS
   ================================================================ */

.cf-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  line-height: 1.6;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.cf-badge-default {
  background: var(--surface-3);
  color: var(--color-text-secondary);
}

.cf-badge-success {
  background: var(--color-success-light);
  color: var(--color-success);
}

.cf-badge-warning {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.cf-badge-danger {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.cf-badge-info {
  background: var(--color-info-bg);
  color: var(--color-info);
}

.cf-badge-pending {
  background: var(--color-pending-bg);
  color: var(--color-pending);
}

/* Orange brand badge */
.cf-badge-primary {
  background: var(--color-orange);
  color: var(--color-white);
}

/* Status dot — small colored circle indicator */
.cf-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 5px;
}

.cf-dot-success { background: var(--color-success); }
.cf-dot-warning { background: var(--color-warning); }
.cf-dot-danger  { background: var(--color-danger); }
.cf-dot-info    { background: var(--color-info); }
.cf-dot-pending { background: var(--color-pending); }
.cf-dot-muted   { background: var(--color-text-muted); }

/* Badge count (small number badge) */
.cf-badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: var(--font-size-xs);
  font-weight: 700;
  background: var(--color-orange);
  color: var(--color-white);
}


/* ================================================================
   9. FILTER PANEL
   ================================================================ */

.cf-filter {
  margin-bottom: 12px;
}

.cf-filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--surface-0);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  cursor: pointer;
  color: var(--color-text-primary);
  transition: background var(--duration-fast) ease;
}

.cf-filter-toggle:hover {
  background: var(--surface-2);
}

.cf-filter-toggle .cf-badge-count {
  font-size: 8px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
}

.cf-filter-panel {
  margin-top: 8px;
  padding: 12px;
  background: var(--surface-1);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}

.cf-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.cf-filter-field label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 3px;
}

.cf-filter-field input,
.cf-filter-field select {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xs);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
}

.cf-filter-actions {
  display: flex;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
}


/* ================================================================
   10. TABS
   ================================================================ */

.cf-tabs {
  margin-bottom: 16px;
}

.cf-tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border-light);
  overflow-x: auto;
}

.cf-tab {
  padding: 7px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--duration-fast) ease,
              border-color var(--duration-fast) ease;
}

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

.cf-tab-active,
.cf-tab-active:hover {
  color: var(--color-orange);
  border-bottom-color: var(--color-orange);
}

.cf-tab-panel {
  padding: 12px 0;
}


/* ================================================================
   11. CARDS
   ================================================================ */

.cf-card {
  background: var(--surface-0);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.cf-card-header {
  padding: 10px 16px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
  font-size: var(--font-size-md);
}

.cf-card-body {
  padding: 16px;
}

.cf-card-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border-light);
  background: var(--surface-1);
}

/* Stat card — for dashboard-style KPIs */
.cf-stat {
  padding: 12px 16px;
  background: var(--surface-0);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--color-orange);
}

.cf-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.cf-stat-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 2px;
}

.cf-stat-blue  { border-left-color: var(--color-blue); }
.cf-stat-green { border-left-color: var(--color-success); }
.cf-stat-red   { border-left-color: var(--color-danger); }


/* ================================================================
   12. EMPTY STATE
   ================================================================ */

.cf-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-muted);
}

.cf-empty-icon {
  font-size: 36px;
  margin-bottom: 8px;
  opacity: 0.5;
}

.cf-empty-title {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.cf-empty-desc {
  font-size: var(--font-size-base);
  margin-bottom: 12px;
}


/* ================================================================
   13. TOOLTIPS (CSS-only)
   ================================================================ */

[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: var(--color-nav-bg);
  color: var(--color-white);
  font-size: var(--font-size-xs);
  font-weight: normal;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-fast) ease;
  z-index: var(--z-dropdown);
}

[data-tooltip]:hover::after,
[data-tooltip]:focus::after {
  opacity: 1;
}

[data-tooltip-pos="bottom"]::after {
  bottom: auto;
  top: calc(100% + 6px);
}


/* ================================================================
   14. PROGRESS BAR
   ================================================================ */

.cf-progress {
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
}

.cf-progress-bar {
  height: 100%;
  background: var(--color-orange);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.cf-progress-bar-blue  { background: var(--color-blue); }
.cf-progress-bar-green { background: var(--color-success); }
.cf-progress-bar-red   { background: var(--color-danger); }

/* Indeterminate */
.cf-progress-indeterminate .cf-progress-bar {
  width: 30% !important;
  animation: cf-progress-slide 1.2s ease-in-out infinite;
}

@keyframes cf-progress-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(430%); }
}


/* ================================================================
   15. UTILITY CLASSES
   ================================================================ */

/* Text helpers */
.cf-text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cf-text-muted {
  color: var(--color-text-muted);
}

.cf-text-success { color: var(--color-success); }
.cf-text-danger  { color: var(--color-danger); }
.cf-text-warning { color: var(--color-warning); }
.cf-text-info    { color: var(--color-info); }

/* Divider line */
.cf-divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 12px 0;
}

/* Visually hidden (for screen readers) */
.cf-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* No-wrap flex row */
.cf-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Sticky scroll container (for long table wrappers) */
.cf-scroll-y {
  max-height: 400px;
  overflow-y: auto;
}


/* ================================================================
   16. RESPONSIVE OVERRIDES
   ================================================================ */

@media (max-width: 768px) {
  /* Table → card layout on mobile */
  .cf-table table thead {
    display: none;
  }

  .cf-table table tbody tr {
    display: block;
    margin-bottom: 8px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--surface-0);
  }

  .cf-table table tbody td {
    display: flex;
    padding: 5px 10px;
    border-bottom: 1px solid var(--border-light);
  }

  .cf-table table tbody td:last-child {
    border-bottom: none;
  }

  .cf-table table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    width: 40%;
    flex-shrink: 0;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
  }

  .cf-table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .cf-table-search input {
    width: 100%;
  }

  .cf-table-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  /* Pagination wraps */
  .cf-page {
    justify-content: center;
  }

  .cf-page-info {
    margin-left: 0;
    text-align: center;
  }

  /* Filter grid → single column */
  .cf-filter-grid {
    grid-template-columns: 1fr;
  }

  /* Toast → full width */
  .cf-toast-container {
    left: 12px;
    right: 12px;
    max-width: none;
  }

  /* Tabs scroll horizontal */
  .cf-tab-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Mobile column hiding — add cf-mobile-hide class to th/td */
  .cf-table table tbody td.cf-mobile-hide,
  .cf-table table thead th.cf-mobile-hide {
    display: none !important;
  }

  /* Touch targets (WCAG 2.5.8 — 44x44px minimum) */
  .cf-page-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .cf-cell-actions a,
  .cf-cell-actions button {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .cf-tab {
    min-height: 44px;
  }
}

/* Tablet column hiding */
@media (max-width: 1024px) {
  .cf-table table tbody td.cf-tablet-hide,
  .cf-table table thead th.cf-tablet-hide {
    display: none !important;
  }
}

/* Wide table — horizontal scroll at tablet widths */
@media (min-width: 769px) and (max-width: 1380px) {
  .cf-table-wide .cf-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .cf-table-wide .cf-table-wrap table {
    min-width: 1000px;
  }
}

@media (max-width: 480px) {
  .cf-page-btn {
    min-width: 26px;
    height: 26px;
    padding: 0 5px;
    font-size: var(--font-size-sm);
  }

  .cf-badge {
    font-size: 8px;
    padding: 1px 5px;
  }

  .cf-stat-value {
    font-size: 18px;
  }

  .cf-empty {
    padding: 24px 12px;
  }
}


/* ================================================================
   17. POLISH & REFINEMENT — Interaction quality layer
   ================================================================ */

/* ---- Heading typography ---- */
.cf-heading,
.cf-card-header,
.cf-stat-label,
.cf-tab,
.cf-empty-title {
  font-family: var(--font-heading);
}

.cf-stat-value {
  font-family: var(--font-heading);
  letter-spacing: -0.5px;
}

/* ---- Global focus-visible ring ---- */
.but-primary:focus-visible,
.but-secondary:focus-visible,
.but-danger:focus-visible,
.but-ghost:focus-visible,
.but-link:focus-visible,
.but-icon:focus-visible,
.cf-tab:focus-visible,
.cf-page-btn:focus-visible,
.cf-filter-toggle:focus-visible {
  outline: 2px solid var(--color-blue);
  outline-offset: 2px;
}

/* ---- Card interaction layer ---- */
.cf-card {
  transition: box-shadow 200ms ease, transform 200ms ease;
}

.cf-card:hover {
  box-shadow: var(--shadow-md);
}

/* ---- Stat card hover ---- */
.cf-stat {
  transition: box-shadow 200ms ease, border-left-color 200ms ease;
}

.cf-stat:hover {
  box-shadow: var(--shadow-sm);
}

/* ---- Badge refinement ---- */
.cf-badge {
  transition: transform 120ms ease;
}

.cf-badge-count {
  transition: transform 120ms ease;
}

a:hover > .cf-badge,
button:hover > .cf-badge-count {
  transform: scale(1.05);
}

/* ---- Tab underline smooth transition ---- */
.cf-tab {
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease;
}

.cf-tab:hover {
  background: rgba(0,0,0,0.02);
}

/* ---- Table row entrance ---- */
.cf-table tbody tr {
  transition: background-color 150ms ease, box-shadow 150ms ease;
}

.cf-table tbody tr:hover {
  box-shadow: inset 3px 0 0 var(--color-orange);
}

/* ---- Icon button refinement ---- */
.but-icon {
  transition: background 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.but-icon:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-xs);
}

.but-icon:active {
  transform: translateY(0);
}

/* ---- Button active press ---- */
.but-primary:active,
.but-secondary:active,
.but-danger:active,
.but-ghost:active {
  transform: translateY(1px);
}

/* ---- Filter panel entrance ---- */
.cf-filter-panel {
  transition: opacity 180ms ease;
}

/* ---- Pagination hover ---- */
.cf-page-btn {
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

/* ---- Tooltip entrance ---- */
[data-tooltip]::after {
  transition: opacity 150ms ease, transform 150ms ease;
  transform: translateX(-50%) translateY(4px);
}

[data-tooltip]:hover::after,
[data-tooltip]:focus::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

[data-tooltip-pos="bottom"]::after {
  transform: translateX(-50%) translateY(-4px);
}

[data-tooltip-pos="bottom"]:hover::after,
[data-tooltip-pos="bottom"]:focus::after {
  transform: translateX(-50%) translateY(0);
}

/* ---- Progress bar subtle shine ---- */
.cf-progress-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,0.2) 0%,
    transparent 60%
  );
  border-radius: inherit;
  pointer-events: none;
}

.cf-progress {
  position: relative;
}

/* ---- Toast hover pause hint ---- */
.cf-toast:hover .cf-toast-progress {
  animation-play-state: paused;
}

/* ---- Spinner subtle glow ---- */
.cf-spinner {
  filter: drop-shadow(0 0 2px rgba(210,123,26,0.3));
}

/* ---- Empty state icon animation ---- */
.cf-empty-icon {
  transition: transform 300ms ease;
}

.cf-empty:hover .cf-empty-icon {
  transform: scale(1.1);
}

/* ---- Select hover ---- */
.cf-select {
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.cf-select:hover {
  border-color: var(--border-strong);
}

/* ---- Input hover ---- */
.cf-input {
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.cf-input:hover:not(:disabled):not(:focus) {
  border-color: var(--border-strong);
}

/* ---- Checkbox accent transition ---- */
.cf-checkbox input[type="checkbox"] {
  transition: box-shadow 120ms ease;
}

.cf-checkbox:hover input[type="checkbox"] {
  box-shadow: 0 0 0 2px rgba(210,123,26,0.15);
}








/* Stepper, Accordion, Description List, Breadcrumb — removed (unused, demo-only) */


/* ================================================================
   22. ABBREVIATION TOOLTIP
   ================================================================ */

abbr[data-tooltip] {
  text-decoration: underline dotted;
  text-underline-offset: 2px;
  cursor: help;
  font-style: normal;
}
