/* ==========================================================================
   components.css — cards, buttons, badges, tables, forms, modals, toasts
   ========================================================================== */

/* ---------- Cards ---------- */
.card-soft {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.card-soft > .card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border);
}
.card-soft > .card-head h2, .card-soft > .card-head h3 { margin: 0; font-size: var(--fs-lg); }
.card-soft > .card-body-pad, .card-soft.card-body-pad { padding: var(--space-5); }
.card-soft.hoverable { transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition); }
.card-soft.hoverable:hover { box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }

/* ---------- Stat cards ---------- */
.stat-card { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4); color: var(--text); height: 100%; overflow: hidden; }
.stat-card:hover { color: var(--text); }
/* Flex children default to a min-width equal to their content, which lets a long label
   (e.g. "Pending approvals") force the card wider than its box and spill past the rounded
   border. min-width: 0 lets the text column shrink and wrap inside the card instead. */
.stat-card > div { min-width: 0; }
.stat-icon {
  width: 44px; height: 44px; border-radius: var(--radius); display: grid; place-items: center;
  font-size: 1.25rem; flex: 0 0 auto; color: var(--c, var(--primary));
  background: color-mix(in srgb, var(--c, var(--primary)) 14%, transparent);
}
.stat-value { font-size: 1.45rem; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.stat-label { color: var(--muted); font-size: var(--fs-sm); font-weight: 600; overflow-wrap: anywhere; }
.stat-note { font-size: var(--fs-xs); color: var(--muted); }
.tone-success { --c: var(--success); } .tone-warning { --c: var(--warning); }
.tone-danger { --c: var(--danger); } .tone-info { --c: var(--info); }
.tone-primary { --c: var(--primary); } .tone-purple { --c: #8b5cf6; } .tone-secondary { --c: var(--secondary); }

/* ---------- Buttons ---------- */
.btn { font-weight: 600; border-radius: var(--radius-sm); transition: all var(--transition); }
.btn-primary {
  --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary);
  --bs-btn-hover-bg: var(--primary-dark); --bs-btn-hover-border-color: var(--primary-dark);
  --bs-btn-active-bg: var(--primary-dark); --bs-btn-active-border-color: var(--primary-dark);
  --bs-btn-disabled-bg: var(--primary); --bs-btn-disabled-border-color: var(--primary);
}
.btn-outline-primary {
  --bs-btn-color: var(--primary); --bs-btn-border-color: var(--primary);
  --bs-btn-hover-bg: var(--primary); --bs-btn-hover-border-color: var(--primary);
  --bs-btn-active-bg: var(--primary); --bs-btn-active-border-color: var(--primary);
}
.btn-soft { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.btn-soft:hover { background: var(--primary-soft); border-color: transparent; color: var(--tone-primary); }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center; border-radius: var(--radius-sm); }
.btn-icon.btn-soft { color: var(--muted); }
.btn-icon.btn-danger-soft:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.btn:disabled, .btn.disabled { cursor: not-allowed; }
.btn.is-loading { pointer-events: none; opacity: 0.8; }

/* ---------- Status badges ---------- */
.badge-status {
  --c: var(--tone-neutral);
  display: inline-flex; align-items: center; gap: 6px; padding: 0.28rem 0.65rem;
  font-size: var(--fs-xs); font-weight: 700; border-radius: var(--radius-pill);
  color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); white-space: nowrap;
}
.badge-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-present, .status-approved, .status-active, .status-paid, .status-open, .status-completed,
.status-hired, .status-selected, .status-low, .status-read { --c: var(--tone-success); }
.status-late, .status-pending, .status-processing, .status-medium, .status-screening,
.status-probation, .status-awaiting-manager-review { --c: var(--tone-warning); }
.status-absent, .status-rejected, .status-critical, .status-urgent { --c: var(--tone-danger); }
.status-half-day, .status-shortlisted, .status-interview { --c: var(--tone-info); }
.status-work-from-home, .status-in-progress, .status-applied, .status-unread, .status-high { --c: var(--tone-primary); }
.status-on-leave, .status-inactive, .status-closed, .status-to-do, .status-self-assessment-pending { --c: var(--tone-neutral); }
.status-critical { --c: var(--tone-danger); }
.status-high.is-priority { --c: var(--tone-warning); }
.status-unread { --c: var(--tone-primary); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-modern { margin: 0; --bs-table-bg: transparent; color: var(--text); }
.table-modern thead th {
  background: var(--surface-2); color: var(--muted); font-size: var(--fs-xs); font-weight: 700;
  border-bottom: 1px solid var(--border); padding: 0.8rem 1rem; white-space: nowrap;
}
.table-modern tbody td { padding: 0.8rem 1rem; vertical-align: middle; border-color: var(--border); }
.table-modern tbody tr { transition: background var(--transition); }
.table-modern tbody tr:hover { background: color-mix(in srgb, var(--primary) 4%, transparent); }
.table-modern th.sortable { cursor: pointer; user-select: none; }
.table-modern th.sortable:hover { color: var(--text); }
.table-modern th .sort-ico { font-size: 0.7rem; margin-left: 4px; opacity: 0.4; }
.table-modern th.sorted .sort-ico { opacity: 1; color: var(--primary); }
.table-modern tr.row-overdue td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.table-footer { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); font-size: var(--fs-sm); color: var(--muted); }
.pagination { margin: 0; --bs-pagination-color: var(--text); --bs-pagination-bg: var(--surface); --bs-pagination-border-color: var(--border); --bs-pagination-active-bg: var(--primary); --bs-pagination-active-border-color: var(--primary); --bs-pagination-hover-bg: var(--surface-2); --bs-pagination-disabled-bg: var(--surface-2); --bs-pagination-hover-color: var(--text); }

