/* =========================================================================
   EdiSira ERP — Design tokens
   Palette inspirée du métier : terre cuite des carreaux, cuivre des
   tuyauteries, ardoise du béton. Typo technique/blueprint pour un outil
   de gestion, avec une chasse mono pour tout ce qui est chiffré (codes,
   montants, références).
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
	--color-bg: #1C2024;
	--color-surface: #24282D;
	--color-surface-alt: #2A2F35;
	--color-border: #383E46;
	--color-text: #F2EFEA;
	--color-text-muted: #9BA2AB;

	--color-accent: #C1652F;       /* terre cuite / tuile */
	--color-accent-hover: #D9773B;
	--color-accent-ink: #2A1608;

	--color-secondary: #4C6B8A;    /* eau / tuyauterie galvanisée */
	--color-success: #4F8B6E;
	--color-danger: #C1443C;
	--color-warning: #D9A441;

	--font-display: 'Space Grotesk', sans-serif;
	--font-body: 'Inter', sans-serif;
	--font-mono: 'IBM Plex Mono', monospace;

	--radius-sm: 6px;
	--radius-md: 10px;
	--radius-lg: 16px;

	--shadow-card: 0 1px 2px rgba(0,0,0,.24), 0 8px 24px -8px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }

.edisira-app, .edisira-app * {
	margin: 0;
	font-family: var(--font-body);
	color: var(--color-text);
}

.edisira-app {
	background: var(--color-bg);
	min-height: 100vh;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

.edisira-app :focus-visible {
	outline: 2px solid var(--color-accent-hover);
	outline-offset: 2px;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------------------
   Le motif "carreaux" : signature visuelle de la marque, réutilisée sur
   l'écran de connexion et en filigrane derrière les états vides.
   ------------------------------------------------------------------------- */
.tile-grid {
	position: absolute;
	inset: 0;
	background-image:
		linear-gradient(var(--color-border) 1px, transparent 1px),
		linear-gradient(90deg, var(--color-border) 1px, transparent 1px);
	background-size: 64px 64px;
	opacity: .35;
	mask-image: radial-gradient(ellipse at 30% 30%, black 0%, transparent 70%);
}

.tile-grid--dense {
	background-size: 32px 32px;
}

/* =========================================================================
   Écran de connexion
   ========================================================================= */

.login-screen {
	display: grid;
	grid-template-columns: 1.1fr 1fr;
	min-height: 100vh;
}

@media (max-width: 860px) {
	.login-screen { grid-template-columns: 1fr; }
	.login-screen__brand { display: none; }
}

.login-screen__brand {
	position: relative;
	background: linear-gradient(160deg, #201A15 0%, var(--color-bg) 55%);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	padding: 48px;
}

.login-screen__brand::after {
	content: "";
	position: absolute;
	right: -120px;
	bottom: -120px;
	width: 420px;
	height: 420px;
	border-radius: 50%;
	background: radial-gradient(circle, var(--color-accent) 0%, transparent 70%);
	opacity: .25;
}

.login-screen__mark {
	font-family: var(--font-display);
	font-weight: 700;
	font-size: 22px;
	letter-spacing: -.01em;
	position: relative;
	z-index: 1;
}

.login-screen__mark span { color: var(--color-accent); }

.login-screen__pitch {
	position: relative;
	z-index: 1;
	max-width: 420px;
}

.login-screen__pitch h1 {
	font-family: var(--font-display);
	font-weight: 600;
	font-size: 32px;
	line-height: 1.15;
	letter-spacing: -.01em;
	margin-bottom: 12px;
}

.login-screen__pitch p {
	color: var(--color-text-muted);
	font-size: 15px;
}

.login-screen__form-wrap {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 32px;
}

.login-card {
	width: 100%;
	max-width: 380px;
}

.login-card__mark {
	font-family: var(--font-display);
	font-weight: 700;
	font-size: 20px;
	margin-bottom: 28px;
	display: none;
}

@media (max-width: 860px) {
	.login-card__mark { display: block; }
}

.login-card h2 {
	font-family: var(--font-display);
	font-size: 24px;
	font-weight: 600;
	margin-bottom: 6px;
}

.login-card__subtitle {
	color: var(--color-text-muted);
	font-size: 14px;
	margin-bottom: 28px;
}

.field {
	margin-bottom: 18px;
}

.field label {
	display: block;
	font-size: 13px;
	font-weight: 500;
	color: var(--color-text-muted);
	margin-bottom: 6px;
}

.field input {
	width: 100%;
	background: var(--color-surface);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-sm);
	padding: 11px 13px;
	font-size: 14px;
	color: var(--color-text);
	transition: border-color .15s ease;
}

.field input:focus {
	border-color: var(--color-accent);
	outline: none;
}

.field--otp input {
	letter-spacing: .5em;
	text-align: center;
	font-family: var(--font-mono);
	font-size: 20px;
}

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	padding: 12px 16px;
	border-radius: var(--radius-sm);
	border: none;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background-color .15s ease, transform .05s ease;
}

.btn:active { transform: translateY(1px); }

.btn--primary {
	background: var(--color-accent);
	color: #fff;
}
.btn--primary:hover { background: var(--color-accent-hover); }
.btn--primary:disabled { opacity: .6; cursor: not-allowed; }

.btn--ghost {
	background: transparent;
	color: var(--color-text-muted);
	border: 1px solid var(--color-border);
}
.btn--ghost:hover { color: var(--color-text); border-color: var(--color-text-muted); }

.login-card__links {
	margin-top: 18px;
	display: flex;
	justify-content: space-between;
	font-size: 13px;
}

.login-card__links a {
	color: var(--color-secondary);
	text-decoration: none;
	cursor: pointer;
}
.login-card__links a:hover { text-decoration: underline; }

.form-message {
	font-size: 13px;
	padding: 10px 12px;
	border-radius: var(--radius-sm);
	margin-bottom: 16px;
	display: none;
}
.form-message--error { background: rgba(193,68,60,.15); color: #E68880; display: block; }
.form-message--success { background: rgba(79,139,110,.15); color: #8FCBAA; display: block; }

.step { display: none; }
.step.is-active { display: block; }

/* =========================================================================
   Dashboard
   ========================================================================= */

.app-shell {
	display: grid;
	grid-template-columns: 248px 1fr;
	min-height: 100vh;
}

@media (max-width: 960px) {
	.app-shell { grid-template-columns: 1fr; }
	.sidebar { display: none; }
}

.sidebar {
	background: var(--color-surface);
	border-right: 1px solid var(--color-border);
	padding: 24px 16px;
	display: flex;
	flex-direction: column;
}

.sidebar__mark {
	font-family: var(--font-display);
	font-weight: 700;
	font-size: 18px;
	padding: 0 8px 24px;
}
.sidebar__mark span { color: var(--color-accent); }

.sidebar__section-label {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: .08em;
	color: var(--color-text-muted);
	padding: 16px 8px 8px;
}

.sidebar__link {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 10px;
	border-radius: var(--radius-sm);
	font-size: 14px;
	color: var(--color-text-muted);
	text-decoration: none;
	cursor: pointer;
}
.sidebar__link:hover { background: var(--color-surface-alt); color: var(--color-text); }
.sidebar__link.is-active { background: rgba(193,101,47,.15); color: var(--color-accent-hover); font-weight: 500; }

.sidebar__dot {
	width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .5;
}

.topbar {
	height: 64px;
	border-bottom: 1px solid var(--color-border);
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 24px;
}

.topbar__search {
	background: var(--color-surface);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-sm);
	padding: 8px 12px;
	font-size: 13px;
	color: var(--color-text-muted);
	width: 320px;
}

.topbar__right { display: flex; align-items: center; gap: 16px; }

.avatar {
	width: 34px; height: 34px; border-radius: 50%;
	background: var(--color-accent);
	display: flex; align-items: center; justify-content: center;
	font-family: var(--font-display); font-weight: 600; font-size: 13px;
	cursor: pointer;
}

.main {
	padding: 28px;
	max-width: 1320px;
}

.main h1 {
	font-family: var(--font-display);
	font-size: 24px;
	font-weight: 600;
	margin-bottom: 4px;
}

.main__subtitle { color: var(--color-text-muted); font-size: 14px; margin-bottom: 24px; }

.kpi-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 14px;
	margin-bottom: 28px;
}

.kpi-card {
	background: var(--color-surface);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-md);
	padding: 18px;
	box-shadow: var(--shadow-card);
}

