
/* ════════════════════════════════════════════════
   IBORA — Couleur de marque : rouge brique
   ════════════════════════════════════════════════ */
:root {
	--accent:              #c0392b;
	--accent-hover:        #a93226;
	/* Bootstrap overrides */
	--bs-primary:          #c0392b;
	--bs-primary-rgb:      192, 57, 43;
	--bs-link-color:       #c0392b;
	--bs-link-hover-color: #a93226;
}

.btn-primary {
	--bs-btn-bg:                #c0392b;
	--bs-btn-border-color:      #c0392b;
	--bs-btn-hover-bg:          #a93226;
	--bs-btn-hover-border-color:#a93226;
	--bs-btn-active-bg:         #922b1e;
	--bs-btn-active-border-color:#922b1e;
	--bs-btn-disabled-bg:       #c0392b;
	--bs-btn-disabled-border-color:#c0392b;
}

.btn-outline-primary {
	--bs-btn-color:         #c0392b;
	--bs-btn-border-color:  #c0392b;
	--bs-btn-hover-bg:      #c0392b;
	--bs-btn-hover-border-color:#c0392b;
	--bs-btn-active-bg:     #a93226;
}

.badge.bg-primary { background-color: #c0392b !important; }
a { color: #c0392b; }
a:hover { color: #a93226; }

.page-item.active .page-link {
	background-color: #c0392b;
	border-color:     #c0392b;
}

/* ---- Menu & Order UI ---- */
.ticket_label {
	font-weight: 600;
	text-transform: uppercase;
	background-color: #ffffff;
	color: var(--text-secondary);
	padding: 0 10px;
	margin-left: 10px;
}

/* ---- Order help toggle ---- */
#toggle_help {
	color: var(--text-secondary);
	cursor: pointer;
	transition: color var(--transition);
	margin-left: 8px;
	vertical-align: middle;
}

#toggle_help:hover {
	color: var(--accent);
}


/* ---- Order form utilities ---- */
.seats-input {
	text-align: center;
}

.text-nowrap { white-space: nowrap; }

.order-actions {
	display: flex;
	gap: 6px;
	justify-content: flex-end;
	align-items: center;
}

.order-actions .btn {
	padding: 6px 12px;
}

.validate-pay {
	padding: 8px 0;
	font-weight: 800;
}

.site-active {
	background: #ff3b30 !important;
	border-color: #ff3b30 !important;
	color: #fff !important;
}

.no-tables-msg {
	color: var(--text-secondary);
	font-style: italic;
	padding: 8px 0;
}

.dish-added-flash {
	animation: flash-add 0.3s ease-out;
}

@keyframes flash-add {
	0% { background-color: rgba(31, 180, 197, 0.15); }
	100% { background-color: transparent; }
}

#dishes_area {
	position: relative;
}

.btn-menu_type {
	flex: 1;
}

/* Tables grid */
.order-tables-grid {
	display: flex;
	flex-wrap: wrap;
	gap: 5px;
}

.order-table-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 36px;
	border-radius: var(--radius-sm);
	background: var(--bg-surface);
	border: 1px solid var(--border);
	cursor: pointer;
	transition: all var(--transition);
	font-weight: 600;
	color: var(--text-primary);
}

.order-table-btn:hover {
	background: rgba(31, 180, 197, 0.06);
	border-color: var(--accent);
}

.order-table-btn.disabled {
	opacity: 0.4;
	pointer-events: none;
}

.order-table-btn:has(input:checked) {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
}

.order-table-btn.occupied {
	background: #ff3b30;
	border-color: #ff3b30;
	color: #fff;
}

.order-table-btn.occupied:hover {
	background: #e0342b;
	border-color: #e0342b;
}

.order-table-btn.occupied:has(input:checked) {
	background: #cc2d26;
	border-color: #cc2d26;
}

.btn-table {
	min-width: 54px;
	border-radius: var(--radius-sm) !important;
	float: none !important;
	margin-bottom: 3px;
}

/* ---- Dish breadcrumb ---- */
.dish-breadcrumb {
	display: flex;
	align-items: center;
	gap: 6px;
}

