/* Chalet Booking — back-office. Mobile d'abord ; barre latérale sur grand écran. */
:root {
	color-scheme: light;
	--bg: #f4f4f1;
	--surface: #ffffff;
	--surface-2: #f8f8f6;
	--border: #e3e2dd;
	--text: #1c1c1a;
	--muted: #6b6a64;
	--accent: #8b2e1f;
	--accent-text: #ffffff;
	--nav: #1f2a37;
	--nav-text: #c9d1db;
	--series-1: #2a78d6;
	--grid: #e8e7e2;
	--st-confirmed-bg: #dcefe0; --st-confirmed: #1d5b2c;
	--st-pending-bg: #fdefc8;   --st-pending: #6d4c00;
	--st-cancelled-bg: #f6dcdc; --st-cancelled: #8a1c1c;
	--st-blocked-bg: #e2e2e0;   --st-blocked: #45443f;
	--st-ical-bg: #dde8f6;      --st-ical: #1c4a80;
	--radius: 12px;
	--shadow: 0 1px 2px rgba(0,0,0,.05), 0 1px 8px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		color-scheme: dark;
		--bg: #121211;
		--surface: #1c1c1b;
		--surface-2: #232322;
		--border: #333331;
		--text: #f2f1ec;
		--muted: #a3a29b;
		--accent: #d4604c;
		--accent-text: #ffffff;
		--nav: #0b0f14;
		--series-1: #3987e5;
		--grid: #2e2e2c;
		--st-confirmed-bg: #1e3a25; --st-confirmed: #a8dcb4;
		--st-pending-bg: #3d3113;   --st-pending: #f2d27e;
		--st-cancelled-bg: #402020; --st-cancelled: #f0a8a8;
		--st-blocked-bg: #33332f;   --st-blocked: #cfcec8;
		--st-ical-bg: #1d2e45;      --st-ical: #a9c8ef;
	}
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body.bo {
	background: var(--bg);
	color: var(--text);
	font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1 { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 6px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Structure */
.bo-header {
	position: sticky; top: 0; z-index: 20;
	display: flex; align-items: center; justify-content: space-between; gap: 12px;
	padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
	background: var(--nav); color: #fff;
}
.bo-brand { font-weight: 700; font-size: 16px; line-height: 1.1; }
.bo-brand small { display: block; font-weight: 400; font-size: 12px; color: var(--nav-text); }
.bo-new {
	background: var(--accent); color: var(--accent-text); text-decoration: none;
	padding: 8px 14px; border-radius: 999px; font-weight: 600; white-space: nowrap;
}
.bo-main { padding: 16px 16px 96px; max-width: 1100px; margin: 0 auto; outline: none; }
.bo-nav {
	position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
	display: flex; background: var(--surface); border-top: 1px solid var(--border);
	padding-bottom: env(safe-area-inset-bottom);
}
.bo-nav a {
	flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
	padding: 8px 2px; font-size: 11px; color: var(--muted); text-decoration: none;
}
.bo-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bo-nav a.active { color: var(--accent); }

@media (max-width: 480px) {
	.bo-new span { display: none; }
	.bo-new { padding: 6px 14px; font-size: 20px; line-height: 1; }
}
@media (min-width: 900px) {
	.bo-nav {
		top: 0; bottom: 0; right: auto; width: 210px; flex-direction: column;
		border-top: 0; border-right: 1px solid var(--border); padding-top: 72px;
	}
	.bo-nav a { flex: none; flex-direction: row; gap: 12px; padding: 12px 22px; font-size: 14px; }
	.bo-header { margin-left: 0; z-index: 30; }
	.bo-main { margin-left: 210px; padding: 24px 32px 48px; }
	@supports (margin-inline: max(0px)) {
		.bo-main { margin-left: max(210px, calc((100vw - 1100px) / 2 + 105px)); }
	}
}

/* Cartes et listes */
.bo-card {
	background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
	padding: 16px; margin: 0 0 16px; box-shadow: var(--shadow);
}
.bo-card.bo-flush { padding: 0 16px; }
.bo-attention { border-color: #e7c35c; }
.bo-grid2 { display: grid; gap: 0 16px; }
@media (min-width: 900px) { .bo-grid2 { grid-template-columns: 1fr 1fr; } }

.bo-row {
	display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
	padding: 12px 0; border-bottom: 1px solid var(--border);
	color: inherit; text-decoration: none; width: 100%; text-align: left;
	background: none; border-left: 0; border-right: 0; border-top: 0; cursor: pointer;
}
.bo-card .bo-row:last-child { border-bottom: 0; }
a.bo-row:hover, button.bo-row:hover { background: var(--surface-2); }
.bo-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bo-row-main strong { overflow: hidden; text-overflow: ellipsis; }
.bo-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.bo-amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.bo-when { font-size: 13px; font-weight: 600; color: var(--accent); }
.bo-muted { color: var(--muted); font-size: 13px; }
.bo-empty { color: var(--muted); margin: 4px 0; }
.bo-loading { color: var(--muted); padding: 40px 0; text-align: center; }
.bo-pending-item { border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 4px; }
.bo-pending-item .bo-row { border-bottom: 0; }
.bo-pending-item:last-child { border-bottom: 0; }
.bo-quote { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; margin: 0; }

/* Badges */
.bo-badge {
	display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
	white-space: nowrap; background: var(--st-blocked-bg); color: var(--st-blocked);
}
.bo-confirmed, .bo-pay-paid { background: var(--st-confirmed-bg); color: var(--st-confirmed); }
.bo-pending, .bo-pay-deposit { background: var(--st-pending-bg); color: var(--st-pending); }
.bo-cancelled, .bo-pay-unpaid { background: var(--st-cancelled-bg); color: var(--st-cancelled); }
.bo-ical { background: var(--st-ical-bg); color: var(--st-ical); }

/* Indicateurs */
.bo-kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 700px) { .bo-kpis { grid-template-columns: repeat(4, 1fr); } }
.bo-kpi {
	background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
	padding: 12px 14px; display: flex; flex-direction: column; gap: 4px;
	color: inherit; text-decoration: none; box-shadow: var(--shadow);
}
.bo-kpi span { font-size: 12px; color: var(--muted); }
.bo-kpi strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.bo-kpi.warn { border-color: #e7c35c; }

/* Boutons */
.bo-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.bo-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	min-height: 40px; padding: 8px 14px; border-radius: 10px;
	border: 1px solid var(--border); background: var(--surface); color: var(--text);
	font-weight: 600; text-decoration: none; cursor: pointer;
}
.bo-btn:hover { background: var(--surface-2); }
.bo-btn.bo-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.bo-btn.bo-danger { color: #b32d2e; }
.bo-btn.bo-small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.bo-back { display: inline-block; margin-bottom: 8px; text-decoration: none; font-weight: 600; }
.bo-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.bo-title h1 { margin: 0; }
.bo-sticky {
	position: sticky; bottom: 72px; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%);
}
@media (min-width: 900px) { .bo-sticky { bottom: 0; } }

/* Formulaires */
.bo-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 700px) { .bo-fields { grid-template-columns: repeat(4, 1fr); } }
.bo-fields .bo-fields { grid-template-columns: inherit; }
.bo-wide { grid-column: 1 / -1; }
.bo-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.bo-field input, .bo-field select, .bo-field textarea, .bo-filters input, .bo-filters select {
	width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px;
	background: var(--surface); color: var(--text); font-size: 16px;
}
.bo-field textarea { min-height: 80px; resize: vertical; }
.bo-form > .bo-field { margin-top: 12px; }
.bo-check { display: flex; gap: 8px; align-items: center; margin: 12px 0; }
.bo-check input { width: 20px; height: 20px; }
.bo-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.bo-filters input[type="search"] { grid-column: 1 / -1; }
@media (min-width: 700px) { .bo-filters { grid-template-columns: 2fr 1fr 1fr; } .bo-filters input[type="search"] { grid-column: auto; } }
.bo-seg { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.bo-seg label { flex: 1 1 140px; }
.bo-seg input { position: absolute; opacity: 0; }
.bo-seg span {
	display: block; text-align: center; padding: 10px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-weight: 600;
}
.bo-seg input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.bo-seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.bo-season { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 12px; background: var(--surface-2); }
.bo-alert { background: var(--st-cancelled-bg); color: var(--st-cancelled); padding: 10px 12px; border-radius: 8px; }
.bo-note { background: var(--st-pending-bg); color: var(--st-pending); padding: 10px 12px; border-radius: 8px; }
.bo-pay-quick { background: var(--surface-2); padding: 8px; border-radius: 10px; }

/* Tableaux */
.bo-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.bo-table td, .bo-table th { padding: 8px 4px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.bo-num-cell { text-align: right !important; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bo-total td { font-weight: 700; border-bottom: 0; }
details summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }

/* Calendrier */
.bo-cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.bo-cal-head h1 { flex: 1; margin: 0; text-align: center; text-transform: capitalize; }
.bo-cal-help { min-height: 2.9em; }
.bo-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; margin-bottom: 12px; }
.bo-dow { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; text-transform: capitalize; }
.bo-day {
	position: relative; min-height: 64px; padding: 4px; border: 1px solid var(--border); border-radius: 8px;
	background: var(--surface); text-align: left; cursor: pointer; overflow: hidden;
	display: flex; flex-direction: column; gap: 2px;
}
@media (min-width: 900px) { .bo-day { min-height: 88px; } }
.bo-day.bo-out { visibility: hidden; }
.bo-num { font-size: 13px; font-weight: 600; position: relative; z-index: 1; }
.bo-today .bo-num { background: var(--accent); color: var(--accent-text); border-radius: 999px; padding: 0 6px; align-self: flex-start; }
.bo-day-label {
	position: relative; z-index: 1; font-size: 11px; font-weight: 600; line-height: 1.2;
	overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.bo-occ.bo-confirmed { background: var(--st-confirmed-bg); color: var(--st-confirmed); border-color: transparent; }
.bo-occ.bo-pending { background: var(--st-pending-bg); color: var(--st-pending); border-color: transparent; }
.bo-occ.bo-blocked { background: var(--st-blocked-bg); color: var(--st-blocked); border-color: transparent; }
.bo-occ.bo-ical { background: var(--st-ical-bg); color: var(--st-ical); border-color: transparent; }
/* Jour de rotation : triangle du séjour qui se termine le matin. */
.bo-end::before {
	content: ""; position: absolute; inset: 0; clip-path: polygon(0 0, 100% 0, 0 100%);
	background: var(--st-blocked-bg);
}
.bo-end-confirmed::before { background: var(--st-confirmed-bg); }
.bo-end-pending::before { background: var(--st-pending-bg); }
.bo-end-ical::before { background: var(--st-ical-bg); }
.bo-occ.bo-start:not(.bo-end) { background-image: linear-gradient(135deg, var(--surface) 0 38%, transparent 38%); }
.bo-occ.bo-end::before { opacity: .9; }
.bo-sel { outline: 3px solid var(--accent); outline-offset: -3px; }
.bo-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }

/* Graphiques */
.bo-chart { margin: 0; }
.bo-chart figcaption { font-weight: 600; margin-bottom: 12px; }
.bo-plot { position: relative; height: 220px; margin-left: 64px; }
.bo-ticks { position: absolute; inset: 0 0 22px 0; }
.bo-tick { position: absolute; left: 0; right: 0; border-top: 1px solid var(--grid); }
.bo-tick span { position: absolute; right: calc(100% + 8px); top: -8px; font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.bo-bars { position: absolute; inset: 0; display: flex; gap: 2px; }
.bo-bar-slot {
	flex: 1; position: relative; display: flex; justify-content: center; align-items: flex-end;
	padding-bottom: 22px; cursor: pointer; outline: none;
}
.bo-bar {
	width: 100%; max-width: 24px; background: var(--series-1);
	border-radius: 4px 4px 0 0; min-height: 0; transition: opacity .15s;
}
.bo-bar-slot.dim .bo-bar { opacity: .35; }
.bo-bar-slot:focus-visible .bo-bar { outline: 2px solid var(--text); outline-offset: 2px; }
.bo-bar-label { position: absolute; bottom: 0; font-size: 11px; color: var(--muted); }
.bo-tip {
	position: absolute; top: -8px; transform: translate(-50%, -100%); z-index: 2;
	background: var(--text); color: var(--bg); font-size: 12px; font-weight: 600;
	padding: 6px 10px; border-radius: 6px; white-space: nowrap; pointer-events: none;
}

/* Connexion */
.bo-login {
	max-width: 380px; margin: 10vh auto; padding: 28px 24px; background: var(--surface);
	border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.bo-login h1 { margin: 0; }
.bo-login p label, .bo-login .login-username label, .bo-login .login-password label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.bo-login input[type="text"], .bo-login input[type="password"] {
	width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px;
	background: var(--surface); color: var(--text); font-size: 16px;
}
.bo-login .login-remember label { display: flex; gap: 8px; align-items: center; color: var(--text); }
.bo-login input[type="submit"] {
	width: 100%; min-height: 46px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-text);
	font-weight: 700; cursor: pointer;
}

/* Notifications */
.bo-toast {
	position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 20px); opacity: 0; z-index: 50;
	background: #1c1c1a; color: #fff; padding: 12px 18px; border-radius: 10px; max-width: calc(100vw - 32px);
	transition: all .2s; pointer-events: none; box-shadow: 0 6px 24px rgba(0,0,0,.25);
}
.bo-toast.show { opacity: 1; transform: translate(-50%, 0); }
.bo-toast.error { background: #8a1c1c; }
@media (min-width: 900px) { .bo-toast { bottom: 24px; } }
