/* ============================================================
 * Design System v3 — Shared Component CSS
 * ============================================================
 * All approved component styles (Phase 2 + Phase 4 + Phase 5).
 * Extracted from component-preview.html for reuse across templates.
 *
 * Usage:
 *   <link rel="stylesheet" href="../components/components.css">
 *
 * Requires:
 *   - A mode CSS file loaded (e.g., dark-warm.css)
 *   - Shared tokens (--text-xs, --space-*, --radius-*) defined
 *
 * Also provides: z-index scale (mode-independent)
 *
 * Components:
 *   ds-table         Data Table (Banded default, Ruled, Minimal)
 *   ds-nav-top       Nav Top Bar (Clean default, Surface, Elevated)
 *   ds-nav-sidebar   Nav Sidebar (Bordered default, Filled, Pill)
 *   ds-breadcrumb    Breadcrumb (Chevron default, Slash, Arrow, Dot)
 *   ds-check         Checkbox / Radio (Filled default, Outlined, Switch)
 *   ds-datepicker    Datepicker (Compact default, Standard, Inline)
 *   ds-chip          Filter Chips (Filled default, Outlined, Subtle)
 *   ds-skeleton      Skeleton / Loading (Wave default, Pulse, Static)
 *   ds-empty         Empty State (Centered default, Card, Inline, Compact)
 *   ds-error         Error State (Soft default, Card, Banner, Fullpage)
 *   ds-filter-bar    Filter Bar (Sectioned container, Minimal variant)
 *   ds-view-switcher View Switcher (Accent Active, Compact variant)
 * ============================================================ */


/* ================================================================
 * DATA TABLE
 * ================================================================ */

/* ── Z-Index Scale (mode-independent) ── */
:root {
  --z-base:      0;
  --z-raised:    10;
  --z-dropdown:  20;
  --z-sticky:    30;
  --z-tooltip:   40;
  --z-overlay:   50;
  --z-modal:     60;
  --z-toast:     70;
}

/* ── Motion Tokens (mode-independent) ── */
:root {
  /* Duration scale */
  --duration-fast:    100ms;   /* hover, focus, color changes */
  --duration-normal:  200ms;   /* toggle, accordion, tooltip */
  --duration-slow:    350ms;   /* modal, drawer, page transitions */

  /* Easing curves */
  --ease-default:  cubic-bezier(0.2, 0, 0.2, 1);   /* general purpose: smooth in + out */
  --ease-out:      cubic-bezier(0, 0, 0.2, 1);      /* entrances: fast start, gentle landing */
  --ease-in:       cubic-bezier(0.4, 0, 1, 1);      /* exits: slow start, fast departure */

  /* Reduced motion — respect user preference */
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Screen reader only ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ── Skip link ── */
.ds-skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  padding: 8px 16px;
  background: var(--accent-primary);
  color: var(--bg-base);
  z-index: var(--z-toast);
  font-size: 13px;
  text-decoration: none;
  border-radius: 0 0 6px 0;
}

.ds-skip-link:focus {
  top: 0;
}

:root {
  /* Breakpoint reference (can't use in @media, documented here for reference)
     --bp-sm:  640px    Large phones, small tablets
     --bp-md:  768px    Tablets portrait
     --bp-lg:  1024px   Tablets landscape, small laptops
     --bp-xl:  1280px   Desktops
     --bp-2xl: 1536px   Large monitors */
}

/* ══════════════════════════════════════════════════════════════
 * RESPONSIVE UTILITIES
 * ══════════════════════════════════════════════════════════════
 * Mobile-first: base = mobile, media queries layer up.
 * Breakpoints: 640px (sm) | 768px (md) | 1024px (lg) | 1280px (xl)
 * ══════════════════════════════════════════════════════════════ */

/* ── Visibility ── */
.ds-hide-mobile  { display: none; }
.ds-hide-tablet  { }
.ds-hide-desktop { }

@media (min-width: 640px) {
  .ds-hide-mobile  { display: revert; }
  .ds-hide-tablet  { display: none; }
  .ds-show-mobile  { display: none; }
}

@media (min-width: 1024px) {
  .ds-hide-tablet  { display: revert; }
  .ds-hide-desktop { display: none; }
  .ds-show-tablet  { display: none; }
}

/* ── Responsive container ── */
.ds-container {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

@media (min-width: 640px)  { .ds-container { max-width: 640px; padding-left: var(--space-6); padding-right: var(--space-6); } }
@media (min-width: 768px)  { .ds-container { max-width: 768px; } }
@media (min-width: 1024px) { .ds-container { max-width: 1024px; padding-left: var(--space-8); padding-right: var(--space-8); } }
@media (min-width: 1280px) { .ds-container { max-width: 1280px; } }

/* Full-width variant (no max-width, just padding) */
.ds-container--fluid {
  max-width: none;
}

/* ── Responsive grid ── */
.ds-grid-responsive {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
}

@media (min-width: 640px)  { .ds-grid-responsive { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .ds-grid-responsive { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1280px) { .ds-grid-responsive { grid-template-columns: repeat(4, 1fr); } }

/* ── Responsive stack (column on mobile, row on tablet+) ── */
.ds-stack-responsive {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

@media (min-width: 640px) { .ds-stack-responsive { flex-direction: row; } }

/* ── Safe area insets ── */
.ds-safe-top    { padding-top: env(safe-area-inset-top, 0px); }
.ds-safe-bottom { padding-bottom: env(safe-area-inset-bottom, 0px); }

/* ── Mobile bottom nav spacer ── */
.ds-mobile-nav-spacer { height: 72px; } /* 56px nav + 16px breathing room */

@media (min-width: 1024px) { .ds-mobile-nav-spacer { display: none; } }

/* ── Table base ── */
.ds-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-base);
  font-size: var(--text-sm);
}

.ds-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 14px;
  white-space: nowrap;
  user-select: none;
}

.ds-table td {
  padding: 8px 14px;
  color: var(--text-secondary);
}

.ds-table td:first-child {
  color: var(--text-primary);
  font-weight: 500;
}

/* Sortable headers */
.ds-table th[data-sort] { cursor: pointer; }
.ds-table th[data-sort]:hover { color: var(--text-tertiary); }

.ds-table th .sort-icon {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.25;
  font-size: 10px;
}

.ds-table th.sorted .sort-icon {
  opacity: 1;
  color: var(--accent-secondary, var(--accent-primary));
}

/* Row hover (base — variants override) */
.ds-table tbody tr { transition: background var(--duration-fast) var(--ease-default); }

/* Selected row */
.ds-table tbody tr.selected {
  background: var(--accent-primary-subtle);
}

.ds-table tbody tr.selected td:first-child {
  box-shadow: inset 3px 0 0 var(--accent-primary);
}

/* ── Variant: Ruled ── */
.ds-table--ruled th {
  border-bottom: 2px solid var(--border-default);
}

.ds-table--ruled td {
  border-bottom: 1px solid var(--border-subtle);
}

.ds-table--ruled tbody tr:hover {
  background: var(--bg-surface);
}

/* ── Variant: Banded (default) ── */
.ds-table--banded th {
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border-default);
  color: var(--text-tertiary);
  transition: background var(--duration-fast) var(--ease-default), color var(--duration-fast) var(--ease-default);
}

.ds-table--banded th.sorted {
  background: color-mix(in srgb, var(--accent-secondary, var(--accent-primary)) 15%, var(--bg-raised));
  color: var(--accent-secondary, var(--accent-primary));
}

.ds-table--banded th.sorted .sort-icon {
  opacity: 1;
  color: var(--accent-secondary, var(--accent-primary));
}

.ds-table--banded tbody tr:nth-child(even) {
  background: var(--bg-surface);
}

.ds-table--banded tbody tr:hover {
  background: var(--accent-primary-subtle);
}

/* ── Variant: Minimal ── */
.ds-table--minimal th {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 12px;
}

.ds-table--minimal td {
  padding: 14px 16px;
}

.ds-table--minimal tbody tr:hover {
  background: var(--bg-surface);
}

.ds-table--minimal tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--accent-primary);
}

/* ── Density ── */
.ds-table--compact th,
.ds-table--compact td {
  padding: 6px 10px;
  font-size: var(--text-xs);
}

.ds-table--comfortable th,
.ds-table--comfortable td {
  padding: 14px 20px;
  font-size: var(--text-base);
}

/* ── Status pill (inline in table) ── */
.table-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
}

.table-status--published {
  background: rgba(58, 208, 96, 0.1);
  color: var(--semantic-success);
}

.table-status--draft {
  background: var(--bg-raised);
  color: var(--text-muted);
}

.table-status--review {
  background: var(--accent-primary-subtle);
  color: var(--accent-primary);
}

.table-status--pending {
  background: var(--accent-secondary-subtle, var(--bg-raised));
  color: var(--accent-secondary, var(--text-secondary));
}

/* ── Responsive wrapper ── */
.table-responsive {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}


/* ================================================================
 * NAV (TOP BAR)
 * ================================================================ */

/* ── Nav Top base (default = Clean: transparent, underline active) ── */
.ds-nav-top {
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 var(--space-5);
  gap: var(--space-5);
  width: 100%;
  background: transparent;
  border-bottom: 1px solid var(--border-subtle);
}

.ds-nav-top--compact { height: 40px; }
.ds-nav-top--comfortable { height: 56px; }

.ds-nav-top__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.ds-nav-top__logo {
  font-size: var(--text-lg);
  color: var(--accent-primary);
  line-height: 1;
}

.ds-nav-top__title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-primary);
}

.ds-nav-top__items {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.ds-nav-top__item {
  padding: 6px 12px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
  text-decoration: none;
  white-space: nowrap;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.ds-nav-top__item:hover {
  color: var(--text-secondary);
  border-bottom-color: var(--border-emphasis);
}

.ds-nav-top__item.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  font-weight: 600;
}

.ds-nav-top__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
  flex-shrink: 0;
}

.ds-nav-top__action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-sm);
  transition: all var(--duration-fast) var(--ease-default);
}

.ds-nav-top__action:hover {
  background: var(--bg-raised);
  color: var(--text-secondary);
}

.ds-nav-top__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-primary-subtle);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

/* ── Clean variant (explicit alias for base) ── */
.ds-nav-top--clean {
  background: transparent;
}

/* ── Surface variant ── */
.ds-nav-top--surface {
  background: var(--bg-surface);
}

.ds-nav-top--surface .ds-nav-top__item {
  border-radius: var(--radius-md);
  border-bottom: none;
  margin-bottom: 0;
}

.ds-nav-top--surface .ds-nav-top__item:hover {
  background: var(--bg-raised);
  border-bottom-color: transparent;
}

.ds-nav-top--surface .ds-nav-top__item.active {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
  color: var(--bg-base);
  border-bottom-color: transparent;
}

/* ── Elevated variant ── */
.ds-nav-top--elevated {
  background: var(--bg-elevated);
  box-shadow: var(--shadow-md);
  border-bottom: none;
}

.ds-nav-top--elevated .ds-nav-top__item {
  border-radius: var(--radius-md);
  border-bottom: none;
  margin-bottom: 0;
}

.ds-nav-top--elevated .ds-nav-top__item:hover {
  background: var(--bg-raised);
  border-bottom-color: transparent;
}

.ds-nav-top--elevated .ds-nav-top__item.active {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
  color: var(--bg-base);
  border-bottom-color: transparent;
  box-shadow: var(--shadow-glow-camel);
}


/* ================================================================
 * NAV (SIDEBAR)
 * ================================================================ */

/* ── Sidebar base (default = Bordered: left accent border on active) ── */
.ds-nav-sidebar {
  display: flex;
  flex-direction: column;
  width: 230px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  height: 100%;
  overflow: hidden;
}

.ds-nav-sidebar--compact { width: 200px; }
.ds-nav-sidebar--comfortable { width: 260px; }

.ds-nav-sidebar__header {
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.ds-nav-sidebar__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.ds-nav-sidebar__subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
  font-family: var(--font-mono);
}

.ds-nav-sidebar__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) 0;
}

.ds-nav-sidebar__section {
  margin-bottom: var(--space-1);
}

.ds-nav-sidebar__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-5);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.ds-nav-sidebar__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 7px var(--space-5) 7px var(--space-6);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
  text-decoration: none;
  border-left: 2px solid transparent;
}

.ds-nav-sidebar__item:hover {
  background: var(--accent-secondary-subtle, var(--bg-raised));
}

.ds-nav-sidebar__item.active {
  background: var(--bg-raised);
  border-left-color: var(--accent-primary);
}

.ds-nav-sidebar__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.ds-nav-sidebar__item.active .ds-nav-sidebar__icon {
  color: var(--accent-primary);
}

.ds-nav-sidebar__name {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 400;
}

.ds-nav-sidebar__item.active .ds-nav-sidebar__name {
  color: var(--text-primary);
  font-weight: 500;
}

.ds-nav-sidebar__badge {
  margin-left: auto;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
  background: var(--accent-pop-subtle, var(--accent-primary-subtle));
  color: var(--accent-pop, var(--accent-primary));
}

.ds-nav-sidebar__footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ── Bordered variant (explicit alias for base) ── */
.ds-nav-sidebar--bordered {
  /* base is already bordered */
}

/* ── Filled variant ── */
.ds-nav-sidebar--filled .ds-nav-sidebar__item {
  border-left: none;
  padding-left: var(--space-5);
  border-radius: 0;
}

.ds-nav-sidebar--filled .ds-nav-sidebar__item.active {
  background: var(--accent-primary-subtle);
  border-left: none;
}

.ds-nav-sidebar--filled .ds-nav-sidebar__item.active .ds-nav-sidebar__name {
  color: var(--accent-primary);
  font-weight: 600;
}

.ds-nav-sidebar--filled .ds-nav-sidebar__item.active .ds-nav-sidebar__icon {
  color: var(--accent-primary);
}

/* ── Pill variant ── */
.ds-nav-sidebar--pill .ds-nav-sidebar__body {
  padding: var(--space-3) var(--space-3);
}

.ds-nav-sidebar--pill .ds-nav-sidebar__label {
  padding-left: var(--space-3);
  padding-right: var(--space-3);
}

.ds-nav-sidebar--pill .ds-nav-sidebar__item {
  border-left: none;
  padding: 7px var(--space-4);
  margin: 1px 0;
  border-radius: var(--radius-md);
}

.ds-nav-sidebar--pill .ds-nav-sidebar__item.active {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
  border-left: none;
}

.ds-nav-sidebar--pill .ds-nav-sidebar__item.active .ds-nav-sidebar__name {
  color: var(--bg-base);
  font-weight: 600;
}

.ds-nav-sidebar--pill .ds-nav-sidebar__item.active .ds-nav-sidebar__icon {
  color: var(--bg-base);
}

.ds-nav-sidebar--pill .ds-nav-sidebar__item.active .ds-nav-sidebar__badge {
  background: rgba(0,0,0,0.2);
  color: var(--bg-base);
}


/* ================================================================
 * BREADCRUMB
 * ================================================================ */

.ds-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
  padding: var(--space-2) 0;
}

.ds-breadcrumb__item {
  color: var(--text-tertiary);
  text-decoration: none;
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-default);
  white-space: nowrap;
}

.ds-breadcrumb__item:hover {
  color: var(--accent-primary);
}

.ds-breadcrumb__item.current {
  color: var(--text-primary);
  font-weight: 500;
  cursor: default;
}

.ds-breadcrumb__sep {
  color: var(--text-muted);
  font-size: var(--text-xs);
  flex-shrink: 0;
  user-select: none;
}

/* Chevron (default) */
.ds-breadcrumb__sep::after { content: '\203A'; font-size: var(--text-base); }

/* Chevron (explicit alias) */
.ds-breadcrumb--chevron .ds-breadcrumb__sep::after { content: '\203A'; font-size: var(--text-base); }

/* Slash */
.ds-breadcrumb--slash .ds-breadcrumb__sep::after { content: '/'; font-size: inherit; }

/* Arrow */
.ds-breadcrumb--arrow .ds-breadcrumb__sep::after { content: '\2192'; font-size: var(--text-xs); }

/* Dot */
.ds-breadcrumb--dot .ds-breadcrumb__sep::after { content: '\00B7'; font-size: var(--text-lg); }


/* ================================================================
 * CHECKBOX / RADIO
 * ================================================================ */

.ds-check-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.ds-check-group--horizontal {
  flex-direction: row;
  gap: var(--space-5);
}

.ds-check {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  transition: color var(--duration-fast) var(--ease-default);
}

.ds-check:hover { color: var(--text-primary); }

.ds-check__box {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-default);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast) var(--ease-default);
  flex-shrink: 0;
  background: var(--bg-base);
}

.ds-check__box--radio {
  border-radius: 50%;
}

.ds-check.checked .ds-check__box {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.ds-check.checked .ds-check__box svg { color: var(--bg-base); }

.ds-check.checked .ds-check__box--radio {
  background: var(--bg-base);
  border-color: var(--accent-primary);
}

.ds-check.checked .ds-check__box--radio::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-primary);
}

.ds-check.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ds-check:hover .ds-check__box:not(.ds-check__box--radio) {
  border-color: var(--accent-primary);
}

/* Outlined variant */
.ds-check--outlined.checked .ds-check__box {
  background: transparent;
  border-color: var(--accent-primary);
}

.ds-check--outlined.checked .ds-check__box svg { color: var(--accent-primary); }

/* Switch variant (checkbox only) */
.ds-check--switch .ds-check__box {
  width: 32px;
  height: 18px;
  border-radius: 9px;
  border: 2px solid var(--border-default);
  background: var(--bg-raised);
  position: relative;
}

.ds-check--switch .ds-check__box::after {
  content: '';
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  position: absolute;
  left: 1px;
  transition: all var(--duration-fast) var(--ease-default);
}

.ds-check--switch.checked .ds-check__box {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.ds-check--switch.checked .ds-check__box::after {
  background: var(--bg-base);
  left: 15px;
}


/* ================================================================
 * DATEPICKER
 * ================================================================ */

.ds-datepicker {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  gap: var(--space-1);
}

.ds-datepicker__trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 5px 10px;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
  min-width: 130px;
}

.ds-datepicker__trigger:hover {
  border-color: var(--border-emphasis);
}

.ds-datepicker__trigger.focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-primary-subtle);
}

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

.ds-datepicker__calendar {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  min-width: 220px;
}

.ds-datepicker__cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2);
  margin-bottom: var(--space-2);
}

.ds-datepicker__cal-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.ds-datepicker__cal-nav {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  transition: all var(--duration-fast) var(--ease-default);
}

.ds-datepicker__cal-nav:hover {
  background: var(--bg-raised);
  color: var(--text-secondary);
}

.ds-datepicker__cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}

.ds-datepicker__cal-dow {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 0;
}

.ds-datepicker__cal-day {
  padding: 6px 4px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
}

.ds-datepicker__cal-day:hover {
  background: var(--bg-raised);
  color: var(--text-primary);
}

.ds-datepicker__cal-day.today {
  border: 1px solid var(--accent-primary);
  color: var(--accent-primary);
  font-weight: 600;
}

.ds-datepicker__cal-day.selected {
  background: var(--accent-primary);
  color: var(--bg-base);
  font-weight: 600;
}

.ds-datepicker__cal-day.muted {
  color: var(--text-muted);
  opacity: 0.5;
}

/* Inline variant */
.ds-datepicker--inline .ds-datepicker__calendar {
  box-shadow: none;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

/* Standard variant (larger trigger + calendar) */
.ds-datepicker--standard .ds-datepicker__trigger {
  padding: 8px 12px;
  font-size: var(--text-sm);
  min-width: 160px;
}

.ds-datepicker--standard .ds-datepicker__calendar {
  min-width: 260px;
  padding: var(--space-3);
}


/* ================================================================
 * FILTER CHIPS
 * ================================================================ */

.ds-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.ds-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-xl);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
  white-space: nowrap;
  user-select: none;
  background: var(--bg-raised);
  border: 1px solid transparent;
  color: var(--text-secondary);
}

.ds-chip:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.ds-chip.active {
  background: var(--accent-primary);
  border-color: transparent;
  color: var(--bg-base);
  font-weight: 600;
}

/* Secondary chip (uses accent-secondary) */
.ds-chip.active.ds-chip--secondary {
  background: var(--accent-secondary);
}

.ds-chip__count {
  font-size: 10px;
  font-weight: 600;
  background: rgba(0,0,0,0.1);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.ds-chip.active .ds-chip__count {
  background: rgba(0,0,0,0.2);
  color: var(--bg-base);
}

.ds-chip__close {
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.ds-chip.active .ds-chip__close { color: var(--bg-base); }

/* Outlined variant */
.ds-chip--outlined {
  background: transparent;
  border: 1px solid var(--border-default);
}

.ds-chip--outlined:hover {
  border-color: var(--border-emphasis);
  background: transparent;
}

.ds-chip--outlined.active {
  background: var(--accent-primary-subtle);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.ds-chip--outlined.active .ds-chip__count {
  background: rgba(0,0,0,0.1);
  color: var(--accent-primary);
}

.ds-chip--outlined.active .ds-chip__close { color: var(--accent-primary); }

/* Subtle variant */
.ds-chip--subtle {
  border: none;
  background: transparent;
  padding: 5px 10px;
}

.ds-chip--subtle:hover { background: var(--bg-raised); }

.ds-chip--subtle.active {
  background: var(--accent-primary-subtle);
  border: none;
  color: var(--accent-primary);
}

.ds-chip--subtle.active .ds-chip__count {
  background: rgba(0,0,0,0.1);
  color: var(--accent-primary);
}

.ds-chip--subtle.active .ds-chip__close { color: var(--accent-primary); }


/* ================================================================
 * SKELETON / LOADING
 * ================================================================ */

.ds-skeleton {
  background: var(--bg-raised);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
}

/* Wave (default) */
.ds-skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, var(--bg-surface) 50%, transparent 100%);
  animation: ds-skeleton-wave 1.8s ease-in-out infinite;
}

@keyframes ds-skeleton-wave {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Pulse variant */
.ds-skeleton--pulse::after {
  background: var(--bg-raised);
  animation: ds-skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes ds-skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Static variant */
.ds-skeleton--static::after {
  animation: none;
  opacity: 1;
}

.ds-skeleton--text {
  height: 14px;
  border-radius: var(--radius-sm);
}

.ds-skeleton--heading {
  height: 24px;
  width: 60%;
  border-radius: var(--radius-sm);
}

.ds-skeleton--avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.ds-skeleton--button {
  height: 36px;
  width: 100px;
  border-radius: var(--radius-md);
}

.ds-skeleton--card {
  height: 120px;
  border-radius: var(--radius-lg);
}


/* ================================================================
 * EMPTY STATE
 * ================================================================ */

.ds-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-12) var(--space-8);
}

.ds-empty__icon {
  font-size: 48px;
  margin-bottom: var(--space-4);
  opacity: 0.25;
  line-height: 1;
}

.ds-empty__title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.ds-empty__desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 36ch;
  line-height: 1.6;
  margin-bottom: var(--space-5);
}

.ds-empty__action {
  padding: 8px 16px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
  color: var(--bg-base);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-base);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
}

.ds-empty__action:hover {
  box-shadow: var(--shadow-glow-camel);
}

/* Card variant */
.ds-empty--card {
  background: var(--bg-surface);
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
}

/* Inline variant */
.ds-empty--inline {
  flex-direction: row;
  text-align: left;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.ds-empty--inline .ds-empty__icon {
  font-size: 28px;
  margin-bottom: 0;
}

.ds-empty--inline .ds-empty__desc {
  margin-bottom: var(--space-3);
}

/* Compact variant */
.ds-empty--compact {
  padding: var(--space-6) var(--space-5);
}

.ds-empty--compact .ds-empty__icon { font-size: 32px; }
.ds-empty--compact .ds-empty__title { font-size: var(--text-base); }


/* ================================================================
 * ERROR STATE
 * ================================================================ */

.ds-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-12) var(--space-8);
}

.ds-error__icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
  font-size: 24px;
  background: rgba(232,56,56,0.1);
  color: var(--semantic-error);
}

.ds-error__title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.ds-error__desc {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  max-width: 40ch;
  line-height: 1.6;
  margin-bottom: var(--space-3);
}

.ds-error__code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-5);
}

.ds-error__actions {
  display: flex;
  gap: var(--space-3);
}

.ds-error__action-primary {
  padding: 8px 16px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
  color: var(--bg-base);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-base);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}

.ds-error__action-secondary {
  padding: 8px 16px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-family: var(--font-base);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
}

/* Card variant */
.ds-error--card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
}

/* Banner variant */
.ds-error--banner {
  flex-direction: row;
  text-align: left;
  padding: var(--space-4) var(--space-5);
  background: rgba(232,56,56,0.06);
  border: 1px solid rgba(232,56,56,0.15);
  border-radius: var(--radius-lg);
  gap: var(--space-4);
}

.ds-error--banner .ds-error__icon {
  width: 36px;
  height: 36px;
  font-size: 18px;
  margin-bottom: 0;
  flex-shrink: 0;
}

.ds-error--banner .ds-error__desc { margin-bottom: var(--space-3); }

/* Fullpage variant */
.ds-error--fullpage {
  padding: var(--space-16) var(--space-8);
}

.ds-error--fullpage .ds-error__icon {
  width: 64px;
  height: 64px;
  font-size: 32px;
}

.ds-error--fullpage .ds-error__title { font-size: var(--text-xl); }


/* ================================================================
 * BUTTON
 * ================================================================ */

.ds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-base);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.ds-btn:disabled, .ds-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary */
.ds-btn--primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
  color: var(--bg-base);
  border: none;
  box-shadow: var(--shadow-sm), var(--shadow-glow-camel);
}

.ds-btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md), 0 0 30px rgba(212,165,116,0.3);
}

/* Secondary (uses accent-secondary) */
.ds-btn--secondary {
  background: var(--accent-secondary);
  border-color: transparent;
  color: var(--bg-base);
  box-shadow: var(--shadow-sm), var(--shadow-glow-terra);
}

.ds-btn--secondary:hover {
  background: var(--accent-secondary-hover);
  color: var(--bg-base);
  border-color: transparent;
  transform: translateY(-1px);
}

/* Subtle (the old secondary — neutral bg) */
.ds-btn--subtle {
  background: var(--bg-raised);
  border-color: var(--border-default);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.ds-btn--subtle:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-emphasis);
}

/* Pop (uses accent-pop) */
.ds-btn--pop {
  background: var(--accent-pop, var(--accent-primary));
  border-color: transparent;
  color: var(--bg-base);
  box-shadow: var(--shadow-sm);
}