.dish-breadcrumb-item {
	color: var(--text-secondary);
	font-weight: 500;
}

.dish-breadcrumb-item.active {
	color: var(--text-primary);
	font-weight: 600;
}

.dish-breadcrumb-sep {
	color: var(--text-secondary);
}

/* ---- Dishes grid ---- */
.dishes-grid {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.btn-dish {
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: space-between;
	width: calc(50% - 4px);
	padding: 8px 12px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg-surface);
	cursor: pointer;
	transition: all var(--transition);
	text-align: left;
	color: var(--text-primary);
}

.btn-dish:hover {
	border-color: var(--accent);
	background: rgba(31, 180, 197, 0.03);
}

.btn-dish:active {
	background: rgba(31, 180, 197, 0.08);
}

.btn-dish-name {
	font-weight: 600;
	line-height: 1.3;
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.btn-dish-price {
	display: inline-block;
	margin-left: 8px;
	padding: 2px 8px;
	background: var(--bg-surface);
	border-radius: 4px;
	font-weight: 700;
	color: var(--accent);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	flex-shrink: 0;
}

.btn-dish-price::after {
	content: ' Frs';
	font-weight: 500;
	color: var(--text-secondary);
}

.order_line td {
	vertical-align: middle !important;
}

/* ---- Print Containers (Invoice & Ticket) ---- */
.print_container {
	width: 80mm;
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	z-index: 2000;
	background: var(--bg-surface);
	border-radius: var(--radius-lg);
	border: var(--separator);
	overflow: hidden;
}

.print_toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 16px;
	background: var(--bg-primary);
	border-bottom: 1px solid var(--border);
	font-weight: 600;
}

.print_body {
	padding: 16px;
	max-height: 70vh;
	overflow-y: auto;
}

#order_invoice .company_copy .ticket_footer,
#order_invoice .customer_copy thead {
	display: none !important;
}

.invoice_row { height: 36px; }
.invoice_header { margin-bottom: 12px; }
.invoice_footer { margin-top: 12px; margin-bottom: 12px; }

.table-ticket {
	width: 100%;
	font-weight: bold;
}

.ticket_quantity {
	white-space: nowrap;
	width: 5%;
}

