/* =============================================================================
   STANDARD Component Library v2
   Reusable, composable UI components built on DS2 tokens.

   UNLAYERED on purpose — same strategy as pages-v2.css. These rules override
   the @layer-scoped DS2 components when both are loaded.

   Naming: c-{component} prefix to avoid collision with ds2-{base} classes.
   Scope: body.ds2 prefix on every rule — zero impact on legacy pages.

   Dependencies: design-system-v2.css (tokens + base components)
   Load order: design-system-v2.css -> components-v2.css -> pages-v2.css
   ============================================================================= */


/* =============================================================================
   1. PAGE HEADER
   Standard page title area: heading + optional subtitle + optional actions
   Usage: <div class="c-page-header"> <h1>Title</h1> <p>Subtitle</p> </div>
   ============================================================================= */

body.ds2 .c-page-header {
    margin-bottom: var(--ds2-space-6);
}

body.ds2 .c-page-header h1 {
    font-family: var(--ds2-font-heading);
    font-size: var(--ds2-text-2xl);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin: 0 0 var(--ds2-space-1);
    line-height: 1.3;
}

body.ds2 .c-page-header p {
    font-size: var(--ds2-text-sm);
    color: var(--text-secondary);
    margin: 0;
}

body.ds2 .c-page-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--ds2-space-4);
    margin-bottom: var(--ds2-space-6);
}

body.ds2 .c-page-header-row .c-page-header {
    margin-bottom: 0;
}

body.ds2 .c-page-actions {
    display: flex;
    gap: var(--ds2-space-2);
    flex-shrink: 0;
}


/* =============================================================================
   2. STAT CARDS & STATS GRID
   Metric display: value + label + optional trend/sparkline
   Usage: <div class="c-stats-grid"> <div class="c-stat-card">...</div> </div>
   ============================================================================= */

body.ds2 .c-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--ds2-space-3);
    margin-bottom: var(--ds2-space-8);
}

@media (min-width: 1024px) {
    body.ds2 .c-stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

body.ds2 .c-stat-card {
    background: var(--card-bg);
    border: none;
    border-radius: var(--ds2-radius-xl);
    padding: var(--ds2-space-5);
    text-align: center;
    box-shadow: 0 0 0 1px var(--border-default);
    contain: layout style paint;
    transition: background 0.15s ease;
}

body.ds2 .c-stat-card:hover {
    background: var(--bg-surface-raised);
}

body.ds2 .c-stat-value {
    font-family: var(--ds2-font-heading);
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    line-height: var(--leading-tight);
}

/* Revenue stat values use amber for monetary amounts */
body.ds2 .c-stat-value.revenue {
    color: var(--color-revenue);
}

body.ds2 .c-stat-label {
    font-size: var(--ds2-text-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

body.ds2 .c-stat-detail {
    font-size: var(--ds2-text-xs);
    color: var(--text-secondary);
    margin-top: var(--ds2-space-2);
}

body.ds2 .c-stat-trend {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: var(--ds2-radius-sm);
    margin-top: var(--ds2-space-2);
}

body.ds2 .c-stat-trend.up {
    background: rgba(52, 211, 153, 0.12);
    color: var(--status-success);
}

body.ds2 .c-stat-trend.down {
    background: rgba(239, 68, 68, 0.12);
    color: var(--status-error);
}

body.ds2 .c-stat-trend.flat {
    background: transparent;
    color: var(--text-secondary);
}

/* Featured stat card (v3 dashboard hero KPI) */
body.ds2 .c-stat-card-featured .c-stat-value {
    font-size: 2.5rem;
    letter-spacing: -0.035em;
}
body.ds2 .c-stat-card-featured.revenue .c-stat-value {
    color: var(--color-revenue);
}

/* Sparkline SVG inside stat cards */
body.ds2 .c-sparkline {
    display: block;
    width: 100%;
    height: 24px;
    margin-top: 0.75rem;
}

body.ds2 .c-sparkline polyline {
    fill: none;
    stroke: var(--interactive-primary);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}


/* =============================================================================
   3. DATA TABLES
   Consistent table styling with sticky headers and zebra striping
   Usage: <div class="c-table-wrap"> <table class="c-table">...</table> </div>
   ============================================================================= */

body.ds2 .c-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--ds2-radius-lg);
    border: 1px solid var(--border-default);
    background: var(--card-bg);
}

body.ds2 .c-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--ds2-text-sm);
}

body.ds2 .c-table th {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    text-align: left;
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--border-strong);
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bg-surface-raised);
    white-space: nowrap;
}