.kpi-card__label {
	font-size: 12px;
	color: var(--color-text-muted);
	margin-bottom: 10px;
}

.kpi-card__value {
	font-family: var(--font-mono);
	font-size: 24px;
	font-weight: 600;
}

.kpi-card__value--accent { color: var(--color-accent-hover); }
.kpi-card__value--danger { color: var(--color-danger); }
.kpi-card__value--warning { color: var(--color-warning); }

.panel {
	background: var(--color-surface);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-md);
	padding: 20px;
	margin-bottom: 20px;
}

.panel h2 {
	font-family: var(--font-display);
	font-size: 16px;
	font-weight: 600;
	margin-bottom: 16px;
}

/* =========================================================================
   Recherche produits (résultats instantanés)
   ========================================================================= */

#recherche-live-resultats {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 14px;
}

.recherche-carte {
	background: var(--color-surface);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-md);
	padding: 14px;
	display: flex;
	gap: 12px;
	box-shadow: var(--shadow-card);
}

.recherche-carte__photo {
	width: 56px;
	height: 56px;
	border-radius: 8px;
	background: var(--color-surface-alt) center/cover no-repeat;
	flex-shrink: 0;
}

.recherche-carte__corps { flex: 1; min-width: 0; }

.recherche-carte__nom {
	font-weight: 600;
	font-size: 14px;
	margin-bottom: 2px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.recherche-carte__code {
	font-size: 11px;
	color: var(--color-text-muted);
	margin-bottom: 8px;
}

.recherche-carte__ligne {
	display: flex;
	justify-content: space-between;
	font-size: 12px;
	color: var(--color-text-muted);
	padding: 2px 0;
}
.recherche-carte__ligne span:last-child { color: var(--color-text); font-weight: 500; }

.recherche-carte__achat span:last-child { color: var(--color-accent-hover); }

.recherche-carte__categorie {
	font-size: 11px;
	color: var(--color-text-muted);
	margin-top: 6px;
	font-style: italic;
}

.recherche-live-vide {
	grid-column: 1 / -1;
	text-align: center;
	color: var(--color-text-muted);
	font-size: 13px;
	padding: 40px 20px;
}

/* =========================================================================
   Cloche de notifications
   ========================================================================= */

.notif-bell-wrap { position: relative; }

.notif-bell {
	position: relative;
	background: none;
	border: none;
	color: var(--color-text-muted);
	cursor: pointer;
	padding: 6px;
	display: flex;
	align-items: center;
	border-radius: 8px;
}
.notif-bell:hover { color: var(--color-text); background: var(--color-surface-alt); }

.notif-bell__badge {
	position: absolute;
	top: -2px;
	right: -2px;
	background: var(--color-danger);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	line-height: 1;
	padding: 3px 5px;
	border-radius: 999px;
	min-width: 16px;
	text-align: center;
}

.notif-dropdown {
	display: none;
	position: absolute;
	top: calc(100% + 10px);
	right: 0;
	width: 340px;
	max-width: calc(100vw - 40px);
	background: var(--color-surface);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-card);
	z-index: 150;
	overflow: hidden;
}
.notif-dropdown.is-open { display: block; }

.notif-dropdown__header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 12px 16px;
	border-bottom: 1px solid var(--color-border);
	font-size: 13px;
	font-weight: 600;
}
.notif-dropdown__mark-all {
	background: none;
	border: none;
	color: var(--color-secondary);
	font-size: 12px;
	font-weight: 400;
	cursor: pointer;
}
.notif-dropdown__mark-all:hover { text-decoration: underline; }

.notif-dropdown__list { max-height: 360px; overflow-y: auto; }

