/**
 * 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-tile:      #ffffff;
	--tl-border:       #e7ecf3;
	--tl-border-soft:  #f1f4f8;
	--tl-ink:          #1a2433;
	--tl-ink-muted:    #6b7a8d;
	--tl-ink-faint:    #9aa7b6;
	--tl-accent:       var(--wstl-color-primary, #3377EE);

	--tl-danger:       #B23A48;
	--tl-danger-soft:  #fbe9eb;
	--tl-good:         #1E7A46;
	--tl-good-soft:    #e7f3ec;
	--tl-warn:         #B88318;
	--tl-warn-soft:    #f9f0db;
	--tl-shadow-h:     0 6px 22px rgba(20, 40, 67, 0.08);

	background: none;
	padding: 0;
	margin: 16px 0 0 0;
	color: var(--tl-ink);
	border-radius: 0;
}

.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: 12px;
	padding: 18px;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.wstl-cd-tile:hover {
	border-color: #d4ddea;
	box-shadow: var(--tl-shadow-h);
}

.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 {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	gap: 9px;
	margin: 0;
	padding: 26px 18px;
	min-height: 120px;
	font-size: 13px;
	color: #7a8aa0;
	line-height: 1.5;
}
.wstl-cd-empty::before {
	content: "";
	width: 30px;
	height: 30px;
	flex: none;
	background: #aab6c6;
	-webkit-mask: var(--wstl-empty-icon) center / contain no-repeat;
	mask: var(--wstl-empty-icon) center / contain no-repeat;
}

/* ==========================================================================
   Segment badges — reusable (used by the linked-accounts tiles)
   ========================================================================== */

.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: var(--tl-good-soft); color: #155c36; }
.wstl-cd-badge.is-trusted  { background: #e8f0fe; color: #1d4ed8; }
.wstl-cd-badge.is-normal   { background: #eef2f6; color: var(--tl-ink-muted); }
.wstl-cd-badge.is-caution  { background: var(--tl-warn-soft); color: #8a6210; }
.wstl-cd-badge.is-risk     { background: #fdeede; color: #9a4a1d; }
.wstl-cd-badge.is-critical { background: var(--tl-danger-soft); color: #8e2c39; }
.wstl-cd-badge.is-blocked  { background: #2a2f3a; color: #ffffff; }
.wstl-cd-badge.is-allowlist{ background: var(--tl-good-soft); color: #155c36; }

/* ==========================================================================
   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; }
}

@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: 12px;
	padding: 14px 16px;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.wstl-cd-kpi:hover {
	border-color: #d4ddea;
	box-shadow: var(--tl-shadow-h);
}

.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: 12px;
	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;
}

/* Tags (canonical tags column, set by automation / bulk operations) */
.wstl-cd-tags {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin: 12px 0;
}
.wstl-cd-tags-label {
	font-size: 12px;
	font-weight: 600;
	color: var(--tl-muted, #6b7280);
	margin-right: 2px;
}
.wstl-cd-tag {
	display: inline-block;
	padding: 2px 9px;
	border-radius: 12px;
	font-size: 12px;
	font-weight: 600;
	background: #eef2ff;
	color: #3730a3;
}