body.ds2 .c-table td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--border-default);
    color: var(--text-primary);
    vertical-align: middle;
}

body.ds2 .c-table tr:last-child td {
    border-bottom: none;
}

body.ds2 .c-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.015);
}

body.ds2 .c-table tbody tr:hover {
    background: var(--bg-surface);
}

/* Compact variant */
body.ds2 .c-table.compact th,
body.ds2 .c-table.compact td {
    padding: 0.4rem 0.625rem;
    font-size: 0.8125rem;
}

/* Right-align numbers */
body.ds2 .c-table .text-right {
    text-align: right;
}

body.ds2 .c-table .text-center {
    text-align: center;
}

/* Muted text in table cells */
body.ds2 .c-table .cell-muted {
    color: var(--text-muted);
    font-size: var(--ds2-text-xs);
}

/* Clickable rows */
body.ds2 .c-table tr.clickable {
    cursor: pointer;
}

body.ds2 .c-table tr.clickable:hover {
    background: var(--bg-surface-raised);
}


/* =============================================================================
   4. TAB BAR
   Horizontal tab navigation with underline indicator
   Usage: <div class="c-tab-bar"> <button class="c-tab active">Tab</button> </div>
   ============================================================================= */

body.ds2 .c-tab-bar {
    display: flex;
    gap: 0;
    margin-bottom: var(--ds2-space-5);
    border-bottom: 1px solid var(--border-default);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

body.ds2 .c-tab {
    padding: 0.75rem 1.25rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: var(--ds2-text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: color var(--ds2-transition-fast), border-color var(--ds2-transition-fast);
    white-space: nowrap;
    margin-bottom: -1px;
}

body.ds2 .c-tab:hover {
    color: var(--text-primary);
}

body.ds2 .c-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--interactive-primary);
}

body.ds2 .c-tab-content {
    display: none;
}

body.ds2 .c-tab-content.active {
    display: block;
}

/* Tab count badge */
body.ds2 .c-tab .c-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: var(--ds2-radius-full);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    margin-left: 0.4rem;
}

body.ds2 .c-tab.active .c-tab-count {
    background: var(--color-primary-bg);
    color: var(--color-primary);
}


/* =============================================================================
   5. EMPTY STATE
   Centered message when no data is available
   Usage: <div class="c-empty-state"> <h3>No items</h3> <p>Description</p> </div>
   ============================================================================= */

body.ds2 .c-empty-state {
    text-align: center;
    padding: var(--ds2-space-12) var(--ds2-space-4);
    color: var(--text-muted);
}

body.ds2 .c-empty-state-icon {
    margin-bottom: var(--ds2-space-4);
    color: var(--text-muted);
    opacity: 0.5;
}

body.ds2 .c-empty-state-icon svg {
    width: 48px;
    height: 48px;
}

body.ds2 .c-empty-state h3 {
    font-size: var(--ds2-text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--ds2-space-2);
}

body.ds2 .c-empty-state p {
    font-size: var(--ds2-text-sm);
    color: var(--text-secondary);
    margin: 0 0 var(--ds2-space-5);
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}


/* =============================================================================
   6. ACTIVITY / FEED ITEMS
   Vertical list of timestamped items (activity logs, recent users, etc.)
   Usage: <ul class="c-activity-list"> <li class="c-activity-item">...</li> </ul>
   ============================================================================= */

body.ds2 .c-activity-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

body.ds2 .c-activity-item {
    display: flex;
    align-items: center;
    gap: var(--ds2-space-3);
    padding: var(--ds2-space-3) 0;
    border-bottom: 1px solid var(--border-default);
}

body.ds2 .c-activity-item:last-child {
    border-bottom: none;
}

body.ds2 .c-activity-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--ds2-radius-md);
    background: rgba(255, 255, 255, 0.04);
    flex-shrink: 0;
    color: var(--text-secondary);
    font-size: 1rem;
}

body.ds2 .c-activity-content {
    flex: 1;
    min-width: 0;
}

body.ds2 .c-activity-title {
    font-size: var(--ds2-text-sm);
    font-weight: 500;
    color: var(--text-primary);
}

body.ds2 .c-activity-meta {
    font-size: var(--ds2-text-xs);
    color: var(--text-muted);
}

body.ds2 .c-activity-time {
    font-size: var(--ds2-text-xs);
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}


/* =============================================================================
   7. PAGINATION
   Page navigation with prev/next and number links
   Usage: <div class="c-pagination-row"> <div class="c-pagination">...</div> </div>
   ============================================================================= */

