/* === Home Domotique UI — v2 (light/dark + toggle) === */
:root {
	/* Light theme (default) */
	--blue: #0A74C9; /* primaire */
	--blue-600: #1769aa; /* hover */
	--blue-dark: #053B5E; /* header/footer */
	--blue-light: #4FB4FF; /* accents */
	--bg: #F3F7FA; /* page background */
	--panel: #FFFFFF; /* cards */
	--panel-weak: #FFFFFFee; /* glass */
	--text: #1E1E1E; /* main text */
	--muted: #6b7280; /* secondary text */
	--line: #e5e7eb; /* borders */
	--thead: #eef6ff; /* table head */
	--thead-text: #053b5e;
	--pill-info-bg: #dcfce7;
	--pill-info-fg: #065f46;
	--pill-warn-bg: #fef9c3;
	--pill-warn-fg: #92400e;
	--pill-error-bg: #fee2e2;
	--pill-error-fg: #991b1b;
	--pill-debug-bg: #e0f2fe;
	--pill-debug-fg: #0369a1;
	--pill-trace-bg: #e2e8f0;
	--pill-trace-fg: #0f172a;
	--pill-fatal-bg: #fecaca;
	--pill-fatal-fg: #7f1d1d;
	--white: #fff;
	--radius: 12px;
	--shadow: 0 10px 24px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .06);
}

/* Dark theme overrides */
html[data-theme="dark"] {
	--blue: #4FB4FF;
	--blue-600: #7cc9ff;
	--blue-dark: #052f47;
	--blue-light: #74c8ff;
	--bg: #0b1520;
	--panel: #0f1b29;
	--panel-weak: #0f1b29ee;
	--text: #e6eef6;
	--muted: #98a3af;
	--line: #1f2a37;
	--thead: #0f2438;
	--thead-text: #cde9ff;
	--pill-info-bg: #0f3d2c;
	--pill-info-fg: #8df0c0;
	--pill-warn-bg: #3b3214;
	--pill-warn-fg: #ffe08a;
	--pill-error-bg: #3a1f1f;
	--pill-error-fg: #ffb4b4;
	--pill-debug-bg: #0f2a3d;
	--pill-debug-fg: #8dd3ff;
	--pill-trace-bg: #1f2732;
	--pill-trace-fg: #cfe4ff;
	--pill-fatal-bg: #3c1a1a;
	--pill-fatal-fg: #ff9c9c;
}

/* Respect system preference unless overridden */
@media ( prefers-color-scheme : dark) {
	html:not([data-theme="light"]) {
		color-scheme: dark;
	}
}

* {
	box-sizing: border-box
}

