/* ==========================================================================
   COMPONENTS — every reusable UI piece. Built on top of Bootstrap 5's
   behavior (modals, dropdowns, tabs, tooltips, offcanvas all still use
   Bootstrap's JS) but every visual is reskinned to the shadcn look using
   the tokens from foundations.css. See components.html for a live catalog.
   ========================================================================== */

/* ---------------------------- Actions ---------------------------- */
.btn{
  font-family:var(--font-sans); font-weight:500; font-size:var(--text-base);
  border-radius:var(--radius-md); padding:.5rem .875rem; border:1px solid transparent;
  display:inline-flex; align-items:center; gap:6px; transition:background .12s,border-color .12s;
}
.btn:focus-visible{ outline:none; box-shadow:0 0 0 3px var(--ring); }
.btn-primary, .btn-dark{ background:var(--primary); border-color:var(--primary); color:var(--primary-fg); }
.btn-primary:hover, .btn-dark:hover{ opacity:.88; color:var(--primary-fg); }
.btn-outline-secondary{ background:var(--surface); border-color:var(--border); color:var(--text); }
.btn-outline-secondary:hover{ background:var(--surface-hover); color:var(--text); border-color:var(--border); }
.btn-ghost{ background:transparent; border-color:transparent; color:var(--text-muted); }
.btn-ghost:hover{ background:var(--surface-hover); color:var(--text); }
.btn-danger{ background:var(--danger); border-color:var(--danger); color:#fff; }
.btn-outline-danger{ background:transparent; border-color:var(--danger-border); color:var(--danger); }
.btn-outline-danger:hover{ background:var(--danger-bg); }
.btn-sm{ font-size:var(--text-sm); padding:.32rem .6rem; }
.btn-lg{ font-size:var(--text-md); padding:.65rem 1.1rem; }
.btn-icon{ width:30px; height:30px; padding:0; justify-content:center; border-radius:var(--radius-md); background:transparent; border:1px solid transparent; color:var(--text-muted); }
.btn-icon:hover{ background:var(--surface-hover); color:var(--text); }
.btn-icon.bordered{ border-color:var(--border); background:var(--surface); }

.btn-group-seg{ display:inline-flex; border:1px solid var(--border); border-radius:var(--radius-md); overflow:hidden; }
.btn-group-seg button{ border:none; background:var(--surface); padding:.4rem .75rem; font-size:var(--text-sm); color:var(--text-muted); border-right:1px solid var(--border); }
.btn-group-seg button:last-child{ border-right:none; }
.btn-group-seg button.active{ background:var(--zinc-100); color:var(--text); font-weight:600; }
html[data-theme="dark"] .btn-group-seg button.active{ background:var(--zinc-800); }

.dropdown-menu{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); box-shadow:var(--shadow-md); padding:.35rem; font-size:var(--text-base); color:var(--text); }
.dropdown-item{ border-radius:var(--radius-sm); padding:.45rem .6rem; color:var(--text); display:flex; align-items:center; gap:8px; }
.dropdown-item:hover,.dropdown-item:focus{ background:var(--surface-hover); color:var(--text); }
.dropdown-item.text-danger:hover{ background:var(--danger-bg); }
.dropdown-divider{ border-color:var(--border); margin:.3rem 0; }
.dropdown-header{ font-size:var(--text-xs); text-transform:uppercase; letter-spacing:.03em; color:var(--text-faint); padding:.4rem .6rem .2rem; }

/* ---------------------------- Navigation ---------------------------- */
.breadcrumb{ font-size:var(--text-sm); color:var(--text-muted); margin:0; }
.breadcrumb .current{ color:var(--text); font-weight:600; }

.nav-tabs{ border-bottom:1px solid var(--border); gap:2px; }
.nav-tabs .nav-link{ border:none; color:var(--text-muted); font-size:var(--text-base); font-weight:500; padding:.5rem .25rem; margin-right:18px; border-bottom:2px solid transparent; border-radius:0; }
.nav-tabs .nav-link:hover{ color:var(--text); }
.nav-tabs .nav-link.active{ color:var(--text); border-bottom-color:var(--text); background:transparent; }