body.ds2 .c-pagination-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--ds2-space-3) var(--ds2-space-4);
    border-top: 1px solid var(--border-default);
    flex-wrap: wrap;
    gap: 0.75rem;
}

body.ds2 .c-pagination-info {
    font-size: var(--ds2-text-xs);
    color: var(--text-muted);
}

body.ds2 .c-pagination {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

body.ds2 .c-page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 0.5rem;
    border-radius: var(--ds2-radius-sm);
    background: var(--bg-surface-raised);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.825rem;
    transition: all var(--ds2-transition-fast);
    cursor: pointer;
}

body.ds2 .c-page-link:hover {
    border-color: var(--interactive-primary);
    color: var(--text-primary);
}

body.ds2 .c-page-link.active {
    background: var(--interactive-primary);
    border-color: var(--interactive-primary);
    color: var(--interactive-primary-text);
    font-weight: 600;
}

body.ds2 .c-page-link.disabled {
    opacity: 0.25;
    pointer-events: none;
}

/* Per-page selector */
body.ds2 .c-per-page {
    display: flex;
    align-items: center;
    gap: var(--ds2-space-2);
    font-size: var(--ds2-text-xs);
    color: var(--text-muted);
}

body.ds2 .c-per-page select {
    background: var(--bg-surface-raised);
    border: 1px solid var(--border-default);
    border-radius: var(--ds2-radius-sm);
    color: var(--text-primary);
    padding: 0.25rem 0.5rem;
    font-size: var(--ds2-text-xs);
}


/* =============================================================================
   8. SEARCH & FILTER BAR
   Inline search input + optional filter controls
   Usage: <div class="c-search-bar"> <input class="c-search-input" /> </div>
   ============================================================================= */

body.ds2 .c-search-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: var(--ds2-space-4);
    align-items: center;
}

body.ds2 .c-search-input {
    flex: 1;
    padding: var(--ds2-space-2) var(--ds2-space-3);
    font-size: var(--ds2-text-sm);
    color: var(--text-primary);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--ds2-radius-md);
    transition: border-color var(--ds2-transition-fast);
}

body.ds2 .c-search-input:focus {
    outline: none;
    border-color: var(--input-focus-ring);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

body.ds2 .c-search-input::placeholder {
    color: var(--text-muted);
}

/* Filter chips row */
body.ds2 .c-filter-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: var(--ds2-space-3);
}

body.ds2 .c-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    font-size: var(--ds2-text-xs);
    font-weight: 500;
    border-radius: var(--ds2-radius-full);
    border: 1px solid var(--border-default);
    background: var(--bg-surface-raised);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--ds2-transition-fast);
}

body.ds2 .c-filter-chip:hover {
    border-color: var(--border-strong);
    color: var(--text-primary);
}

body.ds2 .c-filter-chip.active {
    background: var(--color-primary-bg);
    border-color: var(--color-primary);
    color: var(--color-primary);
}


/* =============================================================================
   9. SECTION CARD
   Container card for grouping related content within a page
   Usage: <div class="c-section"> <h2 class="c-section-title">Title</h2> ... </div>
   ============================================================================= */

body.ds2 .c-section {
    background: var(--card-bg);
    border: none;
    border-radius: var(--ds2-radius-xl);
    padding: var(--ds2-space-5);
    margin-bottom: var(--ds2-space-4);
    box-shadow: 0 0 0 1px var(--border-default);
    contain: layout style paint;
}

body.ds2 .c-section-title {
    font-size: var(--ds2-text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 0 0 var(--ds2-space-4);
}

body.ds2 .c-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--ds2-space-4);
}

body.ds2 .c-section-header h2,
body.ds2 .c-section-header h3 {
    font-size: var(--ds2-text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}


/* =============================================================================
   10. NAV CARDS / LINK CARDS
   Clickable cards for navigation (admin dashboard, settings)
   Usage: <a class="c-nav-card" href="..."> <div class="c-nav-icon">...</div> ... </a>
   ============================================================================= */

body.ds2 .c-nav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--ds2-space-4);
    margin-bottom: var(--ds2-space-5);
}

body.ds2 .c-nav-card {
    background: var(--card-bg);
    border: none;
    border-radius: var(--ds2-radius-xl);
    padding: var(--ds2-space-5);
    display: flex;
    align-items: center;
    gap: var(--ds2-space-3);
    text-decoration: none;
    color: var(--text-primary);
    box-shadow: 0 0 0 1px var(--border-default);
    transition: background 0.15s ease;
}

body.ds2 .c-nav-card:hover {
    background: var(--bg-surface-raised);
}

body.ds2 .c-nav-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary-bg);
    border-radius: var(--ds2-radius-md);
    color: var(--color-primary);
    flex-shrink: 0;
}

body.ds2 .c-nav-content h3 {
    font-size: var(--ds2-text-base);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.15rem;
}

body.ds2 .c-nav-content p {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Notification badge on nav cards */
body.ds2 .c-nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: var(--ds2-radius-full);
    background: var(--ds2-red-600);
    color: #fff;
    margin-left: 0.4rem;
}


/* =============================================================================
   11. STATUS BADGES
   Semantic color badges for status, source, role
   Usage: <span class="c-badge c-badge-success">Active</span>
   ============================================================================= */

body.ds2 .c-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: var(--ds2-radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

body.ds2 .c-badge-success {
    background: rgba(52, 211, 153, 0.12);
    color: var(--ds2-emerald-400);
}

body.ds2 .c-badge-error {
    background: rgba(239, 68, 68, 0.12);
    color: var(--ds2-red-400);
}

body.ds2 .c-badge-warning {
    background: rgba(234, 179, 8, 0.12);
    color: var(--ds2-yellow-400);
}

body.ds2 .c-badge-info {
    background: rgba(96, 165, 250, 0.12);
    color: var(--ds2-blue-400);
}

body.ds2 .c-badge-accent {
    background: var(--color-primary-bg);
    color: var(--color-primary);
}

body.ds2 .c-badge-muted {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

body.ds2 .c-badge-purple {
    background: rgba(168, 85, 247, 0.12);
    color: var(--ds2-purple-500);
}

/* Pill variant (fully rounded) */
body.ds2 .c-badge-pill {
    border-radius: var(--ds2-radius-full);
    padding: 0.15rem 0.625rem;
}

/* Live pulsing badge — red (industry standard) */
body.ds2 .c-badge-live {
    background: var(--color-destructive-bg);
    color: var(--color-destructive);
    animation: ds2-pulse 2s ease-in-out infinite;
}

/* Semantic role badges */
body.ds2 .c-badge-admin {
    background: var(--color-info-bg);
    color: var(--color-info);
}

body.ds2 .c-badge-reviewer {
    background: rgba(168, 85, 247, 0.12);
    color: var(--ds2-purple-500);
}

body.ds2 .c-badge-artist {
    background: var(--color-success-bg);
    color: var(--color-success);
}

body.ds2 .c-badge-ended {
    background: rgba(140, 140, 150, 0.08);
    color: var(--text-secondary);
}

/* Brand accent badge — warm amber for featured/highlighted elements */
body.ds2 .c-badge-brand {
    background: var(--brand-accent-subtle);
    color: var(--brand-accent);
}

/* Featured card border — warm accent for highlighted items */
body.ds2 .c-card-featured {
    border-color: var(--brand-accent);
    box-shadow: var(--shadow-card), 0 0 0 1px var(--brand-accent);
}

body.ds2 .c-card-featured:hover {
    box-shadow: var(--shadow-card-hover), 0 0 12px var(--brand-accent-glow);
}


/* =============================================================================
   12. TWO-COLUMN GRID
   Equal-width side-by-side layout for dashboard sections
   Usage: <div class="c-two-col"> <div>Left</div> <div>Right</div> </div>
   ============================================================================= */

body.ds2 .c-two-col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: var(--ds2-space-4);
}


/* =============================================================================
   13. FORM GROUP ENHANCEMENTS
   Builds on ds2-input/ds2-label from design-system-v2.css
   Usage: <div class="c-form-group"> <label class="c-form-label">...</label> ... </div>
   ============================================================================= */

body.ds2 .c-form-group {
    margin-bottom: var(--ds2-space-4);
}

body.ds2 .c-form-label {
    display: block;
    font-size: var(--ds2-text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--ds2-space-1);
}

body.ds2 .c-form-sublabel {
    display: block;
    font-size: var(--ds2-text-xs);
    color: var(--text-muted);
    font-weight: 400;
}

body.ds2 .c-form-input,
body.ds2 .c-form-select,
body.ds2 .c-form-textarea {
    width: 100%;
    padding: var(--ds2-space-2) var(--ds2-space-3);
    font-size: var(--ds2-text-sm);
    color: var(--text-primary);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--ds2-radius-md);
    transition: border-color var(--ds2-transition-fast);
    font-family: inherit;
}

