/* =========================================================================
   TicketingSystem content building blocks — shared by the customer portal and the staff app:
   page header, section titles, cards and info lists, KPI tiles, compact lists, activity timelines,
   the filter/toolbar bar and small tags. Requires tokens.css; the app shell is in shell.css.
   ========================================================================= */

/* ---------- page header ------------------------------------------------- */
.page-header {
    margin-bottom: var(--ts-space-5);
    display: flex;
    flex-wrap: wrap;
    gap: var(--ts-space-4);
    align-items: flex-end;
    justify-content: space-between;
}

.page-header__left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.page-header__crumb { font-size: 0.8125rem; margin-bottom: 2px; }
.page-header__crumb a { color: var(--ts-text-muted); text-decoration: none; }
.page-header__crumb a:hover { color: var(--ts-accent-text); text-decoration: underline; }
.page-header h1 { margin: 0; font-size: 1.5rem; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.page-subtitle { color: var(--ts-text-muted); font-size: 0.95rem; margin-top: 2px; }

/* Ticket pages: number + status / priority / SLA chips on one line, the title underneath. */
.ticket-heading { display: flex; align-items: center; gap: var(--ts-space-3); flex-wrap: wrap; }
.ticket-title { font-size: 1.125rem; font-weight: 500; color: var(--ts-text); margin-top: 4px; overflow-wrap: anywhere; }

.page-header__actions {
    display: flex;
    gap: var(--ts-space-3);
    flex-wrap: wrap;
    align-items: center;
    margin-left: auto;
}

.section-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ts-text);
    margin: 0 0 var(--ts-space-3) 0;
}

/* ---------- cards (there is no DxCard in DevExpress Blazor) ------------- */
.portal-card,
.info-card {
    background: var(--ts-surface);
    border: 1px solid var(--ts-border);
    border-radius: var(--ts-radius-md);
    padding: var(--ts-space-4) var(--ts-space-5);
    box-sizing: border-box;
}

.portal-card--padded { padding: var(--ts-space-5); }

.info-card-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ts-text-muted);
    font-weight: 600;
    margin-bottom: 8px;
}

.info-list {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 6px 12px;
    font-size: 0.9rem;
    margin: 0;
}

.info-list dt { color: var(--ts-text-muted); font-weight: 500; }
.info-list dd { margin: 0; color: var(--ts-text); overflow-wrap: anywhere; }

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--ts-space-3);
}

.preformatted { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- small tags -------------------------------------------------- */
/* "Preventive" ticket-type tag */
.type-tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: var(--ts-radius-pill);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--ts-tag-preventive-text);
    background: rgba(13, 148, 136, 0.1);
    border: 1px solid rgba(13, 148, 136, 0.3);
    white-space: nowrap;
}

/* DevExpress grids' "No data to display": XAF's styles dim it to opacity 0.7, 4.38:1 on white (WCAG AA
   needs 4.5:1). Muted text at full opacity instead. Selectors match XAF's / the Fluent theme's own
   specificity (this file loads after them). Same contrast block as the tag tokens in tokens.css. */
.dxbl-grid .dxbl-grid-empty-data-area > span,
.dxbl-grid .dxbl-grid-empty-data-area > span.dxbl-grid-empty-data-not-found {
    opacity: 1;
    color: var(--ts-text-muted);
}

/* Count pill (tab headers, section titles) */
.tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 18px;
    padding: 0 6px;
    margin-left: 6px;
    border-radius: var(--ts-radius-pill);
    background: var(--ts-accent-soft);
    color: var(--ts-accent-text);
    font-size: 0.7rem;
    font-weight: 700;
}

/* ---------- filter / toolbar bar ---------------------------------------- */
.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ts-space-3);
    margin-bottom: var(--ts-space-4);
    background: var(--ts-surface);
    border: 1px solid var(--ts-border);
    border-radius: var(--ts-radius-md);
    padding: var(--ts-space-3) var(--ts-space-4);
}

.filters__group { display: flex; align-items: center; gap: 8px; }
.filters__label { font-size: 0.8125rem; color: var(--ts-text-muted); font-weight: 500; white-space: nowrap; }
.filters__search { flex: 1; min-width: 220px; max-width: 420px; margin-left: auto; }

.result-count { color: var(--ts-text-muted); font-size: 0.8125rem; margin-top: 8px; }

