/* CARE Dashboard Kit — Components
 *
 * Shared Button, Status-Chip, and Card shells. Token-only; page templates
 * must not redefine these bases. Canonical names: btn-care, status-chip,
 * hc-card. Handover aliases (.hc-btn, .hc-chip) share the same rules.
 */

/* --- Button (Figma: Button, Tiers Primary/Secondary/Tertiary/Ghost) --- */
.btn-care,
.hc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: 40px;
    padding: 10px var(--space-4);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-family: var(--oc-font-sans);
    font-size: var(--type-label-button-size);
    font-weight: var(--type-label-button-weight);
    line-height: var(--type-label-button-line-height);
    letter-spacing: var(--type-label-button-letter-spacing);
    text-box-trim: var(--type-text-box-trim);
    text-box-edge: var(--type-text-box-edge);
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
}

.btn-care:disabled,
.hc-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-care-primary {
    background-color: var(--action-primary-background);
    color: var(--action-primary-on-background);
}

.btn-care-secondary,
.hc-btn-secondary {
    background-color: var(--action-secondary-background);
    border-color: var(--action-secondary-border);
    color: var(--action-secondary-foreground);
}

.btn-care-tertiary,
.hc-btn-tertiary {
    background-color: var(--action-tertiary-background);
    border-color: var(--action-tertiary-border);
    color: var(--action-tertiary-foreground);
}

.btn-care-ghost {
    background-color: transparent;
    color: var(--text-primary);
}

/* Outline secondary: transparent fill, brand-blue border and label.
   Filled `.btn-care-secondary` stays for in-app actions. */
.btn-care-outline {
    background-color: transparent;
    border-color: var(--action-secondary-border);
    color: var(--brand-secondary);
}

.btn-care-outline:hover:not(:disabled) {
    background-color: color-mix(in srgb, var(--brand-secondary) 8%, var(--surface-card));
    border-color: var(--action-secondary-border-hover);
    color: var(--brand-secondary);
}

.btn-care-ghost:hover:not(:disabled),
.btn-care-tertiary:hover:not(:disabled),
.hc-btn-tertiary:hover:not(:disabled) {
    background-color: var(--chrome-hover);
}

.btn-care-sm,
.hc-btn-sm {
    height: 32px;
    padding: 6px var(--space-3);
    font-size: var(--type-body-sm-size);
}

/* --- Status Chip (Figma: Status Chip / Badge) --- */
.status-chip,
.hc-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 4px var(--space-3);
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    font-family: var(--oc-font-sans);
    font-size: var(--type-label-badge-size);
    font-weight: var(--type-label-badge-weight);
    line-height: var(--type-label-badge-line-height);
    letter-spacing: var(--type-label-badge-letter-spacing);
    text-box-trim: var(--type-text-box-trim);
    text-box-edge: var(--type-text-box-edge);
    white-space: nowrap;
    overflow: hidden;
}

/* In narrow columns truncate the label; the status dot stays visible. */
.status-chip > span,
.hc-chip > span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-chip::before,
.hc-chip::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: currentColor;
    flex-shrink: 0;
}

/* Figma Status Tag property Indicator = Off. */
.status-chip.no-indicator::before,
.hc-chip.no-indicator::before {
    content: none;
}

.status-chip.tone-neutral,
.hc-chip.tone-neutral {
    background-color: var(--status-neutral-background);
    border-color: var(--status-neutral-border);
    color: var(--status-neutral-foreground);
}

.status-chip.tone-attention,
.hc-chip.tone-attention {
    background-color: var(--status-attention-background);
    border-color: var(--status-attention-border);
    color: var(--status-attention-foreground);
}

.status-chip.tone-info,
.hc-chip.tone-info {
    background-color: var(--status-info-background);
    border-color: var(--status-info-border);
    color: var(--status-info-foreground);
}

.status-chip.tone-success,
.hc-chip.tone-success {
    background-color: var(--status-success-background);
    border-color: var(--status-success-border);
    color: var(--status-success-foreground);
}

.status-chip.tone-critical,
.hc-chip.tone-critical {
    background-color: var(--status-critical-background);
    border-color: var(--status-critical-border);
    color: var(--status-critical-foreground);
}