/* ---- Print: Factures et Tickets (imprimante thermique 80mm) ---- */
@media print {
	/* Quand une facture ou un ticket est affiche, cacher tout le reste */
	body:has(#order_invoice[style*="display: block"]) #page,
	body:has(#order_invoice[style*="display: block"]) .navbar,
	body:has(#order_ticket[style*="display: block"]) #page,
	body:has(#order_ticket[style*="display: block"]) .navbar {
		display: none !important;
	}

	#order_invoice, #order_ticket {
		position: static !important;
		transform: none !important;
		width: 100% !important;
		max-width: 80mm;
		border: none !important;
		margin: 0 !important;
		padding: 0 !important;
		background: #fff !important;
		z-index: auto !important;
	}

	.print_body {
		max-height: none !important;
		overflow: visible !important;
		padding: 8px !important;
	}

	.table-ticket {
		font-family: monospace;
		margin: 0 !important;
	}

	.invoice_header img {
		width: 50mm !important;
	}

}

/* ---- Card View ---- */
.view-toggle {
	background: transparent;
	border: 1px solid var(--border);
	color: var(--text-secondary);
	transition: all var(--transition);
}
.view-toggle.active {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
}
.view-toggle:hover:not(.active) {
	background: rgba(0,0,0,0.04);
	color: var(--text-primary);
}

.cv-toolbar {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 16px;
}
.cv-search {
	max-width: 260px;
}
.cv-info {
	white-space: nowrap;
}

.cv-item {
	cursor: pointer;
}
.cv-card {
	background: var(--bg-surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	overflow: hidden;
	transition: border-color var(--transition), box-shadow var(--transition);
	display: flex;
	flex-direction: column;
	height: 100%;
}
.cv-card:hover {
	border-color: var(--accent);
	box-shadow: 0 4px 16px rgba(31, 180, 197, 0.12);
}
.cv-card--inactive {
	opacity: 0.5;
}
.cv-card-head {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 14px 10px;
	background: var(--bg-primary);
	border-bottom: var(--separator);
}
.cv-card-ico {
	font-size: 1.1rem;
	color: var(--text-secondary);
	flex-shrink: 0;
}
.cv-card-body {
	padding: 10px 14px 8px;
	flex: 1;
}
.cv-card-name {
	font-size: 0.88rem;
	font-weight: 600;
	color: var(--text-primary);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	flex: 1;
	min-width: 0;
}
.cv-card-sub {
	display: block;
	color: var(--text-secondary);
}
.cv-card-foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 6px 14px 10px;
	border-top: var(--separator);
	margin-top: 4px;
}
.cv-card-status {
	display: inline-block;
	width: 8px;
	height: 8px;
	border-radius: 50%;
}
.cv-card-status--active  { background: #2ecc71; }
.cv-card-status--inactive { background: #e74c3c; }

.cv-card-actions {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-left: auto;
	flex-shrink: 0;
	padding-left: 8px;
}
.cv-card-btn-edit,
.cv-card-btn-cancel {
	cursor: pointer;
	color: var(--text-secondary);
	transition: color var(--transition);
	font-size: 0.8rem;
	opacity: 0;
	transition: opacity var(--transition), color var(--transition);
}
.cv-card:hover .cv-card-btn-edit,
.cv-card:hover .cv-card-btn-cancel { opacity: 1; }
.cv-card-btn-edit:hover  { color: var(--accent); }
.cv-card-btn-cancel:hover { color: #e74c3c; }

.cv-card--unpaid {
	border-color: rgba(220, 53, 69, 0.45);
}
.cv-card--unpaid .cv-card-head {
	background: rgba(220, 53, 69, 0.06);
}
.cv-card--unpaid .cv-card-ico {
	color: #dc3545;
}
.cv-card-unpaid-label {
	display: inline-block;
	margin-top: 4px;
	color: #dc3545;
	font-weight: 600;
}

.cv-pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	margin-top: 20px;
	padding-bottom: 8px;
}

/* ---- Kitchen Board ---- */
.kb-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 20px;
}

.kb-header-left {
	display: flex;
	align-items: center;
	gap: 8px;
	color: var(--text-secondary);
}

.kb-count {
	font-weight: 600;
	color: var(--text-secondary);
}

.kb-count span {
	color: var(--accent);
	font-size: 1.4rem;
}

.kb-clock {
	font-size: 1.2rem;
	font-weight: 300;
	color: var(--text-secondary);
	font-variant-numeric: tabular-nums;
}

.kb-empty {
	text-align: center;
	padding: 10vh 0;
	color: var(--text-secondary);
}

.kb-empty .fa-solid { font-size: 3rem; margin-bottom: 12px; opacity: 0.3; }

.kb-card {
	background: var(--bg-surface);
	border-radius: var(--radius-md);
	border: 2px solid var(--border);
	overflow: hidden;
	transition: border-color 0.3s, box-shadow 0.3s;
	margin-bottom: 16px;
}

.kb-card.warning {
	border-color: #e67e22;
	box-shadow: 0 0 8px rgba(230, 126, 34, 0.15);
}

.kb-card.critical {
	border-color: #e74c3c;
	animation: kb-pulse 1s ease-in-out infinite;
}

@keyframes kb-pulse {
	0%, 100% { border-color: #e74c3c; box-shadow: 0 0 6px rgba(231, 76, 60, 0.2); }
	50% { border-color: #ff6b6b; box-shadow: 0 0 16px rgba(231, 76, 60, 0.4); }
}

.kb-card-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 16px;
	background: var(--bg-primary);
	border-bottom: var(--separator);
}

.kb-card-header-left { display: flex; flex-direction: column; gap: 2px; }

.kb-order-number { font-weight: 700; font-size: 0.9rem; color: var(--accent); }
.kb-order-table { font-size: 0.75rem; color: var(--text-secondary); }

.kb-btn-done {
	background: #2ecc71;
	color: #fff;
	border: none;
	border-radius: var(--radius-sm);
	padding: 5px 14px;
	font-weight: 700;
	font-size: 0.8rem;
	cursor: pointer;
	transition: background 0.2s, transform 0.1s;
}

.kb-btn-done:hover { background: #27ae60; }
.kb-btn-done:active { transform: scale(0.95); }

.kb-card-body { padding: 10px 16px; }

.kb-dish { display: flex; align-items: center; padding: 3px 0; }

.kb-dish-qty {
	background: var(--bg-primary);
	border-radius: 6px;
	min-width: 26px; height: 26px;
	display: flex; align-items: center; justify-content: center;
	font-weight: 700; font-size: 0.8rem;
	margin-right: 8px;
	color: var(--accent);
}

.kb-dish-name { font-size: 0.85rem; }

.kb-comment {
	margin-top: 6px;
	padding: 5px 8px;
	background: rgba(230, 126, 34, 0.08);
	border-radius: 6px;
	font-size: 0.75rem;
	color: #e67e22;
	font-style: italic;
}

.kb-card-footer {
	padding: 6px 16px;
	background: var(--bg-primary);
	font-size: 0.75rem;
	color: var(--text-secondary);
}

.kb-timer { font-variant-numeric: tabular-nums; font-weight: 600; }
.kb-card.warning .kb-timer { color: #e67e22; }
.kb-card.critical .kb-timer { color: #e74c3c; }

.kb-card.done {
	animation: kb-card-done 0.5s ease-out forwards;
}

@keyframes kb-card-done {
	0% { opacity: 1; transform: scale(1); }
	50% { opacity: 0.5; border-color: #2ecc71; }
	100% { opacity: 0; transform: scale(0.95); height: 0; padding: 0; margin: 0; overflow: hidden; }
}

/* ---- Order Status Milestones ---- */
.order-milestones {
	display: flex;
	align-items: center;
	width: 100%;
	padding: 0;
	margin: 0;
}

.order-milestones .ms-step {
	display: flex;
	align-items: center;
	gap: 0;
	flex-shrink: 0;
}

.order-milestones .ms-dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--border);
	flex-shrink: 0;
}

.order-milestones .ms-label {
	font-size: .7rem;
	color: var(--text-secondary);
	margin-left: 4px;
	white-space: nowrap;
}

.order-milestones .ms-line {
	flex: 1;
	height: 2px;
	background: var(--border);
}

.order-milestones .ms-step.done .ms-dot {
	background: var(--accent);
}

.order-milestones .ms-step.done .ms-label {
	color: var(--accent);
	font-weight: 600;
}

.order-milestones .ms-step.done + .ms-step .ms-line,
.order-milestones .ms-line.done {
	background: var(--accent);
}

.order-milestones .ms-step.active .ms-dot {
	background: var(--accent);
	box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.2);
}

.order-milestones .ms-step.active .ms-label {
	color: var(--text-primary);
	font-weight: 700;
}

.order-milestones .ms-step.cancelled .ms-dot {
	background: #dc3545;
}

.order-milestones .ms-step.cancelled .ms-label {
	color: #dc3545;
	font-weight: 600;
}

/* ---- Order Status Indicator ---- */
.status-dot {
	display: inline-block;
	width: 12px;
	height: 12px;
	border-radius: 3px;
}

/* ---- Order Status Colors (structure .status-box dans iManage) ---- */
.badge-pending      { background: #f0ad4e; color: #fff; }
.badge-validated    { background: #5bc0de; color: #fff; }
.badge-kitchen      { background: #e67e22; color: #fff; }
.badge-stock        { background: #3498db; color: #fff; }
.badge-production   { background: #8e44ad; color: #fff; }
.badge-prod-done    { background: #27ae60; color: #fff; }
.badge-delivered    { background: #c0392b; color: #fff; }
.badge-cancelled    { background: #dc3545; color: #fff; }


/* ════════════════════════════════════════════════
   Dashboard — extensions Ibora
   (la base .dashboard-v3 est dans iManage)
   ════════════════════════════════════════════════ */
.dashboard-v3 {
    --d-ok:   #27ae60;
    --d-warn: #f0ad4e;
    --d-bad:  #dc3545;
}

/* Extensions spécifiques ibora : gauge, hero-label, KPI header/period, status-grid */
.dashboard-v3 .g-gauge-wrap { flex-shrink: 0; }
.dashboard-v3 .g-gauge      { display: block; }
.dashboard-v3 .g-hero-label {
    font-size: 14px;
    color: var(--d-mute);
    margin: 0 0 4px;
    font-weight: 500;
}

/* Updated-at badge (content-title) */
.g-updated-at {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 4px;
}

/* KPI header (ibora-specific : label + period sur la même ligne) */
.dashboard-v3 .g-kpi-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}
.dashboard-v3 .g-kpi-period {
    font-size: 10px;
    font-weight: 600;
    color: var(--d-mute);
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Status grid — variante ibora (surface blanche avec border, badge rounded) */
.dashboard-v3 .g-status-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.dashboard-v3 .g-status-item {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #ffffff;
    border: 1px solid var(--d-line);
    border-radius: 8px;
}
.dashboard-v3 .g-status-item .badge {
    font-size: 12px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 999px;
    letter-spacing: 0.01em;
}
.dashboard-v3 .g-status-count {
    font-size: 20px;
    font-weight: 700;
    color: var(--d-ink);
    min-width: 20px;
    text-align: right;
}

/* Badges de statut métier — contrastes renforcés */
.badge-libre         { background: #d4edda !important; color: #14532d !important; border: 1px solid #a3d9b1; }
.badge-occupe        { background: #cfe2ff !important; color: #0a3d82 !important; border: 1px solid #a3c4ef; }
.badge-travaux       { background: #ffe5b4 !important; color: #7a3e00 !important; border: 1px solid #f3c07a; }
.badge-indisponible  { background: #e2e3e5 !important; color: #2f3136 !important; border: 1px solid #c0c2c5; }
.badge-actif         { background: #d4edda !important; color: #14532d !important; border: 1px solid #a3d9b1; }
.badge-termine       { background: #e2e3e5 !important; color: #2f3136 !important; border: 1px solid #c0c2c5; }
.badge-resilie       { background: #f8d7da !important; color: #7a1725 !important; border: 1px solid #f0a8ae; }
.badge-impayee       { background: #f8d7da !important; color: #7a1725 !important; border: 1px solid #f0a8ae; }
.badge-partielle     { background: #ffe5b4 !important; color: #7a3e00 !important; border: 1px solid #f3c07a; }
.badge-soldee        { background: #d4edda !important; color: #14532d !important; border: 1px solid #a3d9b1; }

/* ── Feed ───────────────────────────────────────── */
.dashboard-v3 .g-feed {
    list-style: none; padding: 0; margin: 0;
}
.dashboard-v3 .g-feed-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--d-line);
}
.dashboard-v3 .g-feed-item:last-child { border-bottom: none; }
.dashboard-v3 .g-feed-icon {
    width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--d-softer);
    color: var(--d-accent);
    border-radius: 6px;
    font-size: 12px;
    flex-shrink: 0;
}
.dashboard-v3 .g-feed-main { flex: 1; min-width: 0; }
.dashboard-v3 .g-feed-label {
    font-weight: 500; color: var(--d-ink); font-size: 13px;
}

/* ── Snapshot note ──────────────────────────────── */
.dashboard-v3 .g-snapshot-note {
    text-align: right;
    padding-top: 8px; border-top: 1px solid var(--d-line);
}

/* ════════════════════════════════════════════════
   Table style — inspiré MyQMa (.lv-table) appliqué à .sorted_table
   ════════════════════════════════════════════════ */

table.sorted_table {
    --t-ink:    #0f172a;
    --t-mute:   #64748b;
    --t-line:   #e8e8ec;
    --t-soft:   #f8fafc;
    --t-softer: #f1f5f9;

    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    background: var(--bg-surface);
    border-radius: 10px;
    overflow: hidden;
}

/* thead — petits caps, muted */
table.sorted_table thead th {
    padding: 11px 14px !important;
    text-align: left;
    font-size: .72rem !important;
    font-weight: 500 !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--t-mute) !important;
    background: var(--t-soft);
    border-bottom: 1px solid var(--t-line);
    border-top: none;
    white-space: nowrap;
    user-select: none;
}

/* corps */
table.sorted_table tbody td {
    padding: 12px 14px !important;
    border-top: none !important;
    border-bottom: 1px solid var(--t-line);
    vertical-align: middle;
    color: var(--t-ink);
    background: var(--bg-surface) !important;
}

table.sorted_table tbody tr:last-child td {
    border-bottom: 0;
}

/* rangées cliquables (table avec data-detail_link) */
table.sorted_table[data-detail_link] tbody tr[data-record_id] {
    cursor: pointer;
    transition: background .12s ease;
}

table.sorted_table[data-detail_link] tbody tr[data-record_id]:hover {
    background: var(--t-soft);
}

table.sorted_table[data-detail_link] tbody tr[data-record_id]:hover td {
    background: var(--t-soft) !important;
}

/* zébrage désactivé quand on est en mode row-click (single-tone plus propre) */
table.sorted_table.table-striped[data-detail_link] > tbody > tr:nth-of-type(odd) > * {
    background-color: transparent !important;
}

/* icônes update/cancel discrètes en fin de ligne */
table.sorted_table .record_tools {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    margin-left: 8px;
    opacity: 0;
    transition: opacity .15s ease;
}

table.sorted_table tbody tr:hover .record_tools {
    opacity: 1;
}

table.sorted_table .record_tools .update_data,
table.sorted_table .record_tools .cancel_data {
    color: var(--t-mute);
    font-size: 13px;
    padding: 2px 4px;
    border-radius: 4px;
    cursor: pointer;
    transition: color .12s, background .12s;
}

table.sorted_table .record_tools .update_data:hover {
    color: var(--accent);
    background: rgba(192, 57, 43, 0.08);
}

table.sorted_table .record_tools .cancel_data:hover {
    color: #dc3545;
    background: rgba(220, 53, 69, 0.08);
}

/* Strong field locked (record_number) reste coloré mais on perd le soulignement hover
   vu que toute la ligne est cliquable */
table.sorted_table strong.field.locked {
    color: var(--t-ink);
    font-weight: 700;
}

/* override : la classe .detail-link (ajoutée par display_content) ne colore plus le
   record_number en vert puisque toute la ligne est cliquable — garder le contraste */
table.sorted_table strong.detail-link {
    color: var(--t-ink);
    text-decoration: none;
    cursor: pointer;
}

/* Boutons d'action de formulaire — jamais pleine largeur, alignés à gauche */
.form-title-actions {
    gap: 6px;
}
.form-title-actions .btn,
.form-title-actions .btn-group,
.form-title-actions .btn-group > .btn {
    width: auto !important;
    flex: 0 0 auto !important;
    min-width: 0 !important;
}


/* Actions par ligne dans list_view (crayon + poubelle) — visibles au hover de la ligne */
.lv-actions-th { opacity: 0.4; }
.lv-actions-cell { white-space: nowrap; padding: 6px 8px !important; }
.lv-action {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; margin-left: 2px;
    border-radius: 6px; cursor: pointer;
    color: #8a8a8f;
    opacity: 0;
    transition: opacity .15s, background .12s, color .12s;
}
.lv-table tbody tr:hover .lv-action { opacity: 1; }
.lv-action:hover { background: rgba(0,0,0,0.06); }
.lv-action-edit:hover   { color: var(--accent); background: rgba(192, 57, 43, 0.10); }
.lv-action-cancel:hover { color: #dc3545;      background: rgba(220, 53, 69, 0.10); }

/* ── Galerie photos du bien ─────────────────────── */
.bien-gallery { display: flex; gap: 12px; flex-wrap: wrap; }
.bien-photo-main {
    flex: 1 1 320px; max-width: 480px; position: relative;
    border-radius: 10px; overflow: hidden; background: #f5f5f7;
    min-height: 220px; display: flex; align-items: center; justify-content: center;
}
.bien-main-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bien-photo-main .bien-delete-primary {
    position: absolute; top: 8px; right: 8px;
    opacity: 0; transition: opacity .15s;
}
.bien-photo-main:hover .bien-delete-primary { opacity: 1; }
.bien-no-photo { text-align: center; padding: 40px 20px; }

.bien-photo-thumbs {
    flex: 1 1 300px; display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px; align-content: flex-start;
}
.bien-thumb {
    position: relative; aspect-ratio: 1 / 1;
    border-radius: 8px; overflow: hidden; background: #f5f5f7;
    cursor: default;
}
.bien-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bien-thumb-actions {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    background: rgba(0,0,0,0.45);
    opacity: 0; transition: opacity .15s;
}
.bien-thumb:hover .bien-thumb-actions { opacity: 1; }
.bien-thumb-actions .btn { width: 34px; height: 34px; padding: 0; }

.bien-thumb-add {
    aspect-ratio: 1 / 1;
    border: 2px dashed #d0d0d6; border-radius: 8px;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    background: #fafafb;
}
.bien-thumb-add .btn { width: 36px; height: 36px; padding: 0; }

/* ════════════════════════════════════════════════
   Fil d'Ariane + sous-menu contextuel (même barre)
   ════════════════════════════════════════════════ */
#breadcrumb_bar {
    background: #f6f7f9;
    border-bottom: 1px solid #e5e7eb;
    padding: 5px 0;
    font-size: 0.8125rem;
}

/* Breadcrumb (gauche) */
#breadcrumb_bar #breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}
#breadcrumb_bar .bc-item {
    background: none;
    border: none;
    padding: 0;
    color: #6b7280;
    font-size: 0.8125rem;
    cursor: pointer;
    white-space: nowrap;
}
#breadcrumb_bar .bc-item:hover { color: var(--accent); }
#breadcrumb_bar .bc-sep {
    color: #cbd0d6;
    font-size: 0.6rem;
    flex-shrink: 0;
}
#breadcrumb_bar .bc-current {
    color: #1f2937;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sous-menu contextuel (droite) */
#page_submenu {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    justify-content: flex-end;
    flex-shrink: 0;
}
#page_submenu:empty { display: none; }
#page_submenu .btn-link.context-link {
    text-decoration: none;
    font-size: 0.8125rem;
    padding: 3px 10px;
    color: #4b5563;
    border-radius: 4px;
    white-space: nowrap;
}
#page_submenu .btn-link.context-link:hover {
    color: var(--accent);
    background: rgba(255,255,255,0.8);
}
#page_submenu .btn-link.context-link .fa-solid { color: #9ca3af; font-size: 0.75rem; }
#page_submenu .btn-link.context-link:hover .fa-solid { color: var(--accent); }


/* ════════════════════════════════════════════════
   Navigation mobile — barre fixe en bas de l'écran
   Icône en haut · Libellé en bas · < 768 px
   ════════════════════════════════════════════════ */
#mobile_bottom_nav {
    display: none; /* caché par défaut, activé par @media */
}

@media (max-width: 767.98px) {

    /* Masquer la barre de navigation du haut et le footer texte */
    nav.navbar       { display: none !important; }
    #page_footer     { display: none !important; }
    #breadcrumb_bar  { display: none !important; }

    /* Contenu : espace pour la barre du bas */
    #page_content {
        padding-bottom: 72px !important;
    }

    /* ── Barre de navigation du bas ── */
    #mobile_bottom_nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: var(--bg-surface);
        border-top: 1px solid var(--border);
        align-items: stretch;
        z-index: 150;
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
    }

    /* Chaque onglet */
    .mobile-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 6px 4px 4px;
        color: var(--text-secondary);
        text-decoration: none;
        cursor: pointer;
        border: none;
        background: transparent;
        transition: color .15s;
        -webkit-tap-highlight-color: transparent;
        min-width: 0;
    }

    /* Icône */
    .mobile-nav-icon {
        font-size: 19px;
        line-height: 1;
        transition: transform .15s;
    }

    /* Libellé */
    .mobile-nav-label {
        font-size: 9.5px;
        font-weight: 500;
        line-height: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 100%;
    }

    /* État actif */
    .mobile-nav-item.active {
        color: var(--accent);
    }
    .mobile-nav-item.active .mobile-nav-icon {
        transform: translateY(-1px);
    }

    /* Ripple au tap */
    .mobile-nav-item:active { opacity: 0.65; }

    /* Notification bar : légèrement compactée sur mobile */
    #notification_box { height: 44px; }
    #notification_box .notification_main_content { height: 44px; }
}


/* ════════════════════════════════════════════════
   Optimisations par type d'appareil
   Classes ajoutées sur <html> dès le chargement de la page
   (is-phone · is-tablet · is-ios · is-android · is-mobile)
   ════════════════════════════════════════════════ */

/* ── Correction safe-area iPhone X+ (encoche + barre retour) ───────── */
html.is-ios #mobile_bottom_nav {
    /* La hauteur fixe 60px devient hauteur min ; on ajoute l'inset en bas */
    height: auto;
    min-height: 60px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
html.is-ios #mobile_bottom_nav .mobile-nav-item {
    /* Décale le contenu de chaque onglet vers le haut pour compenser l'inset */
    padding-bottom: max(4px, env(safe-area-inset-bottom, 4px));
}
html.is-ios #page_content {
    /* Compense la hauteur augmentée de la nav bas sur iPhone X+ */
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
}

/* ── Cibles tactiles (WCAG 2.5.5 : 44 × 44 px minimum) ─────────────── */
html.is-mobile .agent-hist-btn {
    min-height: 38px;
    padding-top:    8px;
    padding-bottom: 8px;
}
html.is-mobile .mobile-nav-item {
    min-height: 44px;
}

/* ── Titre de section sur téléphone : actions sur ligne séparée ──────── */
html.is-phone .content-title {
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 8px 12px;
}
html.is-phone .content-title .content-title-actions {
    width: 100%;
    margin-left: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;          /* Firefox */
    padding-bottom: 2px;
}
html.is-phone .content-title .content-title-actions::-webkit-scrollbar {
    display: none;
}
/* S'assure que le btn-group ne crée pas de retour à la ligne interne */
html.is-phone .content-title .content-title-actions .btn-group {
    flex-wrap: nowrap;
}

/* ── Tableau de bord agent — cartes KPI sur téléphone ───────────────── */
/* Les 3 cartes (carburant · bâche · électricité) défilent horizontalement
   plutôt que de s'empiler, pour afficher l'essentiel sans scroller. */
@media (max-width: 575.98px) {
    html.is-phone .agent-kpi-row {
        display: flex !important;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 10px;
        padding-bottom: 6px;
        margin-bottom: 8px !important;
    }
    html.is-phone .agent-kpi-row::-webkit-scrollbar { display: none; }
    html.is-phone .agent-kpi-col {
        flex: 0 0 220px !important;
        width: 220px !important;
        max-width: none !important;
    }
}

/* ── Tablette : grille 2 colonnes pour les KPI ──────────────────────── */
@media (min-width: 576px) and (max-width: 767.98px) {
    html.is-tablet .agent-kpi-col {
        flex: 0 0 calc(50% - 6px) !important;
        max-width: calc(50% - 6px) !important;
    }
}

/* ── Formulaires : panneau pleine largeur sans arrondi sur téléphone ─── */
@media (max-width: 575.98px) {
    html.is-phone #form_container .form-panel {
        border-radius: 20px 20px 0 0;
    }
}

/* ── Ajustements texte et espacement sur téléphone ──────────────────── */
html.is-phone #page_content .container {
    padding-left:  12px;
    padding-right: 12px;
}
html.is-phone .content-title {
    font-size: 0.9rem;
    margin-top: 12px;
    margin-bottom: 12px;
}
