:root {
	/* Couleurs */
	--lighter-grey: #f0eeee;
	--light-grey: #c0c0c0;

	/* Animations */
	--transition-time: 0.2s;
}

html, body {
	width: 100%;
	height: 100%;
}


/* Affichage général de la page responsive */
#main_container {
	display: grid;
	grid-template-columns: 230px 1fr;
	grid-template-rows: auto 1fr;
	height: 100%;
	grid-template-areas: "menu_logo menu_top"
	                     "menu_side content";
}

#menu_shading {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	background-color: #69696969;
	display: none;
	z-index: 2;
}

#menu_logo {
	display: flex;
	align-items: center;
	justify-content: center;
	grid-area: menu_logo;
	border-bottom: 1px solid var(--light-grey);
}
.menu_volet_buttons {
	font-size: 3em;
	display: none;
	padding: .5em;
	cursor: pointer;
}
#menu_logo_img {
	max-height: 75px;
}

#menu_top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	grid-area: menu_top;
	background-color: var(--lighter-grey);
	border-bottom: 1px solid var(--light-grey);

}
#menu_side {
	grid-area: menu_side;
	background-color: #fff;
	border-right: 1px solid #ececec;
}
#content {
	grid-area: content;
	padding: 10px;
	min-width: 0;
}

@media (max-width:1000px) {
	#menu_logo {
		position: sticky;
		top: 0;
		background-color: white;
		justify-content: space-between;
	}
	#main_container {
		grid-template-columns: 0px 1fr 0px;
		grid-template-areas: "menu_logo menu_logo menu_logo"
	                         "menu_side content   menu_top";
	}
	.menu_volet_buttons {
		display: inline-block;
	}
	.menu_volet {
		transition: transform var(--transition-time) ease;
		overflow: auto;
		padding-top: 75px;
		z-index: 3;
	}
	#menu_side {
		position: fixed;
		background-color: #fff;
		top: 0;
		bottom: 0;
		left: 0;
		transform: translateX(-110%);
		box-shadow: 1px 0 5px black;
	}
	#menu_top {
		position: fixed;
		background-color: var(--lighter-grey);
		top: 0;
		right: 0;
		bottom: 0;
		transform: translateX(110%);
		padding: 5px;
		padding-top: 75px;
		border: none;
		box-shadow: -1px 0 5px black;
		justify-content: flex-start;
	}
	#menu_side.displayed, #menu_top.displayed {
		transform: none;
	}
	#menu_side.displayed, #menu_top.displayed, #menu_shading.displayed {
		display: flex;
	}

	#menu_top {
		flex-direction: column;
	}

}


/* Flèche vers le bas (utilisée aussi par admin/modules/admin_rights/modules.php) */
.arrow_down {
	margin-left: 5px;
	border: solid black;
	border-width: 0 3px 3px 0;
	display: inline-block;
	padding: 4px;
	transform: rotate(45deg);
	margin-top: -.5em;
}

/* Petit drapeau carré (utilisé aussi par mp/commercial.php et admin/agent_main_language.php) */
.square_flag {
	width: 25px;
	height: 16px;
}


/* Affichage du menu du haut (droite du mobile) - A nettoyer */

.toolbar {
	display: flex;
	align-items: center;
	background-color: var(--lighter-grey);
	justify-content: space-between;
	flex-grow: 1;
}


#menu_extra_buttons {
	padding: 8px;
}

.logout:link,
.logout:visited {
	color: red;
}


@media (max-width:1000px) {

	#merchant_grouped_buttons {
		flex-direction:column;
	}
}

/* Menu de gauche : recherche puis rubriques dépliables (details / summary natifs) */

.menu_side_search {
	position: sticky;
	top: 0;
	z-index: 1;
	padding: 12px 12px 8px;
	background-color: inherit;
}
.menu_side_search i {
	position: absolute;
	left: 24px;
	top: 50%;
	margin-top: 2px;
	transform: translateY(-50%);
	color: #9a9a9a;
	font-size: 12px;
	pointer-events: none;
}
#search_menu_side {
	box-sizing: border-box;
	width: 100%;
	margin: 0;
	padding: 7px 10px 7px 30px;
	border: 1px solid #e3e3e3;
	border-radius: 8px;
	background-color: #f7f7f7;
	font: inherit;
	font-size: 13px;
}
#search_menu_side:focus {
	border-color: #c0c0c0;
	background-color: #fff;
	outline: none;
}