body.ds2 .c-form-input:focus,
body.ds2 .c-form-select:focus,
body.ds2 .c-form-textarea:focus {
    outline: none;
    border-color: var(--input-focus-ring);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

body.ds2 .c-form-input:focus-visible,
body.ds2 .c-form-select:focus-visible,
body.ds2 .c-form-textarea:focus-visible {
    box-shadow: var(--focus-ring);
}

body.ds2 .c-form-input::placeholder,
body.ds2 .c-form-textarea::placeholder {
    color: var(--text-muted);
}

body.ds2 .c-form-help {
    font-size: var(--ds2-text-xs);
    color: var(--text-muted);
    margin-top: var(--ds2-space-1);
}

body.ds2 .c-form-error {
    font-size: var(--ds2-text-xs);
    color: var(--status-error);
    margin-top: var(--ds2-space-1);
}

/* Checkbox & radio */
body.ds2 .c-form-check {
    display: flex;
    align-items: center;
    gap: var(--ds2-space-2);
    cursor: pointer;
    font-size: var(--ds2-text-sm);
    color: var(--text-primary);
}

body.ds2 .c-form-check input[type="checkbox"],
body.ds2 .c-form-check input[type="radio"] {
    accent-color: var(--interactive-primary);
}


/* =============================================================================
   14. ICON BUTTONS
   Small icon-only action buttons (edit, delete, view)
   Usage: <button class="c-icon-btn" aria-label="Edit">...</button>
   ============================================================================= */

body.ds2 .c-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--ds2-radius-md);
    border: 1px solid var(--border-default);
    background: var(--bg-surface-raised);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--ds2-transition-fast);
    padding: 0;
}

body.ds2 .c-icon-btn:hover {
    border-color: var(--border-strong);
    color: var(--text-primary);
    background: var(--bg-surface-overlay);
}

body.ds2 .c-icon-btn svg {
    width: 16px;
    height: 16px;
}

/* Danger variant */
body.ds2 .c-icon-btn.danger:hover {
    border-color: var(--status-error);
    color: var(--status-error);
    background: rgba(239, 68, 68, 0.08);
}

/* With tooltip */
body.ds2 .c-icon-btn[aria-label] {
    position: relative;
}

body.ds2 .c-icon-btn[aria-label]::after {
    content: attr(aria-label);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    font-size: 0.6875rem;
    font-weight: 500;
    white-space: nowrap;
    border-radius: var(--ds2-radius-sm);
    background: var(--bg-surface-overlay);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--ds2-transition-fast);
}

body.ds2 .c-icon-btn[aria-label]:hover::after {
    opacity: 1;
}


/* =============================================================================
   15. COLLAPSIBLE SECTIONS
   Expandable/collapsible content groups
   Usage: <div class="c-collapse-header">...</div><div class="c-collapse-body">...</div>
   ============================================================================= */

body.ds2 .c-collapse-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border-default);
    margin-bottom: 0.5rem;
}

body.ds2 .c-collapse-header:hover {
    opacity: 0.8;
}

body.ds2 .c-collapse-chevron {
    font-size: 0.625rem;
    color: var(--text-muted);
    transition: transform var(--ds2-transition-base);
    width: 12px;
    text-align: center;
}

body.ds2 .c-collapse-header.collapsed .c-collapse-chevron {
    transform: rotate(-90deg);
}

body.ds2 .c-collapse-title {
    font-size: var(--ds2-text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

body.ds2 .c-collapse-count {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-left: auto;
}

body.ds2 .c-collapse-body {
    overflow: hidden;
    transition: max-height 0.3s ease;
}

body.ds2 .c-collapse-header.collapsed + .c-collapse-body {
    max-height: 0 !important;
    margin-bottom: 0;
}


/* =============================================================================
   16. ADMIN CONTAINER
   Standard admin page wrapper with consistent spacing
   Usage: <div class="c-admin-container">...</div>
   ============================================================================= */

body.ds2 .c-admin-container {
    padding: var(--ds2-space-6);
    max-width: 1400px;
    margin: 0 auto;
}

body.ds2 .c-admin-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: var(--ds2-space-5);
    gap: var(--ds2-space-4);
}

body.ds2 .c-admin-title {
    font-family: var(--ds2-font-heading);
    font-size: var(--ds2-text-2xl);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 var(--ds2-space-1);
    letter-spacing: -0.02em;
}

body.ds2 .c-admin-subtitle {
    font-size: var(--ds2-text-sm);
    color: var(--text-secondary);
    margin: 0;
}


/* =============================================================================
   17. INTEGRATION ROW
   Platform connection status rows (Stripe, TikTok, etc.)
   Usage: <div class="c-integration-row">...</div>
   ============================================================================= */

body.ds2 .c-integration-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-surface);
    border-radius: var(--ds2-radius-lg);
    border: 1px solid var(--border-default);
    margin-bottom: var(--ds2-space-2);
}