/* ---------- KPI tiles (KpiCard) ------------------------------------------ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--ts-space-4);
    margin-bottom: var(--ts-space-5);
}

.kpi-grid--compact { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.kpi-card-link { display: block; color: inherit; border-radius: var(--ts-radius-md); text-decoration: none; }
.kpi-card-link:hover { color: inherit; text-decoration: none; box-shadow: var(--ts-shadow-hover); }
.kpi-card-link:focus-visible { outline: 2px solid var(--ts-accent); outline-offset: 2px; }

.kpi-card {
    --kpi-tone: var(--ts-tone-neutral);
    position: relative;
    height: 100%;
    box-sizing: border-box;
    background: var(--ts-surface);
    border: 1px solid var(--ts-border);
    border-left: 4px solid var(--kpi-tone);
    border-radius: var(--ts-radius-md);
    padding: 14px 18px 16px;
    min-height: 104px;
    display: flex;
    flex-direction: column;
}

.kpi-card__top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }

.kpi-card__label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ts-text-muted);
    font-weight: 600;
}

.kpi-card__icon { font-size: 1.1rem; color: var(--kpi-tone); }

.kpi-card__value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    margin-top: 2px;
    color: var(--kpi-tone);
    font-variant-numeric: tabular-nums;
}

.kpi-card__caption { margin-top: 6px; font-size: 0.8125rem; color: var(--ts-text-muted); }

.kpi-card--info    { --kpi-tone: var(--ts-tone-info); }
.kpi-card--success { --kpi-tone: var(--ts-tone-success); }
.kpi-card--warning { --kpi-tone: var(--ts-tone-warning); }
.kpi-card--danger  { --kpi-tone: var(--ts-tone-danger); }
.kpi-card--neutral .kpi-card__value { color: var(--ts-text); }

/* ---------- dashboard panels + compact lists ------------------------------ */
.home-panels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--ts-space-4);
    align-items: start;
}

/* Several panels stacked in one column of .home-panels. */
.home-panels__stack { display: flex; flex-direction: column; gap: var(--ts-space-4); min-width: 0; }

.compact-list { list-style: none; margin: 0; padding: 0; }

.compact-list__item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px var(--ts-space-3);
    padding: 10px 0;
    border-bottom: 1px solid var(--ts-border);
}

.compact-list__item:last-child { border-bottom: none; }
/* Two lines per item: text on top, chips left-aligned underneath (same layout in every panel). */
.compact-list__main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 100%; }
.compact-list__title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compact-list__sub { color: var(--ts-text-muted); font-size: 0.8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compact-list__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.compact-list__label { font-size: 0.8125rem; color: var(--ts-text-muted); }
.compact-list__due { display: inline-flex; align-items: center; gap: 6px; }
.compact-list__due .ts-sla { flex-wrap: nowrap; }
.compact-list__empty { color: var(--ts-text-muted); font-size: 0.875rem; }

/* Recent activity (home pages) */
.activity-timeline {
    list-style: none;
    margin: 0;
    padding: 0 0 0 16px;
    border-left: 2px solid var(--ts-border);
}

.activity-timeline__item { position: relative; padding: 8px 0; }
.activity-timeline__item + .activity-timeline__item { border-top: 1px dashed var(--ts-border); }

.activity-timeline__dot {
    position: absolute;
    left: -22px;
    top: 13px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--ts-accent);
    border: 2px solid var(--ts-surface);
}

.activity-timeline__head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.activity-timeline__ticket { font-weight: 600; }
.activity-timeline__text { margin-top: 2px; overflow-wrap: anywhere; }
.activity-timeline__meta { color: var(--ts-text-muted); font-size: 0.8125rem; }

/* ---------- ticket conversation timeline (ticket pages) ------------------- */
.timeline {
    list-style: none;
    position: relative;
    margin: 0 0 0 8px;
    padding: 0 0 0 22px;
    border-left: 2px solid var(--ts-border);
}

.timeline-item { position: relative; padding-bottom: var(--ts-space-4); }
.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
    position: absolute;
    left: -29px;
    top: 8px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--ts-surface);
    box-shadow: 0 0 0 1px var(--ts-border);
    background: var(--ts-tone-neutral);
}

.timeline-dot.by-customer { background: var(--ts-accent); }
.timeline-dot.by-staff { background: var(--ts-tone-neutral); }
.timeline-dot.by-status { background: var(--ts-tone-success); }
.timeline-dot.by-work { background: var(--ts-status-inprogress); }
.timeline-dot.by-internal { background: var(--ts-tone-warning); }

.timeline-body {
    background: var(--ts-surface);
    border: 1px solid var(--ts-border);
    border-radius: var(--ts-radius-md);
    padding: 10px 14px;
}

.timeline-status { background: var(--ts-surface-page); }

.timeline-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: baseline;
    font-size: 0.875rem;
    margin-bottom: 4px;
}

.timeline-status .timeline-meta { margin-bottom: 0; }
.timeline-meta__when { color: var(--ts-text-muted); }
.timeline-attachments { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }

@media (max-width: 575.98px) {
    .home-panels { grid-template-columns: minmax(0, 1fr); }
    .page-header { flex-direction: column; align-items: stretch; }
    .page-header__actions { margin-left: 0; }
    .filters { padding: var(--ts-space-3); }
    .filters__group { width: 100%; }
    .filters__search { max-width: none; min-width: 0; margin-left: 0; width: 100%; }
    .info-list { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
    .info-list dt { margin-top: 6px; }
}