.pagination{ display:flex; gap:4px; list-style:none; padding:0; margin:0; }
.pagination .page-btn{ min-width:30px; height:30px; display:flex; align-items:center; justify-content:center; border:1px solid var(--border); border-radius:var(--radius-md); font-size:var(--text-sm); color:var(--text-muted); background:var(--surface); cursor:pointer; }
.pagination .page-btn.active{ background:var(--primary); border-color:var(--primary); color:var(--primary-fg); }
.pagination .page-btn:hover:not(.active){ background:var(--surface-hover); }

.stepper{ display:flex; align-items:center; }
.stepper .step{ display:flex; align-items:center; gap:8px; color:var(--text-faint); }
.stepper .step .dot{ width:26px; height:26px; border-radius:50%; border:1px solid var(--border); display:flex; align-items:center; justify-content:center; font-size:var(--text-sm); font-weight:600; background:var(--surface); flex-shrink:0; }
.stepper .step.done .dot{ background:var(--primary); border-color:var(--primary); color:var(--primary-fg); }
.stepper .step.active .dot{ border-color:var(--primary); color:var(--text); }
.stepper .step.active .label,.stepper .step.done .label{ color:var(--text); font-weight:600; }
.stepper .step .label{ font-size:var(--text-sm); white-space:nowrap; }
.stepper .connector{ flex:1; height:1px; background:var(--border); margin:0 10px; min-width:24px; }

/* ---------------------------- Forms ---------------------------- */
.field{ margin-bottom:var(--space-4); }
.field-label{ display:block; font-size:var(--text-sm); font-weight:500; color:var(--text-muted); margin-bottom:6px; }
.field-hint{ font-size:var(--text-xs); color:var(--text-faint); margin-top:4px; }
.form-control, .form-select{
  background:var(--surface); border:1px solid var(--border); color:var(--text);
  border-radius:var(--radius-md); font-size:var(--text-base); padding:.5rem .65rem;
}
.form-control:focus, .form-select:focus{ background:var(--surface); color:var(--text); border-color:var(--zinc-400); box-shadow:0 0 0 3px var(--ring); }
.form-control::placeholder{ color:var(--text-faint); }
.input-group-text{ background:var(--bg-subtle); border-color:var(--border); color:var(--text-muted); font-size:var(--text-sm); }

.form-check-input{ border-color:var(--border); width:16px; height:16px; }
.form-check-input:checked{ background-color:var(--primary); border-color:var(--primary); }
.form-check-input:focus{ box-shadow:0 0 0 3px var(--ring); }
.form-check-label{ font-size:var(--text-base); }

.switch{ position:relative; display:inline-block; width:36px; height:20px; flex-shrink:0; }
.switch input{ opacity:0; width:0; height:0; }
.switch .track{ position:absolute; inset:0; background:var(--zinc-300); border-radius:999px; transition:.15s; cursor:pointer; }
.switch .track::before{ content:""; position:absolute; width:16px; height:16px; left:2px; top:2px; background:#fff; border-radius:50%; transition:.15s; box-shadow:var(--shadow-xs); }
.switch input:checked + .track{ background:var(--primary); }
.switch input:checked + .track::before{ transform:translateX(16px); }

.color-swatch-input{ display:flex; align-items:center; gap:8px; border:1px solid var(--border); border-radius:var(--radius-md); padding:6px 8px; background:var(--surface); }
.color-swatch-input input[type="color"]{ width:26px; height:26px; border:none; border-radius:var(--radius-sm); padding:0; background:none; cursor:pointer; }
.color-swatch-input input[type="text"]{ border:none; background:none; font-family:var(--font-mono); font-size:var(--text-sm); flex:1; color:var(--text); }
.color-swatch-input input[type="text"]:focus{ outline:none; }

.file-drop{ border:2px dashed var(--border); border-radius:var(--radius-lg); padding:var(--space-6); text-align:center; color:var(--text-muted); font-size:var(--text-sm); cursor:pointer; background:var(--bg-subtle); }
.file-drop:hover{ border-color:var(--zinc-400); background:var(--surface-hover); }
.file-drop i{ font-size:22px; color:var(--text-faint); display:block; margin-bottom:6px; }

.date-range-presets{ display:flex; gap:6px; flex-wrap:wrap; }
.date-range-presets button{ font-size:var(--text-sm); padding:.3rem .65rem; border:1px solid var(--border); border-radius:var(--radius-full); background:var(--surface); color:var(--text-muted); }
.date-range-presets button.active{ background:var(--primary); border-color:var(--primary); color:var(--primary-fg); }

.rte-toolbar{ display:flex; gap:2px; border:1px solid var(--border); border-bottom:none; border-radius:var(--radius-md) var(--radius-md) 0 0; padding:6px; background:var(--bg-subtle); }
.rte-toolbar button{ width:28px; height:28px; border:none; background:transparent; border-radius:var(--radius-sm); color:var(--text-muted); }
.rte-toolbar button:hover{ background:var(--surface-hover); color:var(--text); }
.rte-toolbar button.active{ background:var(--zinc-200); color:var(--text); }
.rte-body{ border:1px solid var(--border); border-radius:0 0 var(--radius-md) var(--radius-md); padding:14px; min-height:160px; font-size:var(--text-md); line-height:var(--leading-relaxed); background:var(--surface); }
.rte-body:focus{ outline:none; box-shadow:0 0 0 3px var(--ring) inset; }

/* ---------------------------- Data display ---------------------------- */
.card{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-xl); box-shadow:var(--shadow-xs); }
.card-header{ background:transparent; border-bottom:1px solid var(--border); font-weight:600; font-size:var(--text-base); padding:.85rem 1rem; color:var(--text); }
.card-body-pad{ padding:var(--space-4); }