.status-chip-sm {
    height: var(--space-5);
    padding: var(--space-1) var(--space-2);
    gap: var(--space-1);
    font-size: var(--type-label-tag-sm-size);
    font-weight: var(--type-label-tag-weight);
    line-height: var(--type-label-tag-line-height);
    letter-spacing: var(--type-label-tag-letter-spacing);
    text-transform: uppercase;
}

/* --- Filter Pill (Figma: Filter Pill) --- */
.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 4px 6px 4px 10px;
    border: 1px solid var(--filter-pill-border);
    border-radius: var(--radius-pill);
    background-color: var(--filter-pill-background);
    color: var(--filter-pill-foreground);
    font-family: var(--oc-font-sans);
    font-size: var(--type-caption-size);
    font-weight: var(--type-caption-weight);
    line-height: var(--type-caption-line-height);
    letter-spacing: var(--type-caption-letter-spacing);
}

.filter-pill-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-pill.is-action {
    cursor: pointer;
}

.filter-pill-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--filter-pill-close);
    cursor: pointer;
}

.filter-pill-remove:hover,
.filter-pill-remove:focus-visible {
    background-color: var(--chrome-hover);
}

.filter-pill-remove:focus-visible {
    outline: 2px solid var(--navigation-focus-ring);
    outline-offset: 1px;
}

/* --- Table pagination items (Figma: Pagination / Item) --- */
.table-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    background-color: var(--surface-default);
    color: var(--navigation-foreground-default);
    font-family: var(--oc-font-sans);
    font-size: var(--type-body-size);
    line-height: 1;
    cursor: pointer;
}

.table-page-btn:hover:not(:disabled) {
    background-color: var(--chrome-hover);
}

.table-page-btn:focus-visible {
    outline: 2px solid var(--navigation-focus-ring);
    outline-offset: 1px;
}

.table-page-btn:disabled {
    color: var(--navigation-disabled-foreground);
    opacity: 0.55;
    cursor: not-allowed;
}

/* --- Card (Figma: Card / Header+Body, Card / Multi-Section) --- */
.hc-card {
    background-color: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.hc-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-3);
    padding: 20px var(--space-6);
    border-bottom: 1px solid var(--border-default);
}

.hc-card-title {
    margin: 0;
    font-family: var(--oc-font-sans);
    font-size: var(--type-card-title-size);
    font-weight: var(--type-card-title-weight);
    line-height: var(--type-card-title-line-height);
    letter-spacing: var(--type-card-title-letter-spacing);
    text-box-trim: var(--type-text-box-trim);
    text-box-edge: var(--type-text-box-edge);
    color: var(--text-primary);
}

.hc-card-section {
    padding: 20px var(--space-6);
    border-bottom: 1px solid var(--border-default);
}

.hc-card-section:last-child {
    border-bottom: none;
}

@media (max-width: 1100px) {
    .hc-card-header,
    .hc-card-section {
        padding: 16px var(--space-4);
    }
}

@media (max-width: 768px) {
    .hc-card-header,
    .hc-card-section {
        padding: 14px var(--space-3);
    }
}

@media (max-width: 576px) {
    .hc-card-header,
    .hc-card-section {
        padding: 12px var(--space-3);
    }
}

/* --- Evidence gallery (Cases + Case Handover) --- */
.evidence-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}
.evidence-gallery-empty {
    margin: 0;
    font-size: var(--type-body-sm-size);
    font-weight: var(--type-body-sm-weight);
    line-height: var(--type-body-sm-line-height);
    letter-spacing: var(--type-body-sm-letter-spacing);
    color: var(--text-secondary);
}
.evidence-thumb {
    display: block;
    width: 72px;
    height: 72px;
    padding: 0;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    overflow: hidden;
    /* Placeholder behind the image — stays subtle, as the former 4% black did. */
    background: var(--surface-default);
    cursor: pointer;
}
.evidence-thumb:focus-visible {
    outline: 2px solid var(--action-secondary-background);
    outline-offset: 2px;
}
.evidence-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.evidence-overlay {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
    /* Scrim: deliberate hardcode — no overlay/scrim token (same as .sidebar-overlay). */
    background: rgba(48, 48, 48, 0.82);
}
.evidence-overlay.is-open {
    display: flex;
}
.evidence-overlay-dialog {
    position: relative;
    max-width: min(920px, 100%);
    max-height: min(90vh, 100%);
}
.evidence-overlay-img {
    display: block;
    max-width: 100%;
    max-height: min(84vh, 900px);
    width: auto;
    height: auto;
    border-radius: var(--radius-md);
    background: var(--is4it-black);
    object-fit: contain;
}
.evidence-overlay-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--surface-card);
    color: var(--text-primary);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(48, 48, 48, 0.25);
}