.notif-dropdown__empty { padding: 24px 16px; text-align: center; font-size: 13px; color: var(--color-text-muted); }

.notif-item {
	display: block;
	padding: 12px 16px;
	border-bottom: 1px solid var(--color-border);
	text-decoration: none;
	position: relative;
}
.notif-item:hover { background: var(--color-surface-alt); }
.notif-item.is-unread::before {
	content: "";
	position: absolute;
	left: 6px;
	top: 18px;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--color-accent);
}
.notif-item.is-unread { padding-left: 22px; }
.notif-item__titre { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.notif-item__message { font-size: 12px; color: var(--color-text-muted); margin-bottom: 4px; }
.notif-item__date { font-size: 11px; color: var(--color-text-muted); }

.notif-dropdown__footer {
	display: block;
	text-align: center;
	padding: 10px;
	font-size: 12px;
	color: var(--color-secondary);
	text-decoration: none;
	border-top: 1px solid var(--color-border);
}
.notif-dropdown__footer:hover { text-decoration: underline; }

/* =========================================================================
   Notifications toast (confirmation après une action dans une fenêtre)
   ========================================================================= */

#toast-container {
	position: fixed;
	top: 20px;
	right: 20px;
	z-index: 200;
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-width: 360px;
}

.toast {
	background: var(--color-surface);
	border: 1px solid var(--color-border);
	border-left: 3px solid var(--color-text-muted);
	border-radius: var(--radius-sm);
	padding: 13px 16px;
	font-size: 13px;
	box-shadow: var(--shadow-card);
	opacity: 0;
	transform: translateX(16px);
	transition: opacity .2s ease, transform .2s ease;
}
.toast.is-visible { opacity: 1; transform: translateX(0); }
.toast--success { border-left-color: var(--color-success); }
.toast--error { border-left-color: var(--color-danger); }

/* =========================================================================
   Modales (produits, catégories, unités)
   ========================================================================= */

.modal-overlay {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(10,12,14,.6);
	z-index: 100;
	align-items: flex-start;
	justify-content: center;
	padding: 40px 20px;
	overflow-y: auto;
}
.modal-overlay.is-open { display: flex; }

.modal {
	background: var(--color-surface);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-lg);
	width: 100%;
	max-width: 640px;
	box-shadow: var(--shadow-card);
}

.modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20px 24px;
	border-bottom: 1px solid var(--color-border);
}
.modal__header h2 { font-family: var(--font-display); font-size: 17px; font-weight: 600; }

.modal__close {
	background: none;
	border: none;
	color: var(--color-text-muted);
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}
.modal__close:hover { color: var(--color-text); }

.modal__body { padding: 24px; max-height: 70vh; overflow-y: auto; }

.modal__footer {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	padding: 16px 24px;
	border-top: 1px solid var(--color-border);
}

.form-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 4px 16px;
}
@media (max-width: 560px) {
	.form-grid { grid-template-columns: 1fr; }
}

.edisira-app select {
	background: var(--color-surface);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-sm);
	color: var(--color-text);
	font-size: 14px;
	padding: 11px 13px;
}
.edisira-app select:focus {
	border-color: var(--color-accent);
	outline: none;
}

.form-grid select {
	width: 100%;
	background: var(--color-surface);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-sm);
	padding: 11px 13px;
	font-size: 14px;
	color: var(--color-text);
}

.field-hint {
	font-size: 12px;
	color: var(--color-text-muted);
	margin-top: -12px;
	margin-bottom: 14px;
}

.list-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 12px;
	border-bottom: 1px solid var(--color-border);
	font-size: 13px;
}
.list-row:last-child { border-bottom: none; }

.list-row button {
	background: none;
	border: none;
	color: var(--color-text-muted);
	font-size: 16px;
	cursor: pointer;
	line-height: 1;
}
.list-row button:hover { color: var(--color-danger); }

.empty-state {
	position: relative;
	border-radius: var(--radius-md);
	overflow: hidden;
	padding: 40px 20px;
	text-align: center;
	color: var(--color-text-muted);
	font-size: 13px;
}