.ds-btn--pop:hover {
  background: var(--accent-pop-hover, var(--accent-primary-hover));
  transform: translateY(-1px);
}

/* Ghost */
.ds-btn--ghost {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-tertiary);
}

.ds-btn--ghost:hover {
  background: var(--bg-raised);
  border-color: var(--border-default);
  color: var(--text-secondary);
}

/* Danger */
.ds-btn--danger {
  background: rgba(232,56,56,0.1);
  border-color: rgba(232,56,56,0.2);
  color: var(--semantic-error);
}

.ds-btn--danger:hover {
  background: rgba(232,56,56,0.18);
  border-color: rgba(232,56,56,0.35);
}

/* Sizes */
.ds-btn--sm {
  padding: 5px 10px;
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

.ds-btn--lg {
  padding: 12px 24px;
  font-size: var(--text-base);
  border-radius: var(--radius-lg);
}

/* Icon-only */
.ds-btn--icon {
  width: 32px;
  height: 32px;
  padding: 0;
}

.ds-btn--icon.ds-btn--sm { width: 24px; height: 24px; }
.ds-btn--icon.ds-btn--lg { width: 40px; height: 40px; }

/* Loading */
.ds-btn--loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.ds-btn--loading::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: ds-btn-spin 0.6s linear infinite;
}

.ds-btn--primary.ds-btn--loading::after { border-color: var(--bg-base); border-right-color: transparent; }

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


/* ================================================================
 * CARD
 * ================================================================ */

.ds-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  position: relative;
}

.ds-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.ds-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.ds-card__title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text-primary);
}

.ds-card__subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.ds-card__body {
  padding: var(--space-5);
}

.ds-card__footer {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

/* Elevated */
.ds-card--elevated {
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
}

/* Flat */
.ds-card--flat {
  box-shadow: none;
}

.ds-card--flat::before { display: none; }

/* Accent border (left, uses accent-secondary) */
.ds-card--accent-border {
  border-left: 3px solid var(--accent-secondary, var(--accent-primary));
}

/* Interactive */
.ds-card--interactive {
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
}

.ds-card--interactive:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}


/* ================================================================
 * INPUT / TEXTAREA
 * ================================================================ */

.ds-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-base);
  font-size: var(--text-sm);
  line-height: 1.5;
  outline: none;
  transition: all var(--duration-fast) var(--ease-default);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.15);
}

.ds-input:hover { border-color: var(--border-default); }

.ds-input:focus {
  border-color: var(--accent-primary);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.15), 0 0 0 2px var(--accent-primary-subtle);
}

.ds-input::placeholder { color: var(--text-muted); }

.ds-input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--bg-raised);
}

/* Error state */
.ds-input--error {
  border-color: var(--semantic-error);
}

.ds-input--error:focus {
  border-color: var(--semantic-error);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.15), 0 0 0 2px rgba(232,56,56,0.15);
}

/* Success state */
.ds-input--success {
  border-color: var(--semantic-success);
}

/* Sizes */
.ds-input--sm {
  padding: 5px 8px;
  font-size: var(--text-xs);
}

.ds-input--lg {
  padding: 12px 16px;
  font-size: var(--text-base);
}

/* Textarea */
.ds-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-base);
  font-size: var(--text-sm);
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: all var(--duration-fast) var(--ease-default);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.15);
  min-height: 80px;
}

.ds-textarea:hover { border-color: var(--border-default); }

.ds-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.15), 0 0 0 2px var(--accent-primary-subtle);
}

.ds-textarea::placeholder { color: var(--text-muted); }
.ds-textarea:disabled { opacity: 0.4; cursor: not-allowed; background: var(--bg-raised); }
.ds-textarea--error { border-color: var(--semantic-error); }

.ds-textarea--lg { min-height: 120px; padding: 14px 16px; font-size: var(--text-base); }
.ds-textarea--sm { min-height: 60px; padding: 6px 10px; font-size: var(--text-xs); }

/* Field wrapper (label + input + hint/error) */
.ds-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.ds-field__label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.ds-field__label--required::after {
  content: ' *';
  color: var(--semantic-error);
}

.ds-field__hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.ds-field__error {
  font-size: var(--text-xs);
  color: var(--semantic-error);
}


/* ================================================================
 * TOGGLE / SWITCH (standalone)
 * ================================================================ */

.ds-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
}

.ds-toggle__track {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--bg-raised);
  border: 2px solid var(--border-default);
  position: relative;
  transition: all var(--duration-fast) var(--ease-default);
  flex-shrink: 0;
}

.ds-toggle__track::after {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  position: absolute;
  top: 1px;
  left: 1px;
  transition: all var(--duration-fast) var(--ease-default);
}

.ds-toggle.active .ds-toggle__track {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.ds-toggle.active .ds-toggle__track::after {
  background: var(--bg-base);
  left: 17px;
}

.ds-toggle:hover .ds-toggle__track {
  border-color: var(--border-emphasis);
}

.ds-toggle.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.ds-toggle__label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* Small */
.ds-toggle--sm .ds-toggle__track {
  width: 28px;
  height: 16px;
  border-radius: 8px;
}

.ds-toggle--sm .ds-toggle__track::after {
  width: 10px;
  height: 10px;
}

.ds-toggle--sm.active .ds-toggle__track::after {
  left: 13px;
}


/* ================================================================
 * STATUS PILL
 * ================================================================ */

.ds-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-xl);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--bg-raised);
  color: var(--text-secondary);
  border: 1px solid transparent;
}

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

/* Variants */
.ds-pill--success {
  background: rgba(58,208,96,0.1);
  color: var(--semantic-success);
}

.ds-pill--success .ds-pill__dot {
  background: var(--semantic-success);
  box-shadow: 0 0 6px rgba(58,208,96,0.4);
}

.ds-pill--warning {
  background: rgba(230,180,60,0.1);
  color: #e6b43c;
}

.ds-pill--warning .ds-pill__dot {
  background: #e6b43c;
  box-shadow: 0 0 6px rgba(230,180,60,0.4);
}

.ds-pill--error {
  background: rgba(232,56,56,0.1);
  color: var(--semantic-error);
}

.ds-pill--error .ds-pill__dot {
  background: var(--semantic-error);
  box-shadow: 0 0 6px rgba(232,56,56,0.4);
}

.ds-pill--accent {
  background: var(--accent-primary-subtle);
  color: var(--accent-primary);
}

.ds-pill--accent .ds-pill__dot {
  background: var(--accent-primary);
  box-shadow: var(--shadow-glow-camel);
}

/* Secondary pill (uses accent-secondary) */
.ds-pill--secondary {
  background: var(--accent-secondary-subtle, var(--bg-raised));
  color: var(--accent-secondary, var(--text-secondary));
}

.ds-pill--secondary .ds-pill__dot {
  background: var(--accent-secondary);
  box-shadow: var(--shadow-glow-terra, none);
}

/* Pop pill (uses accent-pop) */
.ds-pill--pop {
  background: var(--accent-pop-subtle, var(--bg-raised));
  color: var(--accent-pop, var(--text-secondary));
}

.ds-pill--pop .ds-pill__dot {
  background: var(--accent-pop);
  box-shadow: var(--shadow-glow-pop, none);
}

.ds-pill--muted {
  background: var(--bg-raised);
  color: var(--text-muted);
}

.ds-pill--muted .ds-pill__dot {
  background: var(--text-muted);
}

/* Outline variant */
.ds-pill--outline {
  background: transparent;
  border-color: var(--border-default);
}


/* ================================================================
 * SEGMENTED CONTROL (Mode Toggle)
 * ================================================================ */

.ds-segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-base);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
  border: 1px solid var(--border-subtle);
}

.ds-segmented__item {
  padding: 7px 16px;
  border-radius: var(--radius-md);
  border: none;
  font-family: var(--font-base);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
  background: transparent;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.ds-segmented__item:hover {
  color: var(--text-secondary);
  background: var(--bg-raised);
}

.ds-segmented__item.active {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
  color: var(--bg-base);
  font-weight: 600;
  box-shadow: var(--shadow-sm), var(--shadow-glow-camel);
}

/* Compact */
.ds-segmented--compact {
  padding: 2px;
}

.ds-segmented--compact .ds-segmented__item {
  padding: 4px 12px;
  font-size: var(--text-xs);
}

/* Pill shape */
.ds-segmented--pill {
  border-radius: var(--radius-xl);
}

.ds-segmented--pill .ds-segmented__item {
  border-radius: var(--radius-xl);
}


/* ================================================================
 * STAT CARD
 * ================================================================ */

.ds-stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.ds-stat__value {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.ds-stat__label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ds-stat__delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 600;
  margin-top: var(--space-1);
}

.ds-stat__delta--up { color: var(--semantic-success); }
.ds-stat__delta--down { color: var(--semantic-error); }
.ds-stat__delta--neutral { color: var(--text-muted); }

/* Compact */
.ds-stat--compact {
  padding: var(--space-3) var(--space-4);
}

.ds-stat--compact .ds-stat__value {
  font-size: var(--text-xl);
}

/* Accent glow */
.ds-stat--accent {
  border-color: var(--accent-primary-subtle);
}

.ds-stat--accent .ds-stat__value {
  color: var(--accent-primary);
}

/* Secondary accent stat */
.ds-stat--secondary {
  border-color: var(--accent-secondary-subtle, var(--border-subtle));
}

.ds-stat--secondary .ds-stat__value {
  color: var(--accent-secondary, var(--text-primary));
}

/* Accent bar (left border decoration) */
.ds-stat--bar {
  border-left: 3px solid var(--accent-secondary, var(--accent-primary));
}


/* ================================================================
 * BADGE / TAG
 * ================================================================ */

.ds-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-xl);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--bg-raised);
  color: var(--text-secondary);
}

.ds-badge--accent {
  background: var(--accent-primary-subtle);
  color: var(--accent-primary);
}

/* Secondary badge (uses accent-secondary) */
.ds-badge--secondary {
  background: var(--accent-secondary-subtle, var(--bg-raised));
  color: var(--accent-secondary, var(--text-secondary));
}

/* Pop badge — notification dots, counts */
.ds-badge--pop {
  background: var(--accent-pop, var(--accent-primary));
  color: var(--bg-base);
}

.ds-badge--success {
  background: rgba(58,208,96,0.1);
  color: var(--semantic-success);
}

.ds-badge--error {
  background: rgba(232,56,56,0.1);
  color: var(--semantic-error);
}

.ds-badge--warning {
  background: rgba(230,180,60,0.1);
  color: #e6b43c;
}

.ds-badge--muted {
  background: var(--bg-raised);
  color: var(--text-muted);
}

/* Square shape (override pill default) */
.ds-badge--square {
  border-radius: var(--radius-sm);
  padding: 2px 8px;
}

/* Outline variant */
.ds-badge--outline {
  background: transparent;
  border: 1px solid var(--border-default);
}

.ds-badge--outline.ds-badge--accent { border-color: var(--accent-primary); }
.ds-badge--outline.ds-badge--success { border-color: var(--semantic-success); }
.ds-badge--outline.ds-badge--error { border-color: var(--semantic-error); }

/* Large */
.ds-badge--lg {
  padding: 4px 12px;
  font-size: var(--text-sm);
}


/* ================================================================
 * AVATAR
 * ================================================================ */

.ds-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
  color: var(--bg-base);
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid transparent;
}

.ds-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ds-avatar--sm { width: 24px; height: 24px; font-size: 10px; }
.ds-avatar--lg { width: 40px; height: 40px; font-size: 16px; }
.ds-avatar--xl { width: 56px; height: 56px; font-size: 20px; }

/* Ring */
.ds-avatar--ring { border-color: var(--accent-primary); }

/* Online indicator (uses accent-pop) */
.ds-avatar--online { position: relative; }
.ds-avatar--online::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-pop, var(--semantic-success));
  border: 2px solid var(--bg-surface);
  box-shadow: var(--shadow-glow-pop, none);
}

/* Group */
.ds-avatar-group {
  display: flex;
}

.ds-avatar-group .ds-avatar {
  margin-left: -8px;
  border: 2px solid var(--bg-base);
}

.ds-avatar-group .ds-avatar:first-child { margin-left: 0; }


/* ================================================================
 * PAGINATION
 * ================================================================ */

.ds-pagination {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.ds-pagination__item {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
  background: transparent;
  border: none;
  font-family: var(--font-base);
}

.ds-pagination__item:hover {
  background: var(--bg-raised);
  color: var(--text-secondary);
}

.ds-pagination__item.active {
  background: var(--accent-primary);
  color: var(--bg-base);
  font-weight: 600;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-glow-camel);
}

.ds-pagination__item.disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.ds-pagination__ellipsis {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--text-muted);
  font-size: var(--text-sm);
  user-select: none;
}

/* Compact */
.ds-pagination--compact .ds-pagination__item {
  min-width: 28px;
  height: 28px;
  font-size: var(--text-xs);
}


/* ================================================================
 * TOOLTIP
 * ================================================================ */

.ds-tooltip-wrapper {
  position: relative;
  display: inline-flex;
}

.ds-tooltip {
  position: absolute;
  padding: 5px 10px;
  background: var(--accent-primary-subtle);
  border: 1px solid var(--accent-primary);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: var(--text-primary);
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  z-index: var(--z-tooltip);
  pointer-events: none;
}

/* Positions */
.ds-tooltip--top {
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
}

.ds-tooltip--bottom {
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
}

.ds-tooltip--left {
  right: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
}

.ds-tooltip--right {
  left: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
}

/* Arrow */
.ds-tooltip::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  background: var(--accent-primary-subtle);
  border: 1px solid var(--accent-primary);
  transform: rotate(45deg);
}

.ds-tooltip--top::after {
  bottom: -4px;
  left: 50%;
  margin-left: -3px;
  border-top: none;
  border-left: none;
}

.ds-tooltip--bottom::after {
  top: -4px;
  left: 50%;
  margin-left: -3px;
  border-bottom: none;
  border-right: none;
}


/* ================================================================
 * POPOVER
 * ================================================================ */

.ds-popover {
  position: absolute;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  max-width: 320px;
  z-index: var(--z-dropdown);
  overflow: hidden;
}

.ds-popover__header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.ds-popover__body {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

.ds-popover__footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}

.ds-popover__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 7px var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
}

.ds-popover__item:hover {
  background: var(--bg-raised);
  color: var(--text-primary);
}

.ds-popover__item-icon {
  width: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}


/* ================================================================
 * DRAWER / SHEET
 * ================================================================ */

.ds-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: var(--z-overlay);
}

.ds-drawer {
  position: fixed;
  background: var(--bg-elevated);
  border: none;
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3), 0 1px 6px rgba(0,0,0,0.15);
}

.ds-drawer--right {
  top: 0; right: 0; bottom: 0;
  width: 380px;
}

.ds-drawer--left {
  top: 0; left: 0; bottom: 0;
  width: 380px;
}

.ds-drawer--bottom {
  left: 0; right: 0; bottom: 0;
  height: 50vh;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.ds-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.ds-drawer__title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text-primary);
}

.ds-drawer__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-md);
  transition: all var(--duration-fast) var(--ease-default);
}

.ds-drawer__close:hover {
  background: var(--bg-raised);
  color: var(--text-secondary);
}

.ds-drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
}

.ds-drawer__footer {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}


/* ================================================================
 * COMMAND MENU
 * ================================================================ */

.ds-command {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 480px;
  max-height: 400px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ds-command__input-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.ds-command__search-icon {
  color: var(--text-muted);
  flex-shrink: 0;
  font-size: var(--text-md);
}

.ds-command__input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-base);
  font-size: var(--text-sm);
}

.ds-command__input::placeholder { color: var(--text-muted); }

.ds-command__list {
  overflow-y: auto;
  padding: var(--space-2);
}

.ds-command__group-label {
  padding: var(--space-2) var(--space-3);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.ds-command__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 7px var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.ds-command__item:hover,
.ds-command__item.active {
  background: var(--bg-raised);
  color: var(--text-primary);
}

.ds-command__item-icon {
  width: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.ds-command__item-shortcut {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  padding: 2px 6px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
}


/* ================================================================
 * SEARCH INPUT
 * ================================================================ */

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

.ds-search__icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  font-size: var(--text-sm);
  pointer-events: none;
}

.ds-search__input {
  width: 100%;
  padding: 8px 32px 8px 32px;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  color: var(--text-primary);
  font-family: var(--font-base);
  font-size: var(--text-sm);
  outline: none;
  transition: all var(--duration-fast) var(--ease-default);
}

.ds-search__input:hover { border-color: var(--border-default); }

.ds-search__input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-primary-subtle);
}

.ds-search__input::placeholder { color: var(--text-muted); }

.ds-search__clear {
  position: absolute;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-raised);
  border: none;
  color: var(--text-muted);
  font-size: 10px;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
}

.ds-search__clear:hover {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

/* Rectangle variant (override pill default) */
.ds-search--rect .ds-search__input {
  border-radius: var(--radius-md);
}


/* ================================================================
 * FILE UPLOAD
 * ================================================================ */

.ds-upload {
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  text-align: left;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
  background: var(--bg-base);
}

.ds-upload:hover {
  border-color: var(--accent-primary);
  background: var(--accent-primary-subtle);
}

.ds-upload__icon {
  width: 40px;
  height: 40px;
  margin: 0;
  flex-shrink: 0;
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-tertiary);
}

.ds-upload__text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}

.ds-upload__link {
  color: var(--accent-primary);
  font-weight: 600;
}

.ds-upload__hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Tall (centered, stacked icon + text) */
.ds-upload--tall {
  padding: var(--space-8) var(--space-5);
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.ds-upload--tall .ds-upload__icon {
  margin: 0 auto var(--space-3);
}

/* File list */
.ds-upload__files {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.ds-upload__file {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.ds-upload__file-name { flex: 1; }

.ds-upload__file-size {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.ds-upload__file-remove {
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-sm);
}

.ds-upload__file-remove:hover { color: var(--semantic-error); }


/* ================================================================
 * FORM LAYOUT
 * ================================================================ */

.ds-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.ds-form--grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
}

.ds-form--grid .ds-form__full {
  grid-column: 1 / -1;
}

/* Horizontal layout (label + input side by side) */
.ds-form--horizontal .ds-field {
  flex-direction: row;
  align-items: center;
  gap: var(--space-4);
}

.ds-form--horizontal .ds-field__label {
  min-width: 120px;
  text-align: right;
  flex-shrink: 0;
}

/* Section divider */
.ds-form__section {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.ds-form__actions {
  display: flex;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}


/* ================================================================
 * PROGRESS BAR
 * ================================================================ */

.ds-progress {
  width: 100%;
  height: 6px;
  background: var(--bg-raised);
  border-radius: 3px;
  overflow: hidden;
}

.ds-progress__bar {
  height: 100%;
  border-radius: 3px;
  background: var(--accent-primary);
  transition: width var(--duration-slow) var(--ease-default);
}

.ds-progress--success .ds-progress__bar { background: var(--semantic-success); }
.ds-progress--error .ds-progress__bar { background: var(--semantic-error); }
.ds-progress--secondary .ds-progress__bar { background: var(--accent-secondary, var(--accent-primary)); }

/* Indeterminate */
.ds-progress--indeterminate .ds-progress__bar {
  width: 40% !important;
  animation: ds-progress-slide 1.5s ease-in-out infinite;
}

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

/* Labeled */
.ds-progress-labeled {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.ds-progress-labeled__info {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Sizes */
.ds-progress--sm { height: 3px; }
.ds-progress--lg { height: 10px; border-radius: 5px; }
.ds-progress--lg .ds-progress__bar { border-radius: 5px; }


/* ================================================================
 * SPINNER
 * ================================================================ */

.ds-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: auto;
  height: auto;
}

.ds-spinner__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-primary);
  animation: ds-spinner-bounce 1.2s ease-in-out infinite;
}

.ds-spinner__dot:nth-child(2) { animation-delay: 0.15s; }
.ds-spinner__dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes ds-spinner-bounce {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* Pop color */
.ds-spinner--pop .ds-spinner__dot { background: var(--accent-pop, var(--accent-primary)); }

/* Circle variant */
.ds-spinner--circle {
  gap: 0;
  width: 24px;
  height: 24px;
}

.ds-spinner__circle {
  width: 100%;
  height: 100%;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: ds-spinner-rotate 0.7s linear infinite;
}

@keyframes ds-spinner-rotate {
  to { transform: rotate(360deg); }
}

.ds-spinner--circle.ds-spinner--sm { width: 16px; height: 16px; }
.ds-spinner--circle.ds-spinner--sm .ds-spinner__circle { border-width: 1.5px; }

.ds-spinner--circle.ds-spinner--lg { width: 36px; height: 36px; }
.ds-spinner--circle.ds-spinner--lg .ds-spinner__circle { border-width: 3px; }


/* ================================================================
 * SEPARATOR
 * ================================================================ */

.ds-separator {
  border: none;
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-4) 0;
}

.ds-separator--default { background: var(--border-default); }
.ds-separator--accent { background: var(--accent-primary); opacity: 0.3; }
.ds-separator--dashed { background: none; border-top: 1px dashed var(--border-default); }

.ds-separator--vertical {
  width: 1px;
  height: auto;
  min-height: 20px;
  margin: 0 var(--space-3);
  align-self: stretch;
}

/* With label */
.ds-separator--labeled {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: auto;
  background: none;
}

.ds-separator--labeled::before,
.ds-separator--labeled::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.ds-separator__label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}


/* ================================================================
 * STACK / SPACER
 * ================================================================ */

.ds-stack {
  display: flex;
  flex-direction: column;
}

.ds-stack--gap-xs { gap: var(--space-1); }
.ds-stack--gap-sm { gap: var(--space-2); }
.ds-stack--gap-md { gap: var(--space-4); }
.ds-stack--gap-lg { gap: var(--space-6); }
.ds-stack--gap-xl { gap: var(--space-10); }

/* Horizontal */
.ds-stack--horizontal {
  flex-direction: row;
  align-items: center;
}

/* Alignment */
.ds-stack--center { align-items: center; }
.ds-stack--stretch { align-items: stretch; }
.ds-stack--end { align-items: flex-end; }

/* Spacer (flex expander) */
.ds-spacer {
  flex: 1;
}


/* ================================================================
 * GRID
 * ================================================================ */

.ds-grid {
  display: grid;
  gap: var(--space-5);
}

.ds-grid--2 { grid-template-columns: repeat(2, 1fr); }
.ds-grid--3 { grid-template-columns: repeat(3, 1fr); }
.ds-grid--4 { grid-template-columns: repeat(4, 1fr); }

/* Auto-fill */
.ds-grid--auto { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

/* Gap sizes */
.ds-grid--gap-sm { gap: var(--space-3); }
.ds-grid--gap-lg { gap: var(--space-8); }


/* ================================================================
 * CONTAINER
 * ================================================================ */

.ds-container {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-5);
  padding-right: var(--space-5);
}

.ds-container--sm { max-width: 640px; }
.ds-container--md { max-width: 768px; }
.ds-container--lg { max-width: 1024px; }
.ds-container--xl { max-width: 1280px; }


/* ================================================================
 * ACCORDION
 * ================================================================ */

.ds-accordion {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.ds-accordion__item {
  border-bottom: 1px solid var(--border-subtle);
}

.ds-accordion__item:last-child {
  border-bottom: none;
}

.ds-accordion__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-base);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
}

.ds-accordion__header:hover {
  background: var(--bg-surface);
}

.ds-accordion__chevron {
  color: var(--text-muted);
  font-size: var(--text-xs);
  transition: transform var(--duration-normal) var(--ease-default);
  flex-shrink: 0;
}

.ds-accordion__item.open .ds-accordion__chevron {
  transform: rotate(180deg);
}

.ds-accordion__body {
  padding: 0 var(--space-5) var(--space-5);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Flush (no border) */
.ds-accordion--flush {
  border: none;
  border-radius: 0;
}

.ds-accordion--flush .ds-accordion__item {
  border-bottom: 1px solid var(--border-subtle);
}

/* Separated */
.ds-accordion--separated {
  border: none;
  gap: var(--space-2);
}

.ds-accordion--separated .ds-accordion__item {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}


/* ================================================================
 * FILTER BAR (Sectioned container for data filters)
 * ================================================================ */

.ds-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
}

/* ── Section: label above control ── */
.ds-filter-bar__section {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ds-filter-bar__label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1;
}

/* ── Select (styled native <select>) ── */
.ds-filter-bar__select {
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 4px 28px 4px 8px;
  font-family: var(--font-base);
  font-size: var(--text-sm);
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.15);
  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 1L5 5L9 1' stroke='%23888' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.ds-filter-bar__select:hover {
  border-color: var(--border-emphasis);
}

.ds-filter-bar__select:focus {
  border-color: var(--accent-primary);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.15), 0 0 0 2px var(--accent-primary-subtle);
}

/* ── Search row (full-width below sections) ── */
.ds-filter-bar__search-row {
  width: 100%;
  margin-top: -2px;
}

/* ── Clear button ── */
.ds-filter-bar__clear {
  background: none;
  border: none;
  font-family: var(--font-base);
  font-size: var(--text-sm);
  color: var(--accent-primary);
  cursor: pointer;
  white-space: nowrap;
  margin-left: auto;
  padding: 0;
}

.ds-filter-bar__clear:hover {
  text-decoration: underline;
}

/* ── Result count ── */
.ds-filter-bar__count {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-top: 10px;
}

/* ── Minimal variant (no sections, single line) ── */
.ds-filter-bar--minimal {
  gap: 16px;
  align-items: center;
  padding: 10px 16px;
}


/* ================================================================
 * VIEW SWITCHER (Display control, built on ds-segmented)
 * ================================================================ */

.ds-view-switcher {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-base);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
  border: 1px solid var(--border-subtle);
}

.ds-view-switcher__btn {
  padding: 7px 14px;
  border-radius: var(--radius-md);
  border: none;
  font-family: var(--font-base);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: var(--text-tertiary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--duration-fast) var(--ease-default);
  white-space: nowrap;
}

.ds-view-switcher__btn:hover {
  color: var(--text-secondary);
  background: var(--bg-raised);
}

.ds-view-switcher__btn.active {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
  color: var(--bg-base);
  font-weight: 600;
  box-shadow: var(--shadow-sm), var(--shadow-glow-camel);
}

/* Icon-only compact variant */
.ds-view-switcher--compact .ds-view-switcher__btn {
  padding: 7px 10px;
}


/* ================================================================
 * SHARED UTILITIES
 * ================================================================ */

/* Scrollbar (subtle) */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-default); }
