/* ═══════════════════════════════════════════════════════════════
   Plugin : demo_agro_mes — Styles Globaux MES Agroalimentaire
   ═══════════════════════════════════════════════════════════════ */

/* ── Variables Design ────────────────────────────────────────── */
:root {
	--mes-primary: #1a73e8;
	--mes-primary-light: #e8f0fe;
	--mes-success: #0d9f6e;
	--mes-success-light: #def7ec;
	--mes-warning: #f59e0b;
	--mes-warning-light: #fef3c7;
	--mes-danger: #dc2626;
	--mes-danger-light: #fee2e2;
	--mes-info: #3b82f6;
	--mes-info-light: #dbeafe;
	--mes-neutral: #6b7280;
	--mes-neutral-light: #f3f4f6;
	--mes-dark: #1f2937;
	--mes-bg: #f8fafc;
	--mes-card: #ffffff;
	--mes-border: #e5e7eb;
	--mes-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
	--mes-shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
	--mes-radius: 12px;
	--mes-radius-sm: 8px;
	--mes-transition: .25s cubic-bezier(.4,0,.2,1);
	--mes-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Page Header MES ─────────────────────────────────────────── */
.mes-page-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px;
	margin-bottom: 20px;
	border-bottom: 1px solid var(--mes-border);
}
/* Marge globale contenu pages MES */
.mes-kpi-grid,
.mes-sim-grid,
.mes-page-header ~ .row,
.mes-page-header ~ .mb-3,
.ord-scorebar,
.ord-main {
	margin-left: 20px;
	margin-right: 20px;
}
.mes-page-header h1 {
	font-family: var(--mes-font);
	font-size: 1.5rem;
	font-weight: 700;
	color: var(--mes-dark);
	margin: 0;
	display: flex;
	align-items: center;
	gap: 10px;
}
.mes-page-header h1 .icon {
	width: 28px;
	height: 28px;
	color: var(--mes-primary);
}
.mes-page-header .mes-actions {
	display: flex;
	gap: 8px;
}

/* ── Onglets MES ─────────────────────────────────────────────── */
.mes-tabs {
	background: var(--mes-card);
	border-radius: var(--mes-radius) var(--mes-radius) 0 0;
	border: 1px solid var(--mes-border);
	border-bottom: none;
	padding: 0 16px;
	display: flex;
	gap: 0;
	overflow-x: auto;
}
.mes-tabs .nav-link {
	font-family: var(--mes-font);
	font-size: .85rem;
	font-weight: 500;
	color: var(--mes-neutral);
	padding: 14px 20px;
	border: none;
	border-bottom: 3px solid transparent;
	border-radius: 0;
	transition: var(--mes-transition);
	white-space: nowrap;
	display: flex;
	align-items: center;
	gap: 8px;
}
.mes-tabs .nav-link:hover {
	color: var(--mes-primary);
	background: var(--mes-primary-light);
}
.mes-tabs .nav-link.active {
	color: var(--mes-primary);
	border-bottom-color: var(--mes-primary);
	background: transparent;
	font-weight: 600;
}
.mes-tabs .nav-link .icon {
	width: 18px;
	height: 18px;
}
.mes-tab-content {
	background: var(--mes-card);
	border: 1px solid var(--mes-border);
	border-top: none;
	border-radius: 0 0 var(--mes-radius) var(--mes-radius);
	padding: 24px;
	min-height: 500px;
}

/* ── Cards MES ───────────────────────────────────────────────── */
.mes-card {
	background: var(--mes-card);
	border: 1px solid var(--mes-border);
	border-radius: var(--mes-radius);
	box-shadow: var(--mes-shadow);
	padding: 20px;
	transition: var(--mes-transition);
}
.mes-card:hover {
	box-shadow: var(--mes-shadow-lg);
}
.mes-card-title {
	font-family: var(--mes-font);
	font-size: .8rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .5px;
	color: var(--mes-neutral);
	margin-bottom: 12px;
	display: flex;
	align-items: center;
	gap: 6px;
}
.mes-card-title .icon {
	width: 16px;
	height: 16px;
}

/* ── KPI Widgets ─────────────────────────────────────────────── */
.mes-kpi-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: 16px;
	margin-bottom: 24px;
}
.mes-kpi {
	background: var(--mes-card);
	border: 1px solid var(--mes-border);
	border-radius: var(--mes-radius-sm);
	padding: 16px;
	text-align: center;
	transition: var(--mes-transition);
}
.mes-kpi:hover {
	transform: translateY(-2px);
	box-shadow: var(--mes-shadow-lg);
}
.mes-kpi-label {
	font-family: var(--mes-font);
	font-size: .7rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .5px;
	color: var(--mes-neutral);
	margin-bottom: 6px;
}
.mes-kpi-value {
	font-family: var(--mes-font);
	font-size: 1.8rem;
	font-weight: 700;
	color: var(--mes-dark);
	line-height: 1;
}
.mes-kpi-unit {
	font-size: .75rem;
	font-weight: 400;
	color: var(--mes-neutral);
	margin-left: 2px;
}
.mes-kpi-trend {
	font-size: .75rem;
	margin-top: 4px;
}
.mes-kpi-trend.up { color: var(--mes-success); }
.mes-kpi-trend.down { color: var(--mes-danger); }