.dtable{ width:100%; border-collapse:collapse; font-size:var(--text-base); }
.dtable th{ text-align:left; font-size:var(--text-xs); text-transform:uppercase; letter-spacing:.03em; color:var(--text-faint); font-weight:600; padding:10px 14px; border-bottom:1px solid var(--border); }
.dtable td{ padding:11px 14px; border-bottom:1px solid var(--border); color:var(--text); }
.dtable tr:last-child td{ border-bottom:none; }
.dtable tr:hover td{ background:var(--surface-hover); }

.list-row{ display:flex; align-items:center; justify-content:space-between; padding:11px 14px; border-bottom:1px solid var(--border); }
.list-row:last-child{ border-bottom:none; }

.badge-c{ display:inline-flex; align-items:center; gap:4px; font-size:var(--text-xs); font-weight:500; padding:.28em .6em; border-radius:var(--radius-full); background:var(--zinc-100); color:var(--text-muted); }
html[data-theme="dark"] .badge-c{ background:var(--zinc-800); }
.badge-success{ background:var(--success-bg); color:var(--success); }
.badge-warning{ background:var(--warning-bg); color:var(--warning); }
.badge-danger{ background:var(--danger-bg); color:var(--danger); }
.badge-info{ background:var(--info-bg); color:var(--info); }

.avatar{ border-radius:50%; background:var(--zinc-200); color:var(--zinc-600); display:inline-flex; align-items:center; justify-content:center; font-weight:600; font-size:var(--text-sm); flex-shrink:0; }
.avatar.sq{ border-radius:var(--radius-md); }
.avatar-stack{ display:flex; }
.avatar-stack .avatar{ border:2px solid var(--surface); margin-left:-8px; }
.avatar-stack .avatar:first-child{ margin-left:0; }

.timeline{ position:relative; padding-left:22px; }
.timeline::before{ content:""; position:absolute; left:5px; top:4px; bottom:4px; width:1px; background:var(--border); }
.timeline-item{ position:relative; padding-bottom:var(--space-4); }
.timeline-item:last-child{ padding-bottom:0; }
.timeline-item::before{ content:""; position:absolute; left:-22px; top:3px; width:9px; height:9px; border-radius:50%; background:var(--primary); }
.timeline-item .time{ font-size:var(--text-xs); color:var(--text-faint); }

.accordion-item{ background:var(--surface); border:1px solid var(--border); }
.accordion-button{ background:var(--surface); color:var(--text); font-size:var(--text-base); font-weight:500; }
.accordion-button:not(.collapsed){ background:var(--bg-subtle); color:var(--text); box-shadow:none; }
.accordion-button:focus{ box-shadow:0 0 0 3px var(--ring); }
.accordion-body{ font-size:var(--text-base); color:var(--text-muted); }

/* ---------------------------- Feedback ---------------------------- */
.alert-c{ display:flex; gap:10px; padding:12px 14px; border-radius:var(--radius-lg); border:1px solid; font-size:var(--text-base); }
.alert-c.info{ background:var(--info-bg); border-color:var(--info-border); color:var(--info); }
.alert-c.success{ background:var(--success-bg); border-color:var(--success-border); color:var(--success); }
.alert-c.warning{ background:var(--warning-bg); border-color:var(--warning-border); color:var(--warning); }
.alert-c.danger{ background:var(--danger-bg); border-color:var(--danger-border); color:var(--danger); }

.modal-content{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-xl); color:var(--text); }
.modal-header, .modal-footer{ border-color:var(--border); }
.modal-title{ font-size:var(--text-lg); font-weight:600; }

.tooltip-inner{ background:var(--zinc-900); font-size:var(--text-sm); border-radius:var(--radius-md); padding:6px 10px; }

.skel{ background:linear-gradient(90deg, var(--zinc-100) 25%, var(--zinc-200) 37%, var(--zinc-100) 63%); background-size:400% 100%; animation:skel-shine 1.4s ease infinite; border-radius:var(--radius-md); }
html[data-theme="dark"] .skel{ background:linear-gradient(90deg, var(--zinc-800) 25%, var(--zinc-700) 37%, var(--zinc-800) 63%); background-size:400% 100%; }
@keyframes skel-shine{ 0%{background-position:100% 0;} 100%{background-position:-100% 0;} }

.spinner-c{ width:16px; height:16px; border:2px solid var(--border); border-top-color:var(--text); border-radius:50%; animation:spin .6s linear infinite; display:inline-block; }
@keyframes spin{ to{ transform:rotate(360deg); } }

.state-block{ text-align:center; padding:var(--space-10) var(--space-4); color:var(--text-muted); }
.state-block i{ font-size:32px; color:var(--text-faint); margin-bottom:10px; display:block; }
.state-block h4{ font-size:var(--text-md); color:var(--text); margin-bottom:4px; }
.state-block p{ font-size:var(--text-sm); margin-bottom:14px; }
.state-block.error i{ color:var(--danger); }

/* ---------------------------- Misc ---------------------------- */
.divider{ height:1px; background:var(--border); border:none; margin:var(--space-4) 0; }
.kpi-value{ font-size:var(--text-3xl); font-weight:700; letter-spacing:-.02em; }
.kpi-delta{ font-size:var(--text-xs); font-weight:600; display:inline-flex; align-items:center; gap:2px; }
.kpi-delta.up{ color:var(--success); } .kpi-delta.down{ color:var(--danger); }

/* ---------------------------- DataTable ---------------------------- */
.dt-wrap{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-xl); overflow:hidden; }
.dt-toolbar{ display:flex; align-items:center; gap:8px; padding:12px; border-bottom:1px solid var(--border); flex-wrap:wrap; }
.dt-toolbar .dt-search{ position:relative; width:220px; }
.dt-toolbar .dt-search i{ position:absolute; left:9px; top:50%; transform:translateY(-50%); color:var(--text-faint); font-size:13px; }
.dt-toolbar .dt-search input{ padding-left:28px; }
.dt-date-range{ display:flex; align-items:center; gap:6px; }
.dt-date-range input[type="date"]{ width:140px; }
.dt-date-sep{ color:var(--text-faint); }
.dt-grow{ flex:1; }
.dt-bulkbar{ display:flex; align-items:center; gap:10px; padding:8px 12px; background:var(--bg-subtle); border-bottom:1px solid var(--border); font-size:var(--text-sm); }
.dt-table-scroll{ overflow:auto; max-height:520px; }
.dt-table-scroll table.dtable{ min-width:100%; }
.dt-table-scroll table.dtable thead th{ position:sticky; top:0; background:var(--surface); z-index:1; white-space:nowrap; }
.dtable th.sortable{ cursor:pointer; user-select:none; }
.dtable th.sortable:hover{ color:var(--text); }
.dtable th .sort-arrow{ margin-left:4px; opacity:.3; font-size:10px; }
.dtable th.sorted .sort-arrow{ opacity:1; }
.dtable.dt-compact td, .dtable.dt-compact th{ padding:6px 12px; }
.dt-footer{ display:flex; align-items:center; justify-content:space-between; padding:10px 12px; border-top:1px solid var(--border); font-size:var(--text-sm); color:var(--text-muted); flex-wrap:wrap; gap:8px; }
.dt-colvis-item{ display:flex; align-items:center; gap:8px; padding:5px 8px; font-size:var(--text-sm); cursor:pointer; border-radius:var(--radius-sm); }
.dt-colvis-item:hover{ background:var(--surface-hover); }
.dt-checkbox{ width:15px; height:15px; }