/* --- Context Bar (Figma: Context Bar Compact) --- */
.context-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    min-height: 64px;
    padding: 10px var(--space-4);
    background-color: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
}
.context-bar-copy {
    min-width: 0;
}
.context-bar-text,
.context-bar-hint {
    margin: 0;
    font-size: var(--type-caption-size);
    font-weight: var(--type-caption-weight);
    line-height: var(--type-caption-line-height);
    letter-spacing: var(--type-caption-letter-spacing);
    color: var(--text-secondary);
}
.context-bar-hint {
    margin-top: var(--space-1);
    color: var(--status-attention-foreground);
}

/* --- KPI Tile (Figma: KPI / Tile Size=M) --- */
.kpi-tile {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    min-width: 0;
    padding: var(--space-5) var(--space-6);
    background-color: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    color: inherit;
    text-decoration: none;
}
a.kpi-tile:hover {
    box-shadow: inset 0 0 0 1px var(--border-strong);
    color: inherit;
    text-decoration: none;
}
a.kpi-tile:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--action-secondary-focus-ring);
}
.kpi-tile-label {
    margin: 0;
    font-size: var(--type-caption-size);
    font-weight: var(--type-caption-weight);
    line-height: var(--type-caption-line-height);
    letter-spacing: var(--type-caption-letter-spacing);
    color: var(--text-secondary);
}
.kpi-tile-value {
    margin: 0;
    font-size: var(--type-metric-large-size);
    font-weight: var(--type-metric-large-weight);
    line-height: var(--type-metric-large-line-height);
    letter-spacing: var(--type-metric-large-letter-spacing);
    color: var(--text-primary);
}
.kpi-tile-helper {
    margin: 0;
    font-size: var(--type-caption-size);
    font-weight: var(--type-caption-weight);
    line-height: var(--type-caption-line-height);
    letter-spacing: var(--type-caption-letter-spacing);
    color: var(--text-secondary);
}
.kpi-tile-helper--attention {
    color: var(--status-attention-foreground);
}
.kpi-tile--error {
    border-color: var(--status-critical-foreground);
}
.kpi-tile-retry {
    align-self: flex-start;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--status-critical-foreground);
    font-size: var(--type-label-size);
    font-weight: var(--type-label-weight);
    letter-spacing: var(--type-label-letter-spacing);
    text-transform: uppercase;
    cursor: pointer;
}
.kpi-tile-retry:focus-visible {
    outline: 2px solid var(--action-secondary-focus-ring);
    outline-offset: 2px;
}
.kpi-tile-skel {
    display: block;
    background-color: var(--text-secondary);
    opacity: 0.18;
    border-radius: var(--radius-md);
    animation: hc-pulse 1.6s ease-in-out infinite;
}
.kpi-tile-skel--label { width: 42%; height: 12px; }
.kpi-tile-skel--value { width: 56%; height: 34px; }
.kpi-tile-skel--helper { width: 68%; height: 12px; }
@media (prefers-reduced-motion: reduce) {
    .kpi-tile-skel { animation: none; }
}

/* --- Empty State (Figma: Empty State; Deny on KPI Hub) --- */
.care-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-3);
    max-width: 520px;
    margin: 72px auto;
    padding: var(--space-6);
}
.care-empty-state-icon {
    color: var(--text-secondary);
    font-size: 2rem;
}
.care-empty-state-title {
    margin: 0;
    font-size: var(--type-size-24);
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}
.care-empty-state-body {
    margin: 0;
    font-size: var(--type-body-size);
    font-weight: var(--type-body-weight);
    line-height: var(--type-body-line-height);
    color: var(--text-secondary);
}