html, body {
	margin: 0;
	padding: 0;
	color: var(--text);
	background: var(--bg);
	font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto,
		Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

a {
	color: var(--blue);
	text-decoration: none
}

a:hover {
	text-decoration: underline;
	cursor: pointer
}

.container {
	width: min(1200px, 100% - 2rem);
	margin-inline: auto;
	padding-block: 1.5rem
}

/* Header / Nav */
header.site {
	position: sticky;
	top: 0;
	z-index: 1000;
	background: linear-gradient(180deg, var(--blue-dark), #08486f);
	color: var(--white);
	box-shadow: var(--shadow)
}

html[data-theme="dark"] header.site {
	background: linear-gradient(180deg, var(--blue-dark), #0b2233)
}

/* Assure aux navigateurs modernes d'utiliser les glyphes/indicateurs "dark-ready" */
html[data-theme="dark"] {
	color-scheme: dark;
}

html[data-theme="light"] {
	color-scheme: light;
}

html[data-theme="dark"] input[type="datetime-local"] {
	background-color: var(--panel);
	color: var(--text);
	border: 1px solid var(--line);
	color-scheme: dark;
}

/* Icône du calendrier : color-scheme dark la rend déjà claire (pas d'inversion,
   sinon elle redevient noire sur fond sombre). */
html[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator
	{
	opacity: .9;
	cursor: pointer;
}

.nav {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: .75rem 1rem
}

.nav .brand {
	display: flex;
	align-items: center;
	gap: .5rem;
	font-weight: 700;
	letter-spacing: .2px;
	white-space: nowrap
}

.nav .brand img {
	height: 36px;
	width: auto;
	display: block
}

.nav .links {
	margin-left: auto;
	display: flex;
	gap: .25rem;
	flex-wrap: wrap
}

.nav .links a {
	color: var(--white);
	padding: .5rem .75rem;
	border-radius: 8px
}

.nav .links a.active, .nav .links a:hover {
	background: rgba(255, 255, 255, .12)
}

.nav .right {
	display: flex;
	align-items: center;
	gap: .5rem
}

.btn {
	--bg: var(--blue);
	--fg: #fff;
	--bd: transparent;
	background: var(--bg);
	color: var(--fg);
	border: 1px solid var(--bd);
	padding: .55rem .9rem;
	border-radius: 10px;
	box-shadow: 0 1px 0 rgba(255, 255, 255, .15) inset, 0 1px 2px
		rgba(0, 0, 0, .07);
	cursor: pointer;
	transition: transform .06s ease, background .2s ease
}

.btn:hover {
	transform: translateY(-1px);
	filter: saturate(1.1)
}

.btn.primary {
	--bg: var(--blue);
}

.btn.ghost {
	--bg: transparent;
	--fg: var(--white);
	--bd: rgba(255, 255, 255, .3)
}

/* Action destructive (suppression) */
.btn.danger {
	--bg: #c62828;
	--fg: #fff;
}

html[data-theme="dark"] .btn.danger {
	--bg: #e5484d;
}

/* Tableau large : défile horizontalement dans son conteneur au lieu de faire
   déborder la page (la page garde la largeur commune de .container). */
.table-scroll {
	max-width: 100%;
	overflow-x: auto;
}

.btn:disabled, .btn.disabled {
	opacity: .6;
	pointer-events: none
}

/* Theme toggle */
.theme-toggle {
	display: inline-flex;
	align-items: center;
	gap: .4rem;
	border: 1px solid rgba(255, 255, 255, .25);
	padding: .25rem .5rem;
	border-radius: 9999px;
	background: rgba(255, 255, 255, .1);
	cursor: pointer
}

.theme-toggle .icon {
	font-size: 1rem;
	line-height: 1
}

.theme-toggle .label {
	display: none
}

@media ( min-width : 640px) {
	.theme-toggle .label {
		display: inline
	}
}

/* Hero */
.hero {
	display: grid;
	grid-template-columns: 1.2fr .8fr;
	gap: 2rem;
	align-items: center;
	padding-block: 2rem
}

.hero .title {
	font-size: clamp(1.6rem, 2.5vw, 2.6rem);
	margin: .25rem 0
}

.hero .subtitle {
	color: #eaf6ff;
	opacity: .9;
	margin-top: .5rem
}

.hero .panel {
	background: linear-gradient(180deg, rgba(255, 255, 255, .08),
		rgba(255, 255, 255, .03));
	backdrop-filter: blur(6px);
	border: 1px solid rgba(255, 255, 255, .18);
	border-radius: var(--radius);
	padding: 1rem;
}

.hero img {
	max-width: 220px;
	width: 100%;
	height: auto;
}

/* Cards */
.card {
	background: var(--panel);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 1rem;
	border: 1px solid var(--line)
}

.card+.card {
	margin-top: 1rem
}

.card h2, .card h3 {
	margin-top: 0
}

/* Forms */
form .field {
	display: flex;
	flex-direction: column;
	gap: .35rem;
	margin-bottom: .9rem
}

input[type=text], input[type=password], input[type=datetime-local],
	input[type=number], input[type=search], select, textarea {
	margin-right: 3%;
	padding: .6rem .7rem;
	border-radius: 10px;
	border: 1px solid var(--line);
	background: var(--panel);
	color: var(--text);
	outline: none;
	box-shadow: 0 1px 0 rgba(255, 255, 255, .05) inset
}

input:focus, select:focus, textarea:focus {
	border-color: var(--blue);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 25%, transparent)
}

/* Couleur du placeholder cohérente avec le thème */
input::placeholder, textarea::placeholder {
	color: var(--muted);
	opacity: 1;
}

label {
	font-weight: 600
}

.help {
	font-size: .875rem;
	color: var(--muted)
}

/* Tables */
.table {
	width: 100%;
	border-collapse: separate;
	border-spacing: 0;
	box-shadow: var(--shadow);
	background: var(--panel);
	border-radius: 12px;
	overflow: hidden;
	border: 1px solid var(--line)
}

.table thead th {
	background: var(--thead);
	color: var(--thead-text);
	font-weight: 700;
	text-align: left;
	padding: .7rem;
	border-bottom: 1px solid var(--line);
	cursor: pointer
}

.table tbody td {
	padding: .7rem;
	border-top: 1px solid var(--line)
}

.table tr:hover td {
	background: color-mix(in srgb, var(--panel) 85%, var(--blue) 15%)
}

.table .actions a {
	margin-right: .35rem;
	align-self: flex-start;
}

.actions {
	display: flex;
	flex-wrap: wrap; /* IMPORTANT : autorise le passage à la ligne */
}

@media ( max-width : 990px) {
	.table .actions, .actions {
		flex-direction: column;
		align-items: stretch; /* les boutons prennent toute la largeur */
		gap: .5rem; /* espace entre les boutons */
		text-align: center;
		padding-top: .3em;
		padding-bottom: .3em;
	}
}

.table .text-success {
	color: #0ea5e9
}

.table .text-muted {
	color: #9ca3af
}

.table .pill {
	display: inline-flex;
	align-items: center;
	gap: .35rem;
	padding: .2rem .55rem;
	border-radius: 9999px;
	font-size: .78rem;
	font-weight: 700
}

.pill.lvl-TRACE {
	background: var(--pill-trace-bg);
	color: var(--pill-trace-fg)
}

.pill.lvl-DEBUG {
	background: var(--pill-debug-bg);
	color: var(--pill-debug-fg)
}

.pill.lvl-INFO {
	background: var(--pill-info-bg);
	color: var(--pill-info-fg)
}

.pill.lvl-WARN {
	background: var(--pill-warn-bg);
	color: var(--pill-warn-fg)
}

.pill.lvl-ERROR {
	background: var(--pill-error-bg);
	color: var(--pill-error-fg)
}

.pill.lvl-FATAL {
	background: var(--pill-fatal-bg);
	color: var(--pill-fatal-fg)
}

/* Filters panel */
#filtersPanel {
	background: var(--panel);
	border-radius: 12px;
	box-shadow: var(--shadow);
	margin: 1rem 0;
	padding: 1rem;
	border: 1px solid var(--line)
}

#filtersPanel.collapsed {
	display: none
}

.checkbox-list {
	display: flex;
	flex-wrap: wrap;
	gap: .75rem
}

.checkbox-row {
	display: flex;
	align-items: center
}

.checkbox input {
	margin-right: .45rem
}

.fieldset, fieldset.field {
	border: 1px solid var(--line);
	border-radius: 12px;
	padding: .75rem 1rem
}

legend {
	font-weight: 700;
	color: var(--thead-text)
}

.toolbar {
	display: flex;
	gap: .5rem;
	margin-top: .5rem
}

.summary {
	color: var(--muted)
}

/* Auth card */
.auth {
	display: grid;
	place-content: center;
	min-height: calc(100vh - 64px)
}

.auth .auth-card {
	max-width: 440px;
	margin: 2rem auto
}

/* Pagination */
.pagination {
	display: flex;
	align-items: center;
	gap: .6rem;
	margin-top: 1rem
}

.pagination a, .pagination span {
	background: var(--panel);
	border: 1px solid var(--line);
	color: var(--text);
	padding: .45rem .7rem;
	border-radius: 10px
}

.pagination a.disabled {
	opacity: .6;
	pointer-events: none
}

/* Footer */
footer.site {
	margin-top: 2rem;
	padding: 1.2rem;
	color: #e2e8f0;
	background: var(--blue-dark)
}

/* Logo sizing utility (does not change layout size across theme variants) */
.logo-auto {
	height: 36px;
	width: auto;
	max-width: 100%;
	object-fit: contain
}

.logo-xl {
	height: 54px
}

.logo-hero {
	max-width: 220px;
	height: auto
}

/* Utilities */
.hidden {
	display: none !important
}

.flex {
	display: flex
}

.items-center {
	align-items: center
}

.justify-between {
	justify-content: space-between
}

.gap-1 {
	gap: .25rem
}

.gap-2 {
	gap: .5rem
}

.mt-1 {
	margin-top: .25rem
}

.mt-2 {
	margin-top: .5rem
}

.mt-3 {
	margin-top: .75rem
}

.mt-4 {
	margin-top: 1rem
}

@media ( max-width : 900px) {
	.hero {
		grid-template-columns: 1fr;
	}
	.nav .links {
		width: 100%;
		justify-content: flex-end
	}
}

/* Ciblage de la cellule Target IP avec l'icône */
.targetip-cell .input-with-icon {
	display: grid;
	grid-template-columns: 1fr auto; /* input puis l'emoji */
	gap: .4rem;
	align-items: center;
}

.icon-warning {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
	font-size: 1rem; /* ajuste si tu veux plus grand/petit */
}

/* Optionnel : mettre en évidence la ligne entière quand mismatch */
.row-mismatch > td:first-child {
	/* exemple soft : bordure gauche discrète */
	border-left: 3px solid #b45309;
}

[data-theme="dark"] .row-mismatch > td:first-child {
	border-left-color: #f59e0b;
}