/* ================================================================
   TICKET SYNC — DESIGN SYSTEM v1.0
   ================================================================
   The single source of truth for the .ts-* classes used across
   every page. Loaded from includes/header.php so every page can
   use it.

   What this file DOES:
     - Defines .ts-page-header, .ts-action-bar, .ts-card,
       .ts-kv, .ts-timeline, .ts-empty, .ts-stat-strip, and
       related helpers.
     - Respects every CSS variable already defined in style.css:
       --bg-card, --border-color, --text-primary, --text-muted,
       --accent-color, --accent-color-rgb, --bg-light.
     - Respects dark mode ([data-theme="dark"], [data-bs-theme="dark"]).
     - Respects the user's accent color ([data-accent="..."]).

   What this file DOES NOT do:
     - Override .card, .btn, .badge, .table, .alert, .modal,
       .nav-tabs, or anything else in style.css.
     - Break any existing page. None of the current classes are
       renamed or removed. This file only ADDS new classes.

   Any page can adopt the new look by adding .ts-* classes to its
   markup. Pages that don't adopt it still render exactly as they
   always have.
   ================================================================ */

/* ================================================================
   1. ROOT TOKENS — local to this file so we never fight style.css
   ================================================================ */
   :root {
    --ts-radius:        10px;
    --ts-radius-sm:     6px;
    --ts-gap:           12px;
    --ts-gap-lg:        16px;
    --ts-dot-size:      12px;
    --ts-stage-pad:     10px 12px;
}

/* ================================================================
   2. PAGE HEADER
   ================================================================
   <div class="ts-page-header">
     <div class="ts-header-title">
       <h2>…</h2>
       <div class="ts-header-sub">…</div>
     </div>
     <div class="ts-header-badges">…badges…</div>
     <div class="ts-header-actions">…buttons…</div>
   </div>
   ================================================================ */
.ts-page-header {
    display: flex;
    align-items: center;
    gap: var(--ts-gap);
    flex-wrap: wrap;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: var(--ts-gap-lg);
}
.ts-header-title { flex: 1 1 240px; min-width: 0; }
.ts-header-title h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
    line-height: 1.25;
}
.ts-header-title h2 i {
    color: var(--accent-color);
    margin-right: 6px;
}
.ts-header-sub {
    font-size: .82rem;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.4;
}
.ts-header-badges {
    display: flex;
    gap: 0;
    flex-wrap: wrap;
    align-items: center;
}

/* ================================================================
   HEADER STAT SUMMARY (.ts-chip)
   ================================================================
   Not the KPI tiles (.ts-stat-strip) and not badges: a compact summary
   of counts in the page header. Values are separated by hairlines —
   coloured tabular number + small-caps label. Reads as metadata, stays
   legible in both themes, and never competes with the page content the
   way saturated pills did.
   ================================================================ */
