/* Sahla Commande — customer dashboard (habits + reorder suggestions).
   Loaded on top of frontend.css, so it reuses the custom properties printed by
   Assets::enqueue() and the .sahla-btn / .sahla-badge-pro primitives instead of
   redefining them. Prefix is `sahla-cdash-` and not `sahla-dashboard-`, which
   belongs to the wp-admin screens in admin.css.

   Mobile first: this shop's traffic is mostly mid-range Android at 360–390 px,
   and the popup gives the panel ~312 px of usable width there. Everything below
   is written for that width and only widened at breakpoints. */

.sahla-cdash {
	display: flex;
	flex-direction: column;
	gap: 14px;
	color: var(--sahla-ink, #17120C);
	/* The panel lives inside .sahla-modal, which already scrolls vertically.
	   Clamping the width here is what keeps a long product name from pushing
	   the dialog sideways instead of wrapping. */
	max-width: 100%;
}

.sahla-cdash h3 {
	margin: 0 0 6px;
	font-size: 1.05em;
	line-height: 1.3;
}

.sahla-cdash p {
	margin: 0 0 8px;
}

.sahla-cdash-panel {
	padding: 14px;
	border: 1px solid #EFE4D6;
	border-radius: var(--sahla-radius, 22px);
	background: var(--sahla-paper, #FFFDF9);
}

.sahla-cdash-hint {
	margin: 6px 0 0;
	font-size: 0.85em;
	color: var(--sahla-muted, #5B4F42);
}

.sahla-cdash-gate,
.sahla-cdash-empty {
	padding: 18px 14px;
	text-align: center;
}

/* --- One-tap reorder ---------------------------------------------------- */

/* Stacked on a phone: a button sharing a row with two lines of text at 360 px
   ends up ~120 px wide and reads as secondary, which is the opposite of what
   this action is. */
.sahla-cdash-repeat {
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--sahla-cream, #FFF4E8);
	border-color: #F0D9BE;
}

.sahla-cdash-repeat-text p {
	margin: 0;
	font-size: 0.9em;
	color: var(--sahla-muted, #5B4F42);
}

.sahla-cdash-repeat-btn {
	width: 100%;
}

.sahla-cdash-feedback:empty {
	display: none;
}

.sahla-cdash-feedback {
	margin: 0;
	padding: 10px 12px;
	border-radius: var(--sahla-radius, 22px);
	background: var(--sahla-cream, #FFF4E8);
	font-size: 0.9em;
}

.sahla-cdash-feedback.is-error {
	background: #FDE8E5;
	color: #8A1B10;
}

/* --- Reference lists ---------------------------------------------------- */

.sahla-cdash-list {
	list-style: none;
	margin: 10px 0 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.sahla-cdash-item {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	padding: 10px;
	border: 1px solid #F1E7DA;
	border-radius: 14px;
	background: #fff;
}

/* A left rule rather than a coloured background: the overdue rows are the ones
   the customer acts on, and tinting the whole card makes the price and the
   button harder to read on a cheap screen in daylight. */
.sahla-cdash-item.is-overdue {
	border-left: 4px solid var(--sahla-primary, #FF741F);
}

.sahla-cdash-thumb {
	flex: 0 0 auto;
	width: 48px;
	height: 48px;
	border-radius: 10px;
	overflow: hidden;
	background: var(--sahla-cream, #FFF4E8);
}

.sahla-cdash-thumb img {
	width: 48px;
	height: 48px;
	max-width: 100%;
	object-fit: cover;
	display: block;
}

.sahla-cdash-body {
	display: flex;
	flex-direction: column;
	gap: 4px;
	/* min-width:0 on a flex child is what actually lets the text wrap instead of
	   forcing the row wider than the dialog — the default `auto` minimum keeps
	   the longest word's width. */
	min-width: 0;
	flex: 1 1 auto;
}

.sahla-cdash-name {
	font-weight: 600;
	line-height: 1.3;
	overflow-wrap: anywhere;
}

.sahla-cdash-meta {
	font-size: 0.85em;
	line-height: 1.4;
	color: var(--sahla-muted, #5B4F42);
}

.sahla-cdash-note {
	font-size: 0.8em;
	color: var(--sahla-muted-light, #8A7A64);
}

.sahla-cdash-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.sahla-cdash-badge {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 999px;
	background: var(--sahla-cream, #FFF4E8);
	color: var(--sahla-ink, #17120C);
	font-size: 0.75em;
	font-weight: 600;
	line-height: 1.6;
}

.sahla-cdash-badge-late {
	background: var(--sahla-primary, #FF741F);
	color: #fff;
}

/* --- Buy row ------------------------------------------------------------ */

.sahla-cdash-buy {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-top: 2px;
}

.sahla-cdash-price {
	font-weight: 700;
}

.sahla-cdash-buy form {
	margin: 0;
}

/* 44 px minimum comes from .sahla-btn; the padding here only keeps the label
   from touching the edges once the quantity makes it "Ajouter ×12". */
.sahla-cdash-add {
	padding: 10px 14px;
	font-size: 0.9em;
	white-space: nowrap;
}

/* --- Habits ------------------------------------------------------------- */

.sahla-cdash-cadence {
	margin: 0 0 10px;
	font-size: 1em;
}

.sahla-cdash-strip {
	display: block;
	width: 100%;
	height: 24px;
	margin: 0 0 12px;
	overflow: visible;
}

.sahla-cdash-strip-axis {
	stroke: #E7DACB;
	stroke-width: 2;
	stroke-linecap: round;
}

.sahla-cdash-strip-dot {
	fill: var(--sahla-primary, #FF741F);
}

/* Two columns at 360 px: four would give each tile ~70 px, which truncates
   every amount that carries a currency suffix. */
.sahla-cdash-stats {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
}

.sahla-cdash-stats li {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 10px;
	border-radius: 14px;
	background: var(--sahla-cream, #FFF4E8);
	min-width: 0;
}

.sahla-cdash-stat-value {
	font-size: 1.05em;
	font-weight: 700;
	line-height: 1.2;
	overflow-wrap: anywhere;
}

.sahla-cdash-stat-value .amount,
.sahla-cdash-stat-value bdi {
	white-space: nowrap;
}

.sahla-cdash-stat-label {
	font-size: 0.78em;
	color: var(--sahla-muted, #5B4F42);
	line-height: 1.3;
}

.sahla-cdash-bar {
	display: block;
	height: 6px;
	border-radius: 999px;
	background: #F1E7DA;
	overflow: hidden;
}

.sahla-cdash-bar > span {
	display: block;
	height: 100%;
	background: var(--sahla-primary, #FF741F);
	border-radius: 999px;
}

.sahla-cdash-list-compact .sahla-cdash-item {
	padding: 8px 10px;
}

.sahla-cdash-quiet,
.sahla-cdash-thin {
	color: var(--sahla-muted, #5B4F42);
}

/* --- Wider viewports ---------------------------------------------------- */

@media (min-width: 480px) {
	.sahla-cdash-repeat {
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
	}

	.sahla-cdash-repeat-btn {
		width: auto;
		flex: 0 0 auto;
	}

	.sahla-cdash-stats {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.sahla-cdash-buy {
		flex-wrap: nowrap;
	}
}

@media (max-width: 400px) {
	.sahla-cdash-thumb,
	.sahla-cdash-thumb img {
		width: 40px;
		height: 40px;
	}

	.sahla-cdash-panel {
		padding: 12px;
	}
}