/* ---------- Filter bar ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: var(--space-3); padding: var(--space-4); align-items: flex-end; }
.filter-bar .field { flex: 1 1 170px; min-width: 150px; }
.filter-bar .field.grow { flex: 2 1 240px; }
.filter-bar label { font-size: var(--fs-xs); font-weight: 700; color: var(--muted); margin-bottom: 4px; }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: var(--fs-sm); margin-bottom: 0.3rem; }
.form-control, .form-select {
  background-color: var(--surface); color: var(--text); border-color: var(--border);
  border-radius: var(--radius-sm); font-size: var(--fs-base); padding: 0.55rem 0.8rem;
}
/* Bootstrap's dropdown caret is a background-image positioned ~0.75rem from the right edge.
   The shared padding rule above reset that clearance, so the arrow sat on top of the selected
   text (e.g. the "Rows" page-size picker). Restore enough right padding for every <select>. */
.form-select { padding-right: 2.25rem; }
.form-select-sm { padding-right: 2rem; }
/* The "Rows per page" picker sizes itself to its content (style="width:auto") so it doesn't
   force the pagination footer wider than it needs to be. Give it a guaranteed floor so the
   "10"/"25"/"50" text never sits flush against — or under — the dropdown arrow. */
.table-footer select[data-size] { min-width: 4.75rem; }
.form-control::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); background-color: var(--surface); color: var(--text); }
.form-control:disabled, .form-control[readonly], .form-select:disabled { background-color: var(--surface-2); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.invalid-feedback { font-size: var(--fs-xs); }
.required::after { content: " *"; color: var(--danger); }
.form-section-title { font-size: var(--fs-sm); font-weight: 800; color: var(--muted); margin: var(--space-5) 0 var(--space-3); padding-bottom: var(--space-2); border-bottom: 1px solid var(--border); }
.form-section-title:first-child { margin-top: 0; }

/* ---------- Modals, dropdowns, tabs ---------- */
.modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); color: var(--text); }
.modal-header, .modal-footer { border-color: var(--border); }
.modal-title { font-size: var(--fs-lg); font-weight: 700; }
.dropdown-menu { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: var(--space-2); --bs-dropdown-link-color: var(--text); --bs-dropdown-link-hover-bg: var(--surface-2); --bs-dropdown-link-hover-color: var(--text); --bs-dropdown-divider-bg: var(--border); }
.dropdown-item { border-radius: var(--radius-sm); font-weight: 500; padding: 0.5rem 0.75rem; display: flex; align-items: center; gap: 0.6rem; }
.nav-tabs-modern { border-bottom: 1px solid var(--border); gap: var(--space-2); flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
.nav-tabs-modern .nav-link { border: 0; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; padding: 0.7rem 1rem; white-space: nowrap; border-radius: 0; background: none; }
.nav-tabs-modern .nav-link:hover { color: var(--text); }
.nav-tabs-modern .nav-link.active { color: var(--primary); border-bottom-color: var(--primary); background: none; }
.btn-group-toggle .btn { --bs-btn-color: var(--muted); --bs-btn-border-color: var(--border); --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-color: var(--text); --bs-btn-active-bg: var(--primary-soft); --bs-btn-active-color: var(--tone-primary); --bs-btn-active-border-color: var(--border); }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; top: 16px; right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; width: 360px; max-width: calc(100vw - 32px); }
.toast-item { display: flex; gap: var(--space-3); align-items: flex-start; padding: 0.85rem 1rem; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--c, var(--primary)); border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: toast-in 0.2s ease; }
.toast-item i { color: var(--c, var(--primary)); font-size: 1.15rem; margin-top: 1px; }
.toast-item .msg { flex: 1; font-size: var(--fs-sm); font-weight: 500; }
.toast-item.success { --c: var(--success); } .toast-item.danger { --c: var(--danger); }
.toast-item.warning { --c: var(--warning); } .toast-item.info { --c: var(--info); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Avatars ---------- */
.avatar { --size: 38px; width: var(--size); height: var(--size); border-radius: 50%; flex: 0 0 auto; display: inline-grid; place-items: center; font-weight: 700; font-size: calc(var(--size) * 0.38); color: #fff; object-fit: cover; background: var(--bg-c, var(--primary)); }
.avatar-lg { --size: 84px; } .avatar-md { --size: 52px; } .avatar-sm { --size: 30px; }
.person { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.person .nm { font-weight: 700; line-height: 1.2; }
.person .sub { font-size: var(--fs-xs); color: var(--muted); }

/* ---------- Misc ---------- */
.empty-state { text-align: center; padding: var(--space-6) var(--space-4); color: var(--muted); }
.empty-state i { font-size: 2.4rem; color: color-mix(in srgb, var(--muted) 55%, transparent); }
.empty-state h3 { font-size: var(--fs-lg); margin: var(--space-3) 0 4px; }
.progress { height: 8px; background: var(--surface-2); border-radius: var(--radius-pill); }
.progress-bar { background: var(--primary); }
.list-clean { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; align-items: center; gap: var(--space-3); padding: 0.75rem var(--space-5); border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 0.3rem 0.7rem; border-radius: var(--radius-pill); background: var(--surface-2); border: 1px solid var(--border); font-size: var(--fs-sm); font-weight: 600; }
.chip button { border: 0; background: none; color: var(--muted); padding: 0; line-height: 1; }
.chip button:hover { color: var(--danger); }
.demo-banner { display: flex; gap: var(--space-3); align-items: center; padding: 0.7rem 1rem; border-radius: var(--radius); background: color-mix(in srgb, var(--warning) 14%, transparent); color: var(--tone-warning); font-size: var(--fs-sm); font-weight: 600; margin-bottom: var(--space-4); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 0.6rem var(--space-4); margin: 0; }
.kv dt { color: var(--muted); font-weight: 600; font-size: var(--fs-sm); }
.kv dd { margin: 0; font-weight: 600; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius-sm); min-height: 16px; }
@keyframes shimmer { to { background-position: -200% 0; } }