/* ── Machine Status Badges ───────────────────────────────────── */
.mes-status {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-family: var(--mes-font);
	font-size: .75rem;
	font-weight: 600;
	padding: 4px 10px;
	border-radius: 20px;
	white-space: nowrap;
}
.mes-status::before {
	content: '';
	width: 8px;
	height: 8px;
	border-radius: 50%;
	flex-shrink: 0;
}
.mes-status.running { background: var(--mes-success-light); color: var(--mes-success); }
.mes-status.running::before { background: var(--mes-success); animation: mes-pulse 2s infinite; }
.mes-status.changeover { background: var(--mes-warning-light); color: #d97706; }
.mes-status.changeover::before { background: var(--mes-warning); animation: mes-pulse 1.5s infinite; }
.mes-status.stopped { background: var(--mes-danger-light); color: var(--mes-danger); }
.mes-status.stopped::before { background: var(--mes-danger); }
.mes-status.inactive { background: var(--mes-neutral-light); color: var(--mes-neutral); }
.mes-status.inactive::before { background: #d1d5db; }
.mes-status.planned { background: var(--mes-info-light); color: var(--mes-info); }
.mes-status.planned::before { background: var(--mes-info); }
.mes-status.completed { background: #ecfdf5; color: #065f46; }
.mes-status.completed::before { background: #059669; }

@keyframes mes-pulse {
	0%, 100% { opacity: 1; }
	50% { opacity: .4; }
}

/* ── Synoptique SVG ──────────────────────────────────────────── */
.mes-synoptic-container {
	width: 100%;
	overflow-x: auto;
	padding: 20px 0;
	display: flex;
	justify-content: center;
}
.mes-synoptic-svg {
	width: 100%;
	max-width: 1320px;
	height: 320px;
	flex-shrink: 0;
	margin: 0 auto;
	display: block;
}
.mes-machine-block {
	cursor: pointer;
	transition: var(--mes-transition);
}
.mes-machine-block:hover {
	filter: brightness(1.05);
}
.mes-machine-block:hover .mes-machine-rect {
	stroke-width: 2.5;
	stroke: var(--mes-primary);
}
.mes-machine-rect {
	rx: 8;
	ry: 8;
	stroke-width: 1.5;
	transition: var(--mes-transition);
}
.mes-machine-label {
	font-family: var(--mes-font);
	font-size: 10px;
	font-weight: 600;
	fill: #374151;
	text-anchor: middle;
}
.mes-machine-code {
	font-family: var(--mes-font);
	font-size: 8px;
	font-weight: 500;
	fill: #6b7280;
	text-anchor: middle;
}
.mes-machine-speed {
	font-family: var(--mes-font);
	font-size: 11px;
	font-weight: 700;
	fill: #1f2937;
	text-anchor: middle;
}
.mes-group-label {
	font-family: var(--mes-font);
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 1px;
	fill: var(--mes-primary);
	text-anchor: middle;
}

/* Flux animés entre machines */
.mes-flow-line {
	stroke: var(--mes-primary);
	stroke-width: 2;
	stroke-dasharray: 8 4;
	animation: mes-flow 1s linear infinite;
	opacity: .5;
}
.mes-flow-line.active {
	opacity: 1;
	stroke: var(--mes-success);
}
@keyframes mes-flow {
	to { stroke-dashoffset: -12; }
}

/* Particules animées */
.mes-particle {
	fill: var(--mes-success);
	opacity: 0;
}
.mes-particle.active {
	animation: mes-particle-move 2s linear infinite;
}
@keyframes mes-particle-move {
	0%   { opacity: 1; }
	100% { opacity: 0; }
}

/* ── Gantt Chart ─────────────────────────────────────────────── */
.mes-gantt-container {
	display: flex;
	gap: 20px;
	min-height: 400px;
}
.mes-gantt-backlog {
	width: 320px;
	flex-shrink: 0;
}
.mes-gantt-chart {
	flex: 1;
	overflow-x: auto;
	position: relative;
}
.mes-gantt-header {
	display: flex;
	border-bottom: 2px solid var(--mes-border);
	position: sticky;
	top: 0;
	background: var(--mes-card);
	z-index: 2;
}
.mes-gantt-hour {
	min-width: 80px;
	padding: 8px;
	text-align: center;
	font-family: var(--mes-font);
	font-size: .75rem;
	font-weight: 500;
	color: var(--mes-neutral);
	border-right: 1px solid var(--mes-border);
}
.mes-gantt-bar {
	position: absolute;
	height: 36px;
	border-radius: 6px;
	font-family: var(--mes-font);
	font-size: .7rem;
	font-weight: 600;
	color: #fff;
	display: flex;
	align-items: center;
	padding: 0 10px;
	cursor: grab;
	transition: box-shadow var(--mes-transition);
	overflow: hidden;
	white-space: nowrap;
}
.mes-gantt-bar:active { cursor: grabbing; }
.mes-gantt-bar:hover { box-shadow: var(--mes-shadow-lg); }
.mes-gantt-bar.planned { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.mes-gantt-bar.running { background: linear-gradient(135deg, #10b981, #059669); }
.mes-gantt-bar.completed { background: linear-gradient(135deg, #6b7280, #4b5563); }
.mes-gantt-bar.late { background: linear-gradient(135deg, #ef4444, #dc2626); }
.mes-gantt-bar.changeover {
	background: repeating-linear-gradient(45deg, #f59e0b, #f59e0b 5px, #d97706 5px, #d97706 10px);
	opacity: .7;
}

/* ── Backlog OF Cards ────────────────────────────────────────── */
.mes-wo-card {
	background: var(--mes-card);
	border: 1px solid var(--mes-border);
	border-left: 4px solid var(--mes-primary);
	border-radius: var(--mes-radius-sm);
	padding: 12px;
	margin-bottom: 8px;
	cursor: grab;
	transition: var(--mes-transition);
	font-family: var(--mes-font);
}
.mes-wo-card:hover {
	box-shadow: var(--mes-shadow-lg);
	transform: translateY(-1px);
}
.mes-wo-card:active { cursor: grabbing; }
.mes-wo-card.priority-1 { border-left-color: var(--mes-danger); }
.mes-wo-card.priority-2 { border-left-color: var(--mes-primary); }
.mes-wo-card.priority-3 { border-left-color: var(--mes-neutral); }
.mes-wo-card .wo-number {
	font-size: .8rem;
	font-weight: 700;
	color: var(--mes-dark);
}
.mes-wo-card .wo-product {
	font-size: .75rem;
	color: var(--mes-neutral);
	margin-top: 2px;
}
.mes-wo-card .wo-meta {
	display: flex;
	justify-content: space-between;
	margin-top: 8px;
	font-size: .7rem;
	color: var(--mes-neutral);
}

/* ── Simulation Console ──────────────────────────────────────── */
.mes-console {
	background: #111827;
	border-radius: var(--mes-radius-sm);
	padding: 16px;
	max-height: 300px;
	overflow-y: auto;
	font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
	font-size: .75rem;
	line-height: 1.6;
}
.mes-console-line {
	color: #d1d5db;
}
.mes-console-line .ts {
	color: #6b7280;
}
.mes-console-line.info { color: #60a5fa; }
.mes-console-line.success { color: #34d399; }
.mes-console-line.warning { color: #fbbf24; }
.mes-console-line.error { color: #f87171; }

/* ── Progress Bar ────────────────────────────────────────────── */
.mes-progress {
	height: 8px;
	background: var(--mes-neutral-light);
	border-radius: 4px;
	overflow: hidden;
}
.mes-progress-bar {
	height: 100%;
	border-radius: 4px;
	background: linear-gradient(90deg, var(--mes-primary), var(--mes-success));
	transition: width .6s ease;
}

/* ── NC Severity Badges ──────────────────────────────────────── */
.mes-severity.minor { background: #dbeafe; color: #1e40af; padding: 2px 8px; border-radius: 12px; font-size: .7rem; font-weight: 600; }
.mes-severity.major { background: #fef3c7; color: #92400e; padding: 2px 8px; border-radius: 12px; font-size: .7rem; font-weight: 600; }
.mes-severity.critical { background: #fee2e2; color: #991b1b; padding: 2px 8px; border-radius: 12px; font-size: .7rem; font-weight: 600; }

/* ── Gauge TRS ───────────────────────────────────────────────── */
.mes-gauge-container {
	display: flex;
	justify-content: center;
	gap: 32px;
	flex-wrap: wrap;
	margin-bottom: 24px;
}
.mes-gauge {
	text-align: center;
	width: 160px;
}
.mes-gauge svg {
	width: 140px;
	height: 140px;
}
.mes-gauge-label {
	font-family: var(--mes-font);
	font-size: .75rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .5px;
	color: var(--mes-neutral);
	margin-top: 8px;
}
.mes-gauge-value {
	font-family: var(--mes-font);
	font-size: 1.1rem;
	font-weight: 700;
}
.mes-gauge-track {
	fill: none;
	stroke: #e5e7eb;
	stroke-width: 10;
}
.mes-gauge-fill {
	fill: none;
	stroke-width: 10;
	stroke-linecap: round;
	transition: stroke-dashoffset 1s ease;
}

/* ── Simulation Machine Grid ─────────────────────────────────── */
.mes-sim-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 12px;
}
.mes-sim-machine {
	background: var(--mes-card);
	border: 1px solid var(--mes-border);
	border-radius: var(--mes-radius-sm);
	padding: 14px;
	transition: var(--mes-transition);
}
.mes-sim-machine.state-running { border-left: 4px solid var(--mes-success); }
.mes-sim-machine.state-stopped { border-left: 4px solid var(--mes-danger); }
.mes-sim-machine.state-changeover { border-left: 4px solid var(--mes-warning); }
.mes-sim-machine.state-inactive { border-left: 4px solid #d1d5db; }
.mes-sim-machine-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 8px;
}
.mes-sim-machine-name {
	font-family: var(--mes-font);
	font-size: .8rem;
	font-weight: 600;
	color: var(--mes-dark);
}
.mes-sim-machine-code {
	font-family: var(--mes-font);
	font-size: .7rem;
	color: var(--mes-neutral);
}
.mes-sim-machine-counters {
	display: flex;
	gap: 12px;
	font-family: var(--mes-font);
	font-size: .75rem;
}
.mes-sim-counter {
	display: flex;
	flex-direction: column;
	align-items: center;
}
.mes-sim-counter-val {
	font-size: 1rem;
	font-weight: 700;
	color: var(--mes-dark);
}
.mes-sim-counter-label {
	font-size: .65rem;
	color: var(--mes-neutral);
	text-transform: uppercase;
}

/* ── Buttons MES ─────────────────────────────────────────────── */
.btn-mes {
	font-family: var(--mes-font);
	font-size: .8rem;
	font-weight: 600;
	padding: 8px 16px;
	border-radius: var(--mes-radius-sm);
	border: none;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	transition: var(--mes-transition);
	cursor: pointer;
}
.btn-mes .icon { width: 16px; height: 16px; }
.btn-mes-primary { background: var(--mes-primary); color: #fff; }
.btn-mes-primary:hover { background: #1557b0; color: #fff; }
.btn-mes-success { background: var(--mes-success); color: #fff; }
.btn-mes-success:hover { background: #087f5b; color: #fff; }
.btn-mes-danger { background: var(--mes-danger); color: #fff; }
.btn-mes-danger:hover { background: #b91c1c; color: #fff; }
.btn-mes-warning { background: var(--mes-warning); color: #fff; }
.btn-mes-warning:hover { background: #d97706; color: #fff; }
.btn-mes-outline {
	background: transparent;
	color: var(--mes-neutral);
	border: 1px solid var(--mes-border);
}
.btn-mes-outline:hover {
	background: var(--mes-neutral-light);
	color: var(--mes-dark);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
	.mes-gantt-container { flex-direction: column; }
	.mes-gantt-backlog { width: 100%; }
	.mes-kpi-grid { grid-template-columns: repeat(2, 1fr); }
	.mes-gauge-container { gap: 16px; }
	.mes-tabs .nav-link { padding: 10px 14px; font-size: .78rem; }
	.ord-main { flex-direction: column; }
	.ord-right-panel { width: 100%; }
}

/* ═══════════════════════════════════════════════════════════════
   ORDONNANCEUR — Styles Planning OF
   ═══════════════════════════════════════════════════════════════ */

/* ── Scorebar ────────────────────────────────────────────────── */
.ord-scorebar {
	display: flex;
	background: var(--mes-card);
	border: 1px solid var(--mes-border);
	border-radius: var(--mes-radius);
	margin-top: 20px;
	margin-bottom: 16px;
	box-shadow: var(--mes-shadow);
	overflow: hidden;
}
.ord-sc-item {
	flex: 1;
	padding: 12px 20px;
	border-right: 1px solid var(--mes-border);
	display: flex;
	align-items: center;
	gap: 12px;
}
.ord-sc-item:last-child { border-right: none; }
.ord-sc-icon { font-size: 18px; flex-shrink: 0; }
.ord-sc-label {
	font-family: var(--mes-font);
	font-size: 9px;
	text-transform: uppercase;
	letter-spacing: 1px;
	color: var(--mes-neutral);
	font-weight: 600;
}
.ord-sc-value {
	font-family: var(--mes-font);
	font-weight: 800;
	font-size: 20px;
	color: var(--mes-dark);
	line-height: 1.1;
}

/* ── Main Layout ─────────────────────────────────────────────── */
.ord-main {
	display: flex;
	gap: 0;
	min-height: 560px;
	border: 1px solid var(--mes-border);
	border-radius: var(--mes-radius);
	overflow: hidden;
	background: var(--mes-card);
	box-shadow: var(--mes-shadow);
}

/* ── Left Panel: Séquenceur ──────────────────────────────────── */
.ord-seq-panel {
	flex: 1;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border-right: 1px solid var(--mes-border);
}
.ord-panel-hd {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 18px;
	background: var(--mes-card);
	border-bottom: 1px solid var(--mes-border);
	flex-shrink: 0;
}
.ord-panel-title {
	font-family: var(--mes-font);
	font-size: 13px;
	font-weight: 700;
	display: flex;
	align-items: center;
	gap: 6px;
}
.ord-panel-title .icon { width: 16px; height: 16px; color: var(--mes-primary); }
.ord-panel-sub {
	font-size: 10px;
	color: var(--mes-neutral);
	margin-top: 2px;
}

/* ── Séquence scroll ─────────────────────────────────────────── */
.ord-seq-scroll {
	flex: 1;
	overflow-y: auto;
	padding: 14px 18px;
	display: flex;
	flex-direction: column;
}
.ord-seq-scroll::-webkit-scrollbar { width: 3px; }
.ord-seq-scroll::-webkit-scrollbar-thumb { background: #c5c9d8; border-radius: 2px; }

/* ── OF Card ─────────────────────────────────────────────────── */
.ord-of-card {
	background: var(--mes-card);
	border: 1.5px solid var(--mes-border);
	border-radius: 8px;
	padding: 10px 12px;
	display: flex;
	align-items: center;
	gap: 10px;
	cursor: grab;
	transition: all .18s;
	position: relative;
	user-select: none;
	font-family: var(--mes-font);
}
.ord-of-card:active { cursor: grabbing; }
.ord-of-card:hover {
	box-shadow: 0 4px 14px rgba(0,0,0,.09);
	border-color: #b0b5c8;
	transform: translateX(2px);
}
.ord-of-card.dragging { opacity: .35; transform: scale(.98); }
.ord-of-card.drag-over { border-color: var(--mes-primary) !important; box-shadow: 0 0 0 2px rgba(26,115,232,.18); }
.ord-of-card.priority-1 { border-left: 3px solid var(--mes-danger); }
.ord-of-card.priority-3 { border-left: 3px solid #d1d5db; }

.ord-of-rank {
	width: 24px; height: 24px; border-radius: 50%;
	display: flex; align-items: center; justify-content: center;
	font-weight: 700; font-size: 11px;
	background: var(--mes-neutral-light); color: var(--mes-neutral);
	flex-shrink: 0;
}
.ord-of-drag { color: #c5c9d8; font-size: 14px; cursor: grab; flex-shrink: 0; line-height: 1; }
.ord-of-body { flex: 1; overflow: hidden; min-width: 0; }
.ord-of-num { font-size: 9px; color: var(--mes-neutral); }
.ord-of-name {
	font-weight: 700; font-size: 12px;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ord-of-tags { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.ord-tag {
	padding: 2px 7px; border-radius: 8px;
	font-size: 8px; font-weight: 600; letter-spacing: .3px;
}
.ord-tag-product { background: #ebe8ff; color: #4a3faa; }
.ord-tag-urgent { background: #ffe0e0; color: #b02020; }
.ord-tag-speed { background: #f0f0f0; color: #555; }
.ord-tag-qty { background: #e8f5e9; color: #2e7d32; }
.ord-tag-changeover { background: #fff3cc; color: #8a6000; }

.ord-of-right {
	display: flex; flex-direction: column;
	align-items: flex-end; gap: 3px; flex-shrink: 0;
}
.ord-of-dur { font-size: 10px; color: var(--mes-neutral); }
.ord-of-qte { font-size: 10px; font-weight: 500; }

/* ── Setup Connector ─────────────────────────────────────────── */
.ord-setup-connector {
	display: flex;
	align-items: center;
	padding: 0 0 0 36px;
	position: relative;
	height: 28px;
}
.ord-connector-vline {
	position: absolute;
	left: 47px;
	top: 0; bottom: 0;
	width: 1.5px;
	border-radius: 1px;
}
.ord-setup-badge {
	display: flex;
	align-items: center;
	gap: 5px;
	padding: 3px 9px 3px 7px;
	border-radius: 20px;
	font-size: 10px;
	font-weight: 600;
	font-family: var(--mes-font);
	border: 1px solid transparent;
	cursor: default;
	position: relative;
	z-index: 2;
	transition: box-shadow .15s;
	white-space: nowrap;
}
.ord-setup-badge:hover { box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.ord-sev-icon { font-size: 11px; line-height: 1; }
.ord-sev-time { font-variant-numeric: tabular-nums; }

/* Sévérité setup */
.ord-sev-none .ord-connector-vline { background: var(--mes-success); opacity: .25; }
.ord-sev-none .ord-setup-badge { background: #f0fdf8; color: #0e6e42; border-color: rgba(16,185,129,.2); }
.ord-sev-low .ord-connector-vline { background: #c9930f; opacity: .35; }
.ord-sev-low .ord-setup-badge { background: #fefce8; color: #a07a00; border-color: rgba(201,147,15,.2); }
.ord-sev-med .ord-connector-vline { background: var(--mes-warning); opacity: .45; }
.ord-sev-med .ord-setup-badge { background: #fff7ed; color: #b05a00; border-color: rgba(245,158,11,.25); }
.ord-sev-high .ord-connector-vline { background: var(--mes-danger); opacity: .6; }
.ord-sev-high .ord-setup-badge { background: #fff1f1; color: #c02020; border-color: rgba(220,30,30,.25); }

/* Tooltip setup */
.ord-setup-tooltip {
	display: none;
	position: absolute;
	left: 50%;
	top: calc(100% + 5px);
	transform: translateX(-20px);
	background: var(--mes-dark);
	color: #e8eaf2;
	border-radius: 7px;
	padding: 8px 11px;
	font-size: 10px;
	line-height: 1.6;
	z-index: 50;
	pointer-events: none;
	box-shadow: 0 8px 24px rgba(0,0,0,.18);
	min-width: 160px;
	white-space: nowrap;
}
.ord-setup-tooltip::before {
	content: '';
	position: absolute;
	top: -5px; left: 18px;
	border: 5px solid transparent;
	border-top: none;
	border-bottom-color: var(--mes-dark);
}
.ord-setup-badge:hover .ord-setup-tooltip { display: block; }
.ord-tt-row { display: flex; justify-content: space-between; gap: 16px; }
.ord-tt-key { color: rgba(232,234,242,.55); }
.ord-tt-val { font-weight: 600; }

/* ── Right Panel ─────────────────────────────────────────────── */
.ord-right-panel {
	width: 340px;
	flex-shrink: 0;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

/* ── Mini Gantt ──────────────────────────────────────────────── */
.ord-gantt-mini {
	padding: 14px;
	background: var(--mes-card);
	border-bottom: 1px solid var(--mes-border);
}
.ord-gm-title {
	font-family: var(--mes-font);
	font-size: 12px;
	font-weight: 700;
	margin-bottom: 10px;
	display: flex;
	justify-content: space-between;
}
.ord-gm-total { font-size: 10px; color: var(--mes-neutral); }
.ord-gm-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.ord-gm-label {
	font-family: var(--mes-font);
	font-size: 8px; color: var(--mes-neutral);
	width: 56px; flex-shrink: 0;
	text-align: right;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ord-gm-track {
	flex: 1; height: 18px;
	background: var(--mes-neutral-light);
	border-radius: 3px;
	position: relative; overflow: hidden;
}
.ord-gm-seg {
	position: absolute; top: 1px; bottom: 1px;
	border-radius: 2px;
	display: flex; align-items: center;
	padding: 0 3px; font-size: 7px;
	overflow: hidden; white-space: nowrap;
	color: rgba(0,0,0,.6); font-weight: 600;
	font-family: var(--mes-font);
}
.ord-gm-setup {
	position: absolute; top: 0; bottom: 0;
	background: repeating-linear-gradient(90deg,rgba(0,0,0,.07) 0,rgba(0,0,0,.07) 2px,transparent 2px,transparent 5px);
}
.ord-gm-legend { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.ord-leg-item {
	display: flex; align-items: center; gap: 4px;
	font-size: 8px; color: var(--mes-neutral);
	font-family: var(--mes-font);
}
.ord-leg-box { width: 10px; height: 10px; border-radius: 2px; }

/* ── Summary Section ─────────────────────────────────────────── */
.ord-summary-section {
	flex: 1;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}
.ord-summary-scroll {
	flex: 1;
	overflow-y: auto;
	padding: 12px 14px;
}
.ord-product-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 6px 0;
	border-bottom: 1px solid var(--mes-border);
	font-family: var(--mes-font);
	font-size: 11px;
}
.ord-product-row:last-child { border-bottom: none; }
.ord-product-code { font-weight: 700; color: var(--mes-dark); }
.ord-product-count { color: var(--mes-neutral); font-size: 10px; }

/* ── Propose Banner ──────────────────────────────────────────── */
.ord-propose-banner {
	display: none;
	background: linear-gradient(135deg, #eef0ff, #f0fff8);
	border: 1px solid rgba(26,115,232,.2);
	border-radius: 8px;
	padding: 12px 14px;
	margin: 0 18px;
	flex-shrink: 0;
}
.ord-propose-banner.show { display: block; }
.ord-pb-title {
	font-family: var(--mes-font);
	font-size: 12px; font-weight: 700;
	color: var(--mes-primary); margin-bottom: 6px;
}
.ord-pb-stats { display: flex; gap: 14px; margin-bottom: 10px; }
.ord-pb-stat { font-size: 10px; font-family: var(--mes-font); }
.ord-pb-stat strong { font-weight: 700; }
.ord-pb-actions { display: flex; gap: 6px; }

/* ── Opt saved badge ─────────────────────────────────────────── */
.ord-opt-saved {
	display: none;
	font-size: 10px;
	color: var(--mes-success);
	font-weight: 500;
	font-family: var(--mes-font);
}
.ord-opt-saved.show { display: inline; }

/* ── Toast ───────────────────────────────────────────────────── */
.ord-toast {
	position: fixed;
	bottom: 20px;
	left: 50%;
	transform: translateX(-50%);
	background: var(--mes-dark);
	color: #fff;
	padding: 10px 20px;
	border-radius: 8px;
	font-family: var(--mes-font);
	font-size: 12px;
	z-index: 999;
	opacity: 0;
	pointer-events: none;
	transition: opacity .25s;
	box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.ord-toast.show { opacity: 1; }


/* ── Bouton Header "Lancer la simulation" ─────────────────── */
.mes-header-btn {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 6px 14px;
	border: none;
	border-radius: 20px;
	font-family: var(--mes-font);
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	transition: background var(--mes-transition), box-shadow var(--mes-transition), transform .1s;
	white-space: nowrap;
	line-height: 1.2;
}
.mes-header-btn:active { transform: scale(.97); }

/* Dot LED status */
.mes-header-btn__dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	flex-shrink: 0;
	transition: background var(--mes-transition);
}

/* État idle */
.mes-header-btn--idle {
	background: rgba(255,255,255,.12);
	color: rgba(255,255,255,.85);
	border: 1px solid rgba(255,255,255,.2);
}
.mes-header-btn--idle .mes-header-btn__dot {
	background: rgba(255,255,255,.4);
}
.mes-header-btn--idle:hover {
	background: rgba(255,255,255,.2);
	color: #fff;
}

/* État running — vert pulsant */
.mes-header-btn--running {
	background: linear-gradient(135deg, #059669, #10b981);
	color: #fff;
	border: 1px solid rgba(16,185,129,.3);
	box-shadow: 0 0 0 0 rgba(16,185,129,.5);
	animation: mes-btn-pulse 2s infinite;
}
.mes-header-btn--running .mes-header-btn__dot {
	background: #fff;
	box-shadow: 0 0 6px rgba(255,255,255,.8);
	animation: mes-dot-blink 1s step-end infinite;
}
.mes-header-btn--running:hover {
	background: linear-gradient(135deg, #047857, #059669);
}

/* État paused — orange */
.mes-header-btn--paused {
	background: linear-gradient(135deg, #d97706, #f59e0b);
	color: #fff;
	border: 1px solid rgba(245,158,11,.3);
}
.mes-header-btn--paused .mes-header-btn__dot {
	background: #fff;
}

/* État busy — grisé */
.mes-header-btn--busy {
	background: rgba(255,255,255,.08);
	color: rgba(255,255,255,.5);
	border: 1px solid rgba(255,255,255,.1);
	cursor: wait;
}
.mes-header-btn--busy .mes-header-btn__dot {
	background: rgba(255,255,255,.3);
	animation: mes-dot-spin .8s linear infinite;
}

@keyframes mes-btn-pulse {
	0%   { box-shadow: 0 0 0 0 rgba(16,185,129,.5); }
	70%  { box-shadow: 0 0 0 8px rgba(16,185,129,0); }
	100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}
@keyframes mes-dot-blink {
	0%, 100% { opacity: 1; }
	50%       { opacity: .3; }
}
@keyframes mes-dot-spin {
	to { transform: rotate(360deg); border-radius: 0; }
}

/* ── Boutons Start / Stop OF dans le Planning ─────────────── */
.ord-of-actions {
	margin-top: 6px;
	display: flex;
	gap: 4px;
}
.ord-of-actions .btn-mes {
	padding: 3px 9px;
	font-size: 10px;
	border-radius: 6px;
	display: inline-flex;
	align-items: center;
	gap: 3px;
}
.ord-of-actions .btn-mes .icon {
	width: 12px;
	height: 12px;
}

/* OF en cours de production — surbrillance verte */
.ord-of-card--running {
	border-left: 3px solid #10b981 !important;
	background: linear-gradient(135deg, rgba(16,185,129,.04), rgba(255,255,255,1)) !important;
	box-shadow: 0 0 0 1px rgba(16,185,129,.15), var(--mes-shadow) !important;
}
.ord-of-card--running .ord-of-rank {
	background: #10b981 !important;
	color: #fff !important;
}

/* =========================================================================
   PAGE ARRÊTS & SOUS-CADENCES
   ========================================================================= */

/* Animation Pulse pour l'en cours */
@keyframes mesPulseBadge {
	0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7); }
	70% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
	100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}
.pulse-badge {
	animation: mesPulseBadge 2s infinite;
}

/* Animation Pulse pour la carte sous-cadence complète */
@keyframes mesPulseCardWarning {
	0% { border-left-color: rgba(245, 158, 11, 1); box-shadow: 0 4px 12px rgba(245,158,11,0.2); }
	50% { border-left-color: rgba(245, 158, 11, 0.4); box-shadow: 0 4px 12px rgba(245,158,11,0.05); }
	100% { border-left-color: rgba(245, 158, 11, 1); box-shadow: 0 4px 12px rgba(245,158,11,0.2); }
}
.sc-card-pulse {
	animation: mesPulseCardWarning 3s infinite ease-in-out;
}

/* Styles Datatables MES */
table.mes-table.dataTable {
	border-collapse: collapse !important;
	border-radius: var(--mes-radius);
	overflow: hidden;
	width: 100% !important;
}
table.mes-table.dataTable thead th {
	background-color: #f8fafc;
	border-bottom: 1px solid var(--mes-border);
	font-weight: 600;
	color: #64748b;
	text-transform: uppercase;
	font-size: 0.75rem;
	letter-spacing: 0.5px;
	padding: 12px 15px;
}
table.mes-table.dataTable tbody td {
	padding: 12px 15px;
	vertical-align: middle;
	border-bottom: 1px solid var(--mes-border);
	font-size: 0.85rem;
}
table.mes-table.dataTable.table-hover tbody tr:hover {
	background-color: #f1f5f9;
}
table.mes-table.dataTable tr.table-danger {
	background-color: rgba(254, 226, 226, 0.4) !important;
}
table.mes-table.dataTable tr.table-danger td {
	color: #991b1b;
}

/* Wizard Steps Styling */
.wizard-steps { gap: 10px; }
.step { display: flex; flex-direction: column; align-items: center; color: #adb5bd; position: relative; transition: all 0.3s ease; }
.step.active { color: #E5A000; }
.step.completed { color: #198754; }
.step-num { width: 32px; height: 32px; border-radius: 50%; background-color: #f8f9fa; border: 2px solid #dee2e6; display: flex; align-items: center; justify-content: center; font-weight: bold; margin-bottom: 5px; transition: all 0.3s ease; }
.step.active .step-num { border-color: #E5A000; background-color: #E5A000; color: white; box-shadow: 0 0 10px rgba(229, 160, 0, 0.3); }
.step.completed .step-num { border-color: #198754; background-color: #198754; color: white; }
.step-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; }
.step-line { height: 2px; width: 50px; background-color: #dee2e6; margin-bottom: 25px; }
.step.completed + .step-line { background-color: #198754; }

/* Severity & Status Badges (MES Style) */
.mes-severity { padding: 0.25rem 0.6rem; border-radius: 30px; font-size: 0.75rem; font-weight: 600; }
.mes-severity.minor { background: #e3f2fd; color: #0d6efd; }
.mes-severity.major { background: #fff3e0; color: #f57c00; }
.mes-severity.critical { background: #ffebee; color: #d32f2f; }
.mes-status { padding: 0.25rem 0.6rem; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.mes-status.detected { background: #f8f9fa; color: #6c757d; border: 1px solid #dee2e6; }
.mes-status.analyzing { background: #e3f2fd; color: #0d6efd; border: 1px solid #bbdefb; }
.mes-status.resolved { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.mes-status.closed { background: #343a40; color: #fff; }

/* Flat Status Buttons */
.btn-mes-outline { background-color: #f8f9fa; border: 1px solid #dee2e6; color: #495057; padding: 0.4rem 1rem; border-radius: 6px; font-weight: 500; font-size: 0.875rem; transition: all 0.2s ease; box-shadow: none; }
.btn-mes-outline:hover { background-color: #f1f3f5; color: #212529; }
.btn-mes-outline.active { background-color: #E5A000; border-color: #E5A000; color: #fff; box-shadow: 0 2px 5px rgba(229, 160, 0, 0.2); }

/* Modal Positioning */
#modal-nc .modal-dialog { margin-top: 50px; }