.menu_side_sections {
	display: flex;
	flex-direction: column;
	gap: 3px;
	padding: 0 8px 16px;
}
.menu_section_title {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 11px 12px;
	border-radius: 8px;
	color: rgba(0, 0, 0, .7);
	font-size: 14px;
	font-weight: 500;
	list-style: none;
	cursor: pointer;
	user-select: none;
	transition: background-color var(--transition-time) ease;
}
.menu_section_title::-webkit-details-marker {
	display: none;
}
.menu_section_title:hover {
	background-color: #f4f4f5;
	color: #222;
}
.menu_section_title > span {
	flex-grow: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.menu_section_icon {
	width: 18px;
	flex-shrink: 0;
	color: #8a8a8a;
	font-size: 15px;
	text-align: center;
}
.menu_section_chevron {
	color: #b5b5b5;
	font-size: 10px;
	transition: transform var(--transition-time) ease;
}
.menu_section[open] > .menu_section_title .menu_section_chevron {
	transform: rotate(90deg);
}
/* Rubrique de la page courante */
.menu_section[data-selected] > .menu_section_title {
	background-color: #f4f4f5;
	color: #c30040;
}
.menu_section[data-selected] > .menu_section_title .menu_section_icon {
	color: #c30040;
}

/* Sous-modules : alignés sur le texte de la rubrique, reliés par un trait vertical */
.menu_section_links {
	display: flex;
	flex-direction: column;
	margin: 4px 0 8px 21px;
	padding-left: 14px;
	border-left: 1px solid #ececec;
}
a.menu_section_link {
	padding: 7px 10px;
	border-radius: 6px;
	color: rgba(0, 0, 0, .6);
	font-size: 13px;
	line-height: 1.3;
	text-decoration: none;
}
a.menu_section_link:hover {
	background-color: #f4f4f5;
	color: #222;
	text-decoration: none;
}
a.menu_section_link.selected {
	background-color: #fdebf1;
	color: #c30040;
	font-weight: 600;
}

@media (max-width:1000px) {
	/* Le volet ouvert est en display: flex (#menu_side.displayed) : recherche au-dessus des rubriques */
	#menu_side {
		flex-direction: column;
		width: min(300px, 85vw);
	}
	.menu_section_title {
		padding: 12px;
		font-size: 15px;
	}
	a.menu_section_link {
		padding: 10px;
		font-size: 14px;
	}
}

/* Menus déroulants du header (saison, sourcing team) : select natif présenté en pastille */

.header_selects {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}
.header_select {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 10px;
	border: 1px solid #e3e3e3;
	border-radius: 999px;
	background-color: #fff;
	color: #6b6b6b;
	font-size: 12px;
	cursor: pointer;
	transition: background-color var(--transition-time) ease;
}
.header_select:hover,
.header_select:focus-within {
	background-color: #f2f2f2;
}
.header_select select {
	/* Largeur de la valeur choisie, et non de la plus longue option */
	field-sizing: content;
	appearance: none;
	margin: 0;
	padding: 0 16px 0 0;
	border: none;
	background: none;
	color: #222;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	outline: none;
}
.header_select_chevron {
	position: absolute;
	right: 10px;
	font-size: 9px;
	pointer-events: none;
}

/* Barre d'outils développeur : environnement, debug SQL / PHP, niveau de debug */

