/**
 * TrustLens Admin — Customer Detail (Analyst Grid redesign)
 *
 * Scoped to .wstl-customer-detail so tokens and styles do not leak to
 * other admin pages. Uses CSS custom properties for the color system.
 *
 * @package TrustLens
 */

/* ==========================================================================
   Container + design tokens
   ========================================================================== */

.wstl-customer-detail {
	--tl-bg-page:      #f8fafc;
	--tl-bg-tile:      #ffffff;
	--tl-border:       #e5e7eb;
	--tl-border-soft:  #f1f5f9;
	--tl-ink:          #0f172a;
	--tl-ink-muted:    #64748b;
	--tl-ink-faint:    #94a3b8;

	--tl-danger:       #dc2626;
	--tl-danger-soft:  #fee2e2;
	--tl-good:         #10b981;
	--tl-good-soft:    #d1fae5;

	background: var(--tl-bg-page);
	padding: 20px;
	margin: 20px 0 0 0;
	color: var(--tl-ink);
	border-radius: 8px;
}

.wstl-customer-detail,
.wstl-customer-detail * {
	box-sizing: border-box;
}

/* ==========================================================================
   Tile primitive — every boxed section on the page uses this
   ========================================================================== */

.wstl-cd-tile {
	background: var(--tl-bg-tile);
	border: 1px solid var(--tl-border);
	border-radius: 8px;
	padding: 16px;
	transition: border-color 0.15s ease;
}

.wstl-cd-tile:hover {
	border-color: var(--tl-ink-muted);
}

.wstl-cd-tile h3 {
	margin: 0 0 12px 0;
	padding: 0;
	border: none;
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--tl-ink-muted);
}

.wstl-cd-empty {
	margin: 0;
	font-size: 12px;
	color: var(--tl-ink-faint);
	font-style: italic;
}

/* ==========================================================================
   Zone 1 — Header strip
   ========================================================================== */

.wstl-cd-header {
	display: flex;
	align-items: center;
	gap: 20px;
	background: var(--tl-bg-tile);
	border: 1px solid var(--tl-border);
	border-radius: 8px;
	padding: 16px 20px;
	margin-bottom: 16px;
}

.wstl-cd-header-info {
	flex: 1;
	min-width: 0;
}

.wstl-cd-header-title {
	margin: 0 0 4px 0;
	padding: 0;
	border: none;
	font-size: 18px;
	font-weight: 700;
	color: var(--tl-ink);
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

.wstl-cd-header-meta {
	margin: 0;
	font-size: 12px;
	color: var(--tl-ink-muted);
}

.wstl-cd-header-actions {
	display: flex;
	gap: 8px;
	flex-shrink: 0;
	flex-wrap: wrap;
}

.wstl-customer-detail .wstl-cd-header-actions .button {
	border-radius: 6px;
}

/* Segment badges — reusable */
.wstl-cd-badge {
	display: inline-flex;
	align-items: center;
	padding: 3px 10px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	background: var(--tl-border-soft);
	color: var(--tl-ink);
}

.wstl-cd-badge.is-vip      { background: #dbeafe; color: #1e40af; }
.wstl-cd-badge.is-trusted  { background: var(--tl-good-soft); color: #065f46; }
.wstl-cd-badge.is-normal   { background: var(--tl-border-soft); color: var(--tl-ink-muted); }
.wstl-cd-badge.is-caution  { background: #fef3c7; color: #92400e; }
.wstl-cd-badge.is-risk     { background: var(--tl-danger-soft); color: #991b1b; }
.wstl-cd-badge.is-critical { background: #111827; color: #ffffff; }
.wstl-cd-badge.is-blocked  { background: #111827; color: #ffffff; }
.wstl-cd-badge.is-allowlist{ background: var(--tl-good-soft); color: #065f46; }

/* ==========================================================================
   Zone layout scaffolds (content-specific styles come in later tasks)
   ========================================================================== */

.wstl-cd-kpis {
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	gap: 12px;
	margin-bottom: 16px;
}

.wstl-cd-charts {
	display: grid;
	grid-template-columns: 1.2fr 1fr 1fr;
	gap: 12px;
	margin-bottom: 16px;
}

.wstl-cd-details {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
	margin-bottom: 16px;
}

/* ==========================================================================
   Responsive breakpoints
   ========================================================================== */

@media (max-width: 1099px) {
	.wstl-cd-kpis { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 899px) {
	.wstl-cd-kpis   { grid-template-columns: repeat(2, 1fr); }
	.wstl-cd-charts { grid-template-columns: 1fr 1fr; }
	.wstl-cd-charts > :first-child { grid-column: 1 / -1; }
	.wstl-cd-details{ grid-template-columns: 1fr; }
	.wstl-cd-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 699px) {
	.wstl-cd-kpis   { grid-template-columns: 1fr; }
	.wstl-cd-charts { grid-template-columns: 1fr; }
	.wstl-cd-charts > :first-child { grid-column: auto; }
}

/* ==========================================================================
   Zone 2 — KPI tiles
   ========================================================================== */

.wstl-cd-kpi {
	background: var(--tl-bg-tile);
	border: 1px solid var(--tl-border);
	border-radius: 8px;
	padding: 12px 14px;
	transition: border-color 0.15s ease;
}

.wstl-cd-kpi:hover {
	border-color: var(--tl-ink-muted);
}

.wstl-cd-kpi-label {
	font-size: 10px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--tl-ink-muted);
	margin: 0;
}

.wstl-cd-kpi-value {
	font-size: 22px;
	font-weight: 700;
	color: var(--tl-ink);
	line-height: 1;
	margin: 4px 0 4px 0;
	font-variant-numeric: tabular-nums;
}

.wstl-cd-kpi-value.is-danger { color: var(--tl-danger); }
.wstl-cd-kpi-value.is-good   { color: var(--tl-good); }

.wstl-cd-kpi-sub {
	font-size: 11px;
	color: var(--tl-ink-muted);
	margin: 0;
}

.wstl-cd-kpi-delta {
	font-size: 11px;
	font-weight: 600;
	margin: 2px 0 0 0;
}

.wstl-cd-kpi-delta.is-up   { color: var(--tl-danger); }
.wstl-cd-kpi-delta.is-down { color: var(--tl-good); }

/* ==========================================================================
   Zone 3 — Tile A: Trust Score Gauge
   ========================================================================== */

.wstl-cd-gauge-wrap {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 180px;
}

.wstl-cd-gauge-svg {
	width: 100%;
	max-width: 240px;
	height: auto;
}

.wstl-cd-gauge-bg {
	stroke: var(--tl-border-soft);
	stroke-width: 18;
	fill: none;
	stroke-linecap: round;
}

.wstl-cd-gauge-fill {
	stroke-width: 18;
	fill: none;
	stroke-linecap: round;
}

.wstl-cd-gauge-needle {
	stroke: var(--tl-ink);
	stroke-width: 3;
	stroke-linecap: round;
}

.wstl-cd-gauge-hub {
	fill: var(--tl-ink);
}

.wstl-cd-gauge-value {
	font-size: 40px;
	font-weight: 800;
	color: var(--tl-ink);
	line-height: 1;
	margin: -8px 0 4px 0;
	font-variant-numeric: tabular-nums;
}

.wstl-cd-gauge-label {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	margin: 0;
}

/* ==========================================================================
   Zone 3 — Tile B: Signal Impact bars
   ========================================================================== */

.wstl-cd-signals {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.wstl-cd-signal {
	display: grid;
	grid-template-columns: 110px 1fr 36px;
	align-items: center;
	gap: 8px;
	font-size: 12px;
}

.wstl-cd-signal-name {
	color: var(--tl-ink);
	font-weight: 500;
	text-align: right;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.wstl-cd-signal-track {
	position: relative;
	height: 14px;
	background: var(--tl-border-soft);
	border-radius: 3px;
}

.wstl-cd-signal-zero {
	position: absolute;
	top: -2px;
	bottom: -2px;
	left: 50%;
	width: 1px;
	background: var(--tl-ink-faint);
}

.wstl-cd-signal-fill {
	position: absolute;
	top: 0;
	bottom: 0;
}

.wstl-cd-signal-fill.is-pos {
	left: 50%;
	background: var(--tl-good);
	border-radius: 0 3px 3px 0;
}

.wstl-cd-signal-fill.is-neg {
	right: 50%;
	background: var(--tl-danger);
	border-radius: 3px 0 0 3px;
}

.wstl-cd-signal-value {
	text-align: right;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.wstl-cd-signal-value.is-pos { color: var(--tl-good); }
.wstl-cd-signal-value.is-neg { color: var(--tl-danger); }

/* ==========================================================================
   Zone 3 — Tile C: Return rate trend
   ========================================================================== */

.wstl-cd-trend-wrap {
	display: flex;
	flex-direction: column;
	justify-content: center;
	min-height: 160px;
}

.wstl-cd-trend-svg {
	width: 100%;
	height: 140px;
}

.wstl-cd-trend-guide {
	stroke: var(--tl-border-soft);
	stroke-width: 1;
}

.wstl-cd-trend-line {
	fill: none;
	stroke: var(--tl-danger);
	stroke-width: 2.5;
	stroke-linejoin: round;
	stroke-linecap: round;
}

/* ==========================================================================
   Zone 4 — Tile D: Activity feed
   ========================================================================== */

.wstl-cd-activity {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.wstl-cd-activity-item {
	display: flex;
	gap: 10px;
	padding: 8px 10px;
	background: var(--tl-border-soft);
	border-radius: 6px;
}

.wstl-cd-activity-icon {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: var(--tl-bg-tile);
	color: var(--tl-ink-muted);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.wstl-cd-activity-icon.is-refund {
	background: var(--tl-danger-soft);
	color: var(--tl-danger);
}

.wstl-cd-activity-icon.is-order {
	background: var(--tl-good-soft);
	color: var(--tl-good);
}

.wstl-cd-activity-body {
	flex: 1;
	min-width: 0;
}

.wstl-cd-activity-title {
	font-size: 13px;
	color: var(--tl-ink);
	font-weight: 500;
	margin: 0;
}

.wstl-cd-activity-meta {
	font-size: 11px;
	color: var(--tl-ink-muted);
	margin: 2px 0 0 0;
}

/* ==========================================================================
   Zone 4 — Tile E: Linked accounts
   ========================================================================== */

.wstl-cd-linked {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.wstl-cd-linked-item {
	padding: 10px 12px;
	background: var(--tl-border-soft);
	border: 1px solid var(--tl-border);
	border-radius: 6px;
}

.wstl-cd-linked-item.is-risky {
	background: var(--tl-danger-soft);
	border-color: #fecaca;
}

.wstl-cd-linked-top {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	margin-bottom: 4px;
}

.wstl-cd-linked-top a {
	font-weight: 600;
}

.wstl-cd-linked-meta {
	display: flex;
	gap: 14px;
	font-size: 11px;
	color: var(--tl-ink-muted);
}

.wstl-cd-linked-score {
	font-weight: 700;
}

/* ==========================================================================
   Admin notes (collapsible, below the grid)
   ========================================================================== */

.wstl-cd-notes {
	background: var(--tl-bg-tile);
	border: 1px solid var(--tl-border);
	border-radius: 8px;
	padding: 0;
	margin-top: 16px;
}

.wstl-cd-notes > summary {
	cursor: pointer;
	padding: 14px 16px;
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--tl-ink-muted);
	list-style: none;
	outline: none;
	user-select: none;
}

.wstl-cd-notes > summary::-webkit-details-marker { display: none; }

.wstl-cd-notes > summary::before {
	content: '▸';
	display: inline-block;
	margin-right: 8px;
	transition: transform 0.15s ease;
}

.wstl-cd-notes[open] > summary::before {
	transform: rotate(90deg);
}

.wstl-cd-notes-body {
	padding: 0 16px 16px 16px;
}

.wstl-cd-notes-existing {
	background: var(--tl-border-soft);
	padding: 12px;
	border-radius: 6px;
	white-space: pre-wrap;
	font-family: inherit;
	font-size: 13px;
	margin: 0 0 12px 0;
	color: var(--tl-ink);
}

.wstl-cd-notes-empty {
	color: var(--tl-ink-faint);
	font-style: italic;
	font-size: 12px;
	margin: 0 0 12px 0;
}

.wstl-cd-notes textarea {
	width: 100%;
	border-radius: 6px;
	border-color: var(--tl-border);
	font-size: 13px;
}