.ts-chip {
    --chip: #6c757d;
    display: inline-flex;
    align-items: baseline;
    gap: .4rem;
    padding: 0 .95rem;
    border: 0;
    border-left: 1px solid var(--border-color);
    border-radius: 0;
    background: none;
    line-height: 1.15;
    white-space: nowrap;
}
.ts-chip:first-child {
    padding-left: 0;
    border-left: 0;
}
.ts-chip:last-child {
    padding-right: 0;
}
.ts-chip--primary   { --chip: var(--accent-color); }
.ts-chip--info      { --chip: #0aa2c0; }
.ts-chip--success   { --chip: #198754; }
.ts-chip--warning   { --chip: #b8860b; }
.ts-chip--danger    { --chip: #dc3545; }
.ts-chip--secondary { --chip: #6c757d; }
.ts-chip--dark      { --chip: #495057; }

/* The dot was part of the old chip design; the strip does not use it. */
.ts-chip-dot {
    display: none;
}
.ts-chip-num {
    font-size: 1.02rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--chip);
}
.ts-chip-label {
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* Brighter tints so coloured numbers keep contrast on dark surfaces. */
[data-theme="dark"] .ts-chip--primary,
[data-bs-theme="dark"] .ts-chip--primary   { --chip: var(--accent-color); }
[data-theme="dark"] .ts-chip--info,
[data-bs-theme="dark"] .ts-chip--info      { --chip: #6edff6; }
[data-theme="dark"] .ts-chip--success,
[data-bs-theme="dark"] .ts-chip--success   { --chip: #75b798; }
[data-theme="dark"] .ts-chip--warning,
[data-bs-theme="dark"] .ts-chip--warning   { --chip: #ffcd39; }
[data-theme="dark"] .ts-chip--danger,
[data-bs-theme="dark"] .ts-chip--danger    { --chip: #f1aeb5; }
[data-theme="dark"] .ts-chip--secondary,
[data-bs-theme="dark"] .ts-chip--secondary { --chip: #adb5bd; }
[data-theme="dark"] .ts-chip--dark,
[data-bs-theme="dark"] .ts-chip--dark      { --chip: #dee2e6; }
.ts-header-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ================================================================
   3. ACTION BAR
   ================================================================
   <div class="ts-action-bar">
     <a class="btn">…</a>
   </div>
   ================================================================ */
.ts-action-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--ts-radius);
    margin-bottom: var(--ts-gap-lg);
}
.ts-action-bar .btn {
    font-size: .82rem;
    font-weight: 600;
    border-radius: 8px;
    padding: 8px 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ================================================================
   4. CARD
   ================================================================
   <div class="ts-card">
     <div class="ts-card-header">
       <span><i class="…"></i> Title</span>
       <span class="badge">3</span>
     </div>
     <div class="ts-card-body">…</div>
   </div>
   ================================================================ */
.ts-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--ts-radius);
    margin-bottom: var(--ts-gap-lg);
    overflow: hidden;
}
.ts-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
    font-size: .82rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: .4px;
    gap: 8px;
    flex-wrap: wrap;
}
.ts-card-header > span:first-child {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.ts-card-header i { color: var(--accent-color); }
.ts-card-header .badge {
    font-size: .65rem;
    padding: 3px 8px;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
}
.ts-card-header .ts-card-header-actions {
    display: inline-flex;
    gap: 4px;
    text-transform: none;
    letter-spacing: 0;
}
.ts-card-body { padding: 14px; }
.ts-card-body.p-0 { padding: 0; }

/* ================================================================
   5. KEY-VALUE GRID
   ================================================================
   <dl class="ts-kv">
     <dt>Label</dt><dd>Value</dd>
   </dl>
   ================================================================ */
.ts-kv {
    display: grid;
    grid-template-columns: minmax(120px, 40%) 1fr;
    gap: 8px 14px;
    font-size: .85rem;
    margin: 0;
}
.ts-kv dt {
    color: var(--text-muted);
    font-weight: 600;
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .3px;
    margin: 0;
    padding-top: 2px;
}
.ts-kv dd {
    margin: 0;
    color: var(--text-primary);
    word-break: break-word;
    line-height: 1.45;
}
.ts-kv dd.empty {
    color: var(--text-muted);
    font-style: italic;
}
.ts-kv hr {
    grid-column: 1 / -1;
    border: 0;
    border-top: 1px dashed var(--border-color);
    margin: 4px 0;
}

/* ================================================================
   6. STAT STRIP (Option B — one horizontal row of tiles)
   ================================================================
   <div class="ts-stat-strip">
     <div class="ts-stat">
       <div class="ts-stat-value">47</div>
       <div class="ts-stat-label">Total</div>
     </div>
     <div class="ts-stat ts-stat-primary">…</div>
   </div>
   ================================================================ */
.ts-stat-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--ts-radius);
    overflow: hidden;
    margin-bottom: var(--ts-gap-lg);
}
.ts-stat {
    padding: 14px 12px;
    text-align: center;
    border-right: 1px solid var(--border-color);
    transition: background .15s ease;
    min-width: 0;
}
.ts-stat:last-child { border-right: none; }
.ts-stat:hover { background: var(--bg-light); }
.ts-stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.1;
    color: var(--text-primary);
    letter-spacing: -.5px;
}
.ts-stat-label {
    font-size: .68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-top: 4px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ts-stat.ts-stat-primary   .ts-stat-value { color: #0d6efd; }
.ts-stat.ts-stat-warning   .ts-stat-value { color: #ffc107; }
.ts-stat.ts-stat-info      .ts-stat-value { color: #0dcaf0; }
.ts-stat.ts-stat-success   .ts-stat-value { color: #198754; }
.ts-stat.ts-stat-danger    .ts-stat-value { color: #dc3545; }
.ts-stat.ts-stat-secondary .ts-stat-value { color: #6c757d; }
.ts-stat.ts-stat-muted     .ts-stat-value { color: var(--text-muted); }

/* Compact variant for use inside cards */
.ts-stat-strip.ts-stat-compact .ts-stat { padding: 10px 8px; }
.ts-stat-strip.ts-stat-compact .ts-stat-value { font-size: 1.15rem; }
.ts-stat-strip.ts-stat-compact .ts-stat-label { font-size: .6rem; }

/* ================================================================
   7. EXPLAINER TIMELINE
   ================================================================
   <div class="ts-timeline">
     <details class="ts-stage">
       <summary class="ts-stage-summary">
         <span class="ts-dot"></span>
         <span class="ts-stage-body">
           <span class="ts-stage-title">…</span>
           <span class="ts-stage-meta">…</span>
         </span>
         <span class="ts-stage-toggle"><i class="bi bi-chevron-down"></i></span>
       </summary>
       <div class="ts-stage-detail">…</div>
     </details>
   </div>
   ================================================================ */
.ts-timeline {
    position: relative;
    padding-left: 22px;
    border-left: 2px solid var(--border-color);
    margin-left: 6px;
}
.ts-stage {
    position: relative;
    margin-bottom: 8px;
}
.ts-stage:last-child { margin-bottom: 0; }
.ts-stage-summary {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: var(--ts-stage-pad);
    border-radius: var(--ts-radius);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    cursor: pointer;
    list-style: none;
    transition: background .15s ease, border-color .15s ease;
}
.ts-stage-summary::-webkit-details-marker { display: none; }
.ts-stage-summary:hover {
    background: var(--bg-light);
    border-color: rgba(var(--accent-color-rgb), 0.30);
}
.ts-dot {
    width: var(--ts-dot-size);
    height: var(--ts-dot-size);
    border-radius: 50%;
    flex-shrink: 0;
    position: absolute;
    left: -30px;
    top: 14px;
    background: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(var(--accent-color-rgb), 0.15);
}
.ts-stage-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.ts-stage-title {
    font-weight: 700;
    font-size: .88rem;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.ts-stage-title i {
    color: var(--accent-color);
}
.ts-stage-meta {
    font-size: .72rem;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    align-items: center;
}
.ts-stage-meta span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
.ts-stage-meta i {
    color: var(--text-muted);
    font-size: .65rem;
    opacity: .75;
}
.ts-stage-toggle {
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform .2s ease;
    font-size: .8rem;
    align-self: center;
}
.ts-stage[open] .ts-stage-toggle { transform: rotate(180deg); }
.ts-stage-detail {
    margin-top: 6px;
    padding: 10px 14px;
    background: var(--bg-light);
    border-left: 3px solid var(--accent-color);
    border-radius: 0 var(--ts-radius) var(--ts-radius) 0;
    font-size: .82rem;
    color: var(--text-primary);
}
.ts-stage-detail p:last-child { margin-bottom: 0; }

/* Diff bullets (used by asset edit events) */
.ts-diff-list {
    list-style: none;
    margin: 6px 0;
    padding: 0;
}
.ts-diff-list li {
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(255,193,7,.10);
    margin-bottom: 4px;
    font-size: .78rem;
}
.ts-diff-list li:last-child { margin-bottom: 0; }
.ts-diff-list .old { color: #dc3545; text-decoration: line-through; }
.ts-diff-list .arrow { color: var(--text-muted); margin: 0 6px; }
.ts-diff-list .new { color: #198754; font-weight: 600; }

/* ================================================================
   8. EMPTY STATE
   ================================================================
   <div class="ts-empty">
     <i class="bi bi-inbox"></i>
     <h6>No records</h6>
     <p>Explanation</p>
   </div>
   ================================================================ */
.ts-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
    font-size: .85rem;
    line-height: 1.5;
}
.ts-empty i {
    display: block;
    font-size: 2.5rem;
    color: var(--text-muted);
    opacity: .35;
    margin-bottom: 8px;
}
.ts-empty h6 {
    font-weight: 700;
    font-size: .95rem;
    color: var(--text-primary);
    margin: 0 0 4px 0;
}
.ts-empty p {
    margin: 0;
    font-size: .8rem;
    color: var(--text-muted);
}
.ts-empty.ts-empty-sm {
    padding: 20px 12px;
}
.ts-empty.ts-empty-sm i { font-size: 1.8rem; }

/* ================================================================
   9. PERSON CARD (used in every sidebar)
   ================================================================ */
.ts-person-card { padding: 14px; }
.ts-person-card .ts-avatar {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent-color);
    background: var(--bg-light);
    flex-shrink: 0;
}
.ts-person-card .ts-avatar-lg {
    width: 96px; height: 96px;
}
.ts-person-card .ts-person-name {
    font-weight: 700;
    font-size: .98rem;
    line-height: 1.2;
    color: var(--text-primary);
}
.ts-person-card .ts-person-role {
    font-size: .7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
}
.ts-person-card .ts-person-meta {
    font-size: .82rem;
    color: var(--text-secondary);
    word-break: break-word;
}
.ts-person-card .ts-person-meta i {
    width: 16px;
    text-align: center;
    color: var(--text-muted);
    margin-right: 5px;
}

/* ================================================================
   10. FIELD LABELS inside forms
   ================================================================ */
.ts-field-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 6px;
    display: block;
}
.ts-field-hint {
    font-size: .72rem;
    color: var(--text-muted);
}

/* ================================================================
   11. STICKY RIGHT RAIL
   ================================================================ */
@media (min-width: 992px) {
    .ts-rail-sticky { position: sticky; top: 76px; }
}

/* ================================================================
   12. LAPTOP 1366 SAFETY — tighten spacing below 1366px
   ================================================================ */
@media (max-width: 1366px) {
    .ts-page-header h2 { font-size: 1.2rem; }
    .ts-action-bar .btn { padding: 6px 10px; font-size: .75rem; }
    .ts-kv { font-size: .8rem; }
    .ts-stat { padding: 12px 8px; }
    .ts-stat-value { font-size: 1.3rem; }
    .ts-stat-label { font-size: .62rem; }
}

/* ================================================================
   13. DARK MODE — the CSS vars already flip via style.css, but a few
       shadow / border values need a small nudge to stay readable.
   ================================================================ */
[data-theme="dark"] .ts-card,
[data-bs-theme="dark"] .ts-card {
    border-color: var(--border-color);
}
[data-theme="dark"] .ts-stat-strip,
[data-bs-theme="dark"] .ts-stat-strip {
    border-color: var(--border-color);
}
[data-theme="dark"] .ts-stage-detail,
[data-bs-theme="dark"] .ts-stage-detail {
    background: var(--bg-light);
}
[data-theme="dark"] .ts-diff-list li,
[data-bs-theme="dark"] .ts-diff-list li {
    background: rgba(255,193,7,.08);
}

/* ================================================================
   14. FORCE ICON CONSISTENCY
   ================================================================
   Both Bootstrap Icons (bi bi-*) and Font Awesome (fas fa-*) are
   loaded. This rule makes sure any icon inside a .ts-* component
   has predictable spacing.
   ================================================================ */
.ts-page-header i,
.ts-card-header i,
.ts-stage-title i,
.ts-stage-meta i,
.ts-empty i,
.ts-person-card i {
    line-height: 1;
}