.dev_toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	padding: 6px 10px;
	font-size: 12px;
}
.dev_toolbar_segmented {
	display: inline-flex;
	align-items: center;
	padding: 2px;
	border: 1px solid #e3e3e3;
	border-radius: 999px;
	background-color: #fff;
}
.dev_toolbar_segment,
.dev_toolbar_env,
.dev_toolbar_label {
	display: inline-flex;
	align-items: center;
	padding: 3px 10px;
	border: none;
	border-radius: 999px;
	background: none;
	color: #6b6b6b;
	font: inherit;
	text-decoration: none;
}
a.dev_toolbar_segment,
button.dev_toolbar_segment {
	cursor: pointer;
}
a.dev_toolbar_segment:hover,
button.dev_toolbar_segment:hover {
	background-color: #f2f2f2;
	color: #222;
	text-decoration: none;
}
.dev_toolbar_label {
	padding: 3px 4px 3px 8px;
}
.dev_toolbar_debug_level {
	padding: 3px 8px;
}
.dev_toolbar_debug_level.selected,
.dev_toolbar_debug_level.selected:hover {
	background-color: #222;
	color: #fff;
}

/* Environnement courant : couleur selon le risque */
.dev_toolbar_env {
	color: #fff;
	font-weight: 600;
}
.dev_toolbar_env_dev {
	background-color: #1e88e5;
}
.dev_toolbar_env_preprod {
	background-color: #f59e0b;
}
.dev_toolbar_env_prod {
	background-color: #d32f2f;
}

/* Interrupteurs debug SQL / PHP */
.dev_toolbar_toggle {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 10px;
	border: 1px solid #e3e3e3;
	border-radius: 999px;
	background-color: #fff;
	color: #6b6b6b;
	font: inherit;
	cursor: pointer;
}
.dev_toolbar_toggle:hover {
	background-color: #f2f2f2;
}
.dev_toolbar_dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background-color: #c0c0c0;
}
.dev_toolbar_toggle.active {
	border-color: #2e7d32;
	color: #2e7d32;
	font-weight: 600;
}
.dev_toolbar_toggle.active .dev_toolbar_dot {
	background-color: #2e7d32;
	box-shadow: 0 0 0 3px rgba(46, 125, 50, .2);
}

@media (max-width:1000px) {
	.dev_toolbar {
		justify-content: center;
		font-size: 14px;
	}
}

/* Menu utilisateur : pastille (avatar à initiales + prénom) qui ouvre un popover natif */

.login_menu {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0 12px;
}

.login_menu_trigger {
	anchor-name: --login_menu_anchor;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 2px 12px 2px 2px;
	border: 1px solid #e3e3e3;
	border-radius: 999px;
	background-color: #fff;
	color: inherit;
	font: inherit;
	cursor: pointer;
	transition: background-color var(--transition-time) ease;
}
.login_menu_trigger:hover,
.login_menu_trigger:focus-visible {
	background-color: #f2f2f2;
}

/* Avatar à initiales, teinte calculée côté PHP à partir de l'email */
.login_menu_avatar {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background-color: hsl(var(--login_menu_hue, 210), 55%, 45%);
	color: #fff;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: .5px;
	user-select: none;
}
.login_menu_name {
	max-width: 140px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-weight: 600;
}
.login_menu_chevron {
	font-size: 10px;
	color: #6b6b6b;
}

.login_menu_popover {
	box-sizing: border-box;
	min-width: 220px;
	max-width: 320px;
	padding: 6px;
	border: 1px solid #e3e3e3;
	border-radius: 10px;
	background-color: #fff;
	color: #222;
	box-shadow: 0 10px 30px rgba(0, 0, 0, .15);
	font-size: 13px;
}
/* Popover natif : position fixe en haut à droite, ou sous la pastille si le navigateur gère l'ancrage CSS */
.login_menu_popover[popover] {
	position: fixed;
	inset: auto;
	top: 70px;
	right: 12px;
	margin: 0;
}
@supports (anchor-name: --login_menu_anchor) {
	.login_menu_popover[popover] {
		position-anchor: --login_menu_anchor;
		top: calc(anchor(bottom) + 8px);
		right: anchor(right);
		position-try-fallbacks: flip-inline;
	}
}
.login_menu_popover[popover]:popover-open {
	animation: login_menu_open .12s ease-out;
}
@keyframes login_menu_open {
	from {
		opacity: 0;
		transform: translateY(-4px);
	}
}

.login_menu_email {
	padding: 8px 10px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: #6b6b6b;
}
.login_menu_separator {
	height: 1px;
	margin: 4px 0;
	background-color: #e3e3e3;
}
/* Élément de menu : lien, ou bouton d'un formulaire (ex : connexion au compte du marchand) */
.login_menu_item {
	box-sizing: border-box;
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 8px 10px;
	border: none;
	border-radius: 6px;
	background: none;
	color: #222;
	font: inherit;
	text-align: left;
	text-decoration: none;
	cursor: pointer;
}
.login_menu_item:hover,
.login_menu_item:focus-visible {
	background-color: #f2f2f2;
	color: #222;
	text-decoration: none;
}
.login_menu_item i {
	width: 16px;
	text-align: center;
	color: #6b6b6b;
}
a.login_menu_item_danger,
a.login_menu_item_danger i {
	color: #c62828;
}
a.login_menu_item_danger:hover {
	background-color: #fdecea;
}

/* Mobile : le header est déjà un volet latéral, le contenu du menu y est affiché directement (pas de menu flottant) */
@media (max-width:1000px) {
	.login_menu {
		flex-direction: column;
		align-items: stretch;
		width: 100%;
		box-sizing: border-box;
		padding: 10px 0;
		font-size: 1.2em;
	}
	.login_menu_trigger {
		display: none;
	}
	/* Le popover fermé est masqué par le navigateur : on le force dans le flux du volet */
	.login_menu_popover,
	.login_menu_popover[popover] {
		display: block;
		position: static;
		inset: auto;
		width: 100%;
		max-width: none;
		min-width: 0;
		box-shadow: none;
		animation: none;
	}
	.login_menu_item {
		padding: 12px 10px;
	}
}

/* Menu du marchand (backoffice MP) : mêmes composants que le menu utilisateur, avec sa propre ancre */
.merchant_menu {
	display: flex;
	align-items: center;
	gap: 8px;
}
.merchant_menu_trigger {
	anchor-name: --merchant_menu_anchor;
	padding: 4px 12px;
}
@supports (anchor-name: --merchant_menu_anchor) {
	.merchant_menu_popover[popover] {
		position-anchor: --merchant_menu_anchor;
	}
}
.merchant_menu_trigger .login_menu_name {
	max-width: 200px;
}
/* Identifiants du marchand à copier (utilisateurs Spartoo) */
.merchant_menu_ids {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 12px;
	padding: 0 10px 8px;
}
.merchant_menu_id {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}
.merchant_menu_id_label {
	color: #6b6b6b;
	font-size: 11px;
}
.merchant_menu_copy {
	padding: 2px 4px;
	border: none;
	border-radius: 4px;
	background: none;
	color: #6b6b6b;
	cursor: pointer;
}
.merchant_menu_copy:hover {
	background-color: #f2f2f2;
	color: #222;
}
.merchant_menu_copy.copied {
	color: #2e7d32;
}
/* Utilisateur Spartoo connecté au compte d'un marchand : avertissement toujours visible */
.merchant_menu_warning {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 12px;
	border-radius: 999px;
	background-color: #c30040;
	color: #fff;
	font-size: 12px;
}
@media (max-width:1000px) {
	.merchant_menu {
		flex-direction: column;
		align-items: stretch;
		width: 100%;
		padding: 10px 0;
		font-size: 1.2em;
	}
}

/* Sélecteur de site : bouton qui ouvre un popover natif */

.flags_menu_trigger {
	anchor-name: --flags_menu_anchor;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 4px 12px;
	border: 1px solid #e3e3e3;
	border-radius: 999px;
	background-color: #fff;
	color: inherit;
	font: inherit;
	cursor: pointer;
	transition: background-color var(--transition-time) ease;
}
.flags_menu_trigger:hover,
.flags_menu_trigger:focus-visible {
	background-color: #f2f2f2;
}
.flags_menu_chevron {
	font-size: 10px;
	color: #6b6b6b;
}
.flags_menu_flag {
	width: 20px;
	height: 13px;
	border-radius: 2px;
	object-fit: cover;
	flex-shrink: 0;
}