body.ds2 .c-integration-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

body.ds2 .c-integration-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-page);
    border-radius: var(--ds2-radius-md);
    color: var(--text-secondary);
}

body.ds2 .c-integration-name {
    font-weight: 600;
    font-size: var(--ds2-text-sm);
    display: block;
    color: var(--text-primary);
}

body.ds2 .c-integration-status {
    display: block;
    margin-top: 2px;
    font-size: var(--ds2-text-xs);
    color: var(--text-muted);
}


/* =============================================================================
   18. LICENSE FEATURE GRID
   Feature catalog with unlock/lock state
   Usage: <div class="c-license-grid">...</div>
   ============================================================================= */

body.ds2 .c-license-cat-title {
    font-size: var(--ds2-text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 0 0 0.75rem;
}

body.ds2 .c-license-grid {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

body.ds2 .c-license-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

body.ds2 .c-license-item:last-child {
    border-bottom: none;
}

body.ds2 .c-license-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

body.ds2 .c-license-item.unlocked .c-license-dot {
    background: var(--interactive-primary);
}

body.ds2 .c-license-item.locked .c-license-dot {
    background: rgba(255, 255, 255, 0.15);
}

body.ds2 .c-license-name {
    flex: 1;
    font-size: var(--ds2-text-sm);
    color: var(--text-primary);
}

body.ds2 .c-license-item.locked .c-license-name {
    color: var(--text-muted);
}

body.ds2 .c-license-status {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

body.ds2 .c-license-status.unlocked {
    color: var(--interactive-primary);
}

body.ds2 .c-license-status.locked {
    color: var(--text-muted);
    opacity: 0.6;
}


/* =============================================================================
   19. BUNDLE CARD
   Feature bundle display with status and actions
   Usage: <div class="c-bundle-card">...</div>
   ============================================================================= */

body.ds2 .c-bundle-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

body.ds2 .c-bundle-info {
    flex: 1;
}

body.ds2 .c-bundle-name {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

body.ds2 .c-bundle-features {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

body.ds2 .c-bundle-chip {
    display: inline-block;
    padding: 3px 10px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--ds2-radius-full);
    font-size: var(--ds2-text-xs);
    color: var(--text-secondary);
}

body.ds2 .c-bundle-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}


/* =============================================================================
   20. FEATURE TAG (for subscription / plan features)
   Usage: <span class="c-feature-tag">Feature Name</span>
   ============================================================================= */

body.ds2 .c-feature-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--ds2-radius-full);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    font-size: var(--ds2-text-xs);
    line-height: 1.4;
}


/* =============================================================================
   21. SETTINGS TABS
   Horizontal tab nav for settings pages
   Usage: <nav class="c-settings-tabs">...</nav>
   ============================================================================= */

body.ds2 .c-settings-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-default);
    margin-bottom: var(--ds2-space-5);
}

body.ds2 .c-settings-tab {
    padding: 0.625rem 1rem;
    font-size: var(--ds2-text-sm);
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color var(--ds2-transition-fast), border-color var(--ds2-transition-fast);
}

body.ds2 .c-settings-tab:hover {
    color: var(--text-primary);
}

body.ds2 .c-settings-tab.active {
    color: var(--interactive-link);
    border-bottom-color: var(--interactive-link);
}


/* =============================================================================
   22. COMPLETE ICON (success checkmark circle)
   Usage: <div class="c-complete-icon">...</div>
   ============================================================================= */

body.ds2 .c-complete-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--color-success);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}


/* =============================================================================
   23. BUTTON VARIANTS
   4-variant system: primary (indigo CTA), secondary (outline), ghost, destructive
   Usage: <button class="c-btn c-btn-primary">Save</button>
   ============================================================================= */

body.ds2 .c-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-radius: var(--ds2-radius-lg);
    font-size: var(--ds2-text-sm);
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, transform 0.08s ease;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}

body.ds2 .c-btn:active {
    transform: scale(0.98);
}

body.ds2 .c-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Size variants */
body.ds2 .c-btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: var(--ds2-text-xs);
}

body.ds2 .c-btn-md {
    padding: 0.625rem 1.25rem;
}

body.ds2 .c-btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: var(--ds2-text-base);
}

/* Primary — indigo, main CTA. One per section. */
body.ds2 .c-btn-primary {
    background: var(--color-primary);
    color: var(--color-primary-text);
    border: 1px solid transparent;
    padding: 0.625rem 1.25rem;
}

body.ds2 .c-btn-primary:hover {
    background: var(--color-primary-hover);
}