.flags_menu_popover {
	box-sizing: border-box;
	width: min(760px, calc(100vw - 24px));
	max-height: min(80vh, 700px);
	padding: 0;
	border: 1px solid #e3e3e3;
	border-radius: 10px;
	background-color: #fff;
	color: #222;
	box-shadow: 0 10px 30px rgba(0, 0, 0, .15);
	font-size: 13px;
	overflow: hidden;
}
.flags_menu_popover:popover-open {
	display: flex;
	flex-direction: column;
	animation: login_menu_open .12s ease-out;
}
/* Centré à l'écran, juste sous le bouton si le navigateur gère l'ancrage CSS */
.flags_menu_popover[popover] {
	position: fixed;
	inset: auto;
	top: 70px;
	left: 50%;
	transform: translateX(-50%);
	margin: 0;
}
@supports (anchor-name: --flags_menu_anchor) {
	.flags_menu_popover[popover] {
		position-anchor: --flags_menu_anchor;
		top: calc(anchor(bottom) + 8px);
	}
}

.flags_menu_header {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	border-bottom: 1px solid #e3e3e3;
}
.flags_menu_header:not(:has(.flags_menu_search)) {
	display: none;
}
.flags_menu_search {
	position: relative;
	flex-grow: 1;
}
.flags_menu_search i {
	position: absolute;
	left: 10px;
	top: 50%;
	transform: translateY(-50%);
	color: #6b6b6b;
	pointer-events: none;
}
.flags_menu_search input {
	box-sizing: border-box;
	width: 100%;
	padding: 8px 10px 8px 32px;
	border: 1px solid #e3e3e3;
	border-radius: 6px;
	font: inherit;
}
.flags_menu_close {
	display: none;
	border: none;
	background: none;
	font-size: 1.4em;
	cursor: pointer;
	color: #6b6b6b;
}

.flags_menu_content {
	padding: 6px;
	overflow-y: auto;
}

/* Vue multi-partenaires : une ligne par partenaire */
.flags_menu_row {
	display: grid;
	grid-template-columns: 110px 1fr;
	gap: 8px;
	align-items: start;
	padding: 6px;
	border-radius: 6px;
}
.flags_menu_row:hover {
	background-color: #fafafa;
}
.flags_menu_partner {
	padding-top: 5px;
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.flags_menu_chips {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
}
a.flags_menu_chip {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 4px 8px;
	border: 1px solid #e3e3e3;
	border-radius: 999px;
	color: #222;
	font-size: 12px;
	text-decoration: none;
	white-space: nowrap;
}
a.flags_menu_chip .flags_menu_flag {
	width: 16px;
	height: 11px;
}

/* Vue un seul partenaire : liste des pays */
.flags_menu_countries {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
	gap: 2px;
}
a.flags_menu_country {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 10px;
	border-radius: 6px;
	color: #222;
	text-decoration: none;
}
.flags_menu_country_name {
	flex-grow: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.flags_menu_code {
	color: #6b6b6b;
	font-size: 11px;
}

a.flags_menu_site:hover,
a.flags_menu_site:focus-visible {
	background-color: #f2f2f2;
	text-decoration: none;
}
a.flags_menu_site.selected {
	border-color: #222;
	background-color: #222;
	color: #fff;
}
a.flags_menu_site.selected .flags_menu_code {
	color: #ddd;
}
.flags_menu_site.flags_menu_hidden,
.flags_menu_row.flags_menu_hidden {
	display: none;
}

/* Mobile : le sélecteur occupe tout l'écran */
@media (max-width:1000px) {
	.flags_menu {
		order: -1;
	}
	.flags_menu_popover[popover] {
		inset: 0;
		width: 100%;
		max-height: none;
		height: 100%;
		border-radius: 0;
		transform: none;
	}
	.flags_menu_header,
	.flags_menu_header:not(:has(.flags_menu_search)) {
		display: flex;
		justify-content: flex-end;
	}
	.flags_menu_close {
		display: block;
	}
	.flags_menu_row {
		grid-template-columns: 1fr;
		gap: 4px;
	}
	a.flags_menu_chip {
		padding: 8px 10px;
		font-size: 14px;
	}
}

@media print {
	html, body {
		height: 80%;
	}
	@page {
		margin: 0;
	}
}