/* Accent — amber/orange, for high-contrast marketing CTAs */
body.ds2 .c-btn-accent {
    background: var(--brand-accent);
    color: var(--ds2-zinc-950);
    border: 1px solid transparent;
    padding: 0.625rem 1.25rem;
}

body.ds2 .c-btn-accent:hover {
    background: #ea6c0a;
}

/* Secondary — outline, for secondary actions */
body.ds2 .c-btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-default);
    padding: 0.625rem 1.25rem;
    font-weight: 500;
}

body.ds2 .c-btn-secondary:hover {
    background: var(--bg-surface);
    border-color: var(--border-strong);
}

/* Ghost — no border, for tertiary actions, nav items */
body.ds2 .c-btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    padding: 0.5rem 0.75rem;
    font-weight: 500;
}

body.ds2 .c-btn-ghost:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

/* Destructive — red, for delete/remove actions */
body.ds2 .c-btn-destructive {
    background: var(--color-destructive-bg);
    color: var(--color-destructive);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 0.625rem 1.25rem;
}

body.ds2 .c-btn-destructive:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
}

/* Revenue — amber, for payment/purchase actions */
body.ds2 .c-btn-revenue {
    background: var(--color-revenue);
    color: #000;
    border: 1px solid transparent;
    padding: 0.625rem 1.25rem;
}

body.ds2 .c-btn-revenue:hover {
    background: var(--ds2-amber-600, #d97706);
}

/* Icon inside button */
body.ds2 .c-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}


/* =============================================================================
   24. FOCUS-VISIBLE GLOBAL STYLES
   Every interactive element gets visible keyboard focus ring
   ============================================================================= */

body.ds2 a:focus-visible,
body.ds2 button:focus-visible,
body.ds2 [role="button"]:focus-visible,
body.ds2 [tabindex]:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--ds2-radius-sm);
}

body.ds2 .c-tab:focus-visible,
body.ds2 .c-settings-tab:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

body.ds2 .c-page-link:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

body.ds2 .c-icon-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}


/* =============================================================================
   25. SKELETON LOADING
   CSS-only shimmer animation for loading placeholders
   Usage: <div class="c-skeleton c-skeleton-text"></div>
   ============================================================================= */

body.ds2 .c-skeleton {
    background: linear-gradient(90deg,
        var(--skeleton-base) 25%,
        var(--skeleton-shine) 50%,
        var(--skeleton-base) 75%
    );
    background-size: 200% 100%;
    animation: ds2-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--ds2-radius-sm);
    will-change: background-position;
}

body.ds2 .c-skeleton-text {
    height: 14px;
    width: 100%;
    margin-bottom: 0.5rem;
}

body.ds2 .c-skeleton-text.short {
    width: 60%;
}

body.ds2 .c-skeleton-heading {
    height: 24px;
    width: 40%;
    margin-bottom: 0.75rem;
}

body.ds2 .c-skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

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


/* =============================================================================
   26. CARD BASE
   Generic card container with containment for rendering performance
   Usage: <div class="c-card">...</div>
   ============================================================================= */

body.ds2 .c-card {
    background: var(--bg-surface);
    border: none;
    border-radius: var(--ds2-radius-xl);
    padding: var(--ds2-space-5);
    box-shadow: 0 0 0 1px var(--border-default);
    contain: layout style paint;
    transition: background 0.15s ease;
}

body.ds2 .c-card:hover {
    background: var(--bg-surface-raised);
}

body.ds2 .c-card__title {
    font-family: var(--ds2-font-heading);
    font-size: var(--ds2-text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--ds2-space-2);
    line-height: var(--leading-tight);
}

body.ds2 .c-card__description {
    font-size: var(--ds2-text-sm);
    color: var(--text-secondary);
    line-height: var(--leading-normal);
    margin: 0;
}

/* Hover-enhanced card — adds shadow elevation + subtle lift on hover */
body.ds2 .c-card-hover {
    box-shadow: var(--shadow-card);
    transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

body.ds2 .c-card-hover:hover {
    box-shadow: var(--shadow-card-hover);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

/* Non-interactive card (no hover) */
body.ds2 .c-card.static {
    transition: none;
}

body.ds2 .c-card.static:hover {
    border-color: var(--border-default);
    background: var(--bg-surface);
}


/* =============================================================================
   27. TOAST NOTIFICATION STYLES
   Semantic toast colors matching token system
   Usage: Applied via stdToast() in app.js with data-type attribute
   ============================================================================= */

body.ds2 .std-toast {
    border-radius: var(--ds2-radius-md);
    padding: 0.75rem 1rem;
    font-size: var(--ds2-text-sm);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: toast-slide-in 0.2s ease-out;
}

@keyframes toast-slide-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body.ds2 .std-toast.toast-success {
    background: var(--toast-success-bg);
    border: 1px solid var(--toast-success-border);
    color: var(--color-success);
}

body.ds2 .std-toast.toast-error {
    background: var(--toast-error-bg);
    border: 1px solid var(--toast-error-border);
    color: var(--text-primary);
}

body.ds2 .std-toast.toast-info {
    background: var(--toast-info-bg);
    border: 1px solid var(--toast-info-border);
    color: var(--color-info);
}


/* =============================================================================
   RESPONSIVE BREAKPOINTS
   ============================================================================= */

@media (max-width: 639px) {
    body.ds2 .c-stat-value {
        font-size: 1.75rem;
    }

    body.ds2 .c-two-col {
        grid-template-columns: 1fr;
    }

    body.ds2 .c-nav-grid {
        grid-template-columns: 1fr;
    }

    body.ds2 .c-page-header-row {
        flex-direction: column;
    }

    body.ds2 .c-admin-container {
        padding: var(--ds2-space-4);
    }

    body.ds2 .c-admin-header {
        flex-direction: column;
    }

    body.ds2 .c-search-bar {
        flex-direction: column;
    }

    body.ds2 .c-tab-bar {
        gap: 0;
    }

    body.ds2 .c-tab {
        padding: 0.625rem 0.75rem;
        font-size: var(--ds2-text-xs);
    }

    body.ds2 .c-bundle-card {
        flex-direction: column;
    }

    body.ds2 .c-bundle-actions {
        align-self: flex-start;
    }

    body.ds2 .c-integration-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    body.ds2 .c-settings-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    body.ds2 .c-settings-tab {
        white-space: nowrap;
        font-size: var(--ds2-text-xs);
    }
}

@media (max-width: 480px) {
    body.ds2 .c-stats-grid {
        grid-template-columns: 1fr;
    }
}

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

body.ds2 .c-skeleton {
    background: linear-gradient(90deg,
        var(--bg-surface) 25%,
        var(--bg-surface-raised) 50%,
        var(--bg-surface) 75%);
    background-size: 200% 100%;
    animation: ds2-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--ds2-radius-md);
}

body.ds2 .c-skeleton-text {
    height: 14px;
    margin-bottom: var(--ds2-space-2);
}

body.ds2 .c-skeleton-text.lg { height: 20px; }

body.ds2 .c-skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

body.ds2 .c-skeleton-card {
    height: 120px;
    border-radius: var(--ds2-radius-xl);
}

body.ds2 .c-skeleton-row {
    height: 48px;
    border-radius: var(--ds2-radius-sm);
    margin-bottom: var(--ds2-space-2);
}


/* =============================================================================
   21. AVATAR
   Circular avatar with initials, gradient, or image.
   Sizes: sm (28px), md (36px), lg (48px)
   ============================================================================= */

body.ds2 .c-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    font-family: var(--ds2-font-heading);
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
}
body.ds2 .c-avatar-sm { width: 28px; height: 28px; font-size: 10px; }
body.ds2 .c-avatar-md { width: 36px; height: 36px; font-size: 12px; }
body.ds2 .c-avatar-lg { width: 48px; height: 48px; font-size: 14px; }
body.ds2 .c-avatar-gradient {
    background: linear-gradient(135deg, var(--interactive-primary), #8b5cf6);
}
body.ds2 .c-avatar img {
    width: 100%; height: 100%; object-fit: cover;
}


/* =============================================================================
   22. TOAST NOTIFICATIONS
   Slide-in notifications for success, error, warning, info.
   ============================================================================= */

body.ds2 .c-toast {
    display: flex;
    align-items: center;
    gap: var(--ds2-space-3);
    padding: var(--ds2-space-3) var(--ds2-space-4);
    border-radius: var(--ds2-radius-lg);
    font-size: var(--ds2-text-sm);
    animation: ds2-slide-in-right 0.3s ease;
    box-shadow: var(--shadow-elevation-3);
}
body.ds2 .c-toast-success {
    background: var(--toast-success-bg);
    border: 1px solid var(--toast-success-border);
    color: var(--color-success);
}
body.ds2 .c-toast-error {
    background: var(--toast-error-bg);
    border: 1px solid var(--toast-error-border);
    color: var(--text-primary);
}
body.ds2 .c-toast-info {
    background: var(--toast-info-bg);
    border: 1px solid var(--toast-info-border);
    color: var(--color-info);
}
