/*
 * cms-odontogram.css - styles for the dental chart, treatment plan and
 * clinical notes tabs of the Patient detail modal (desktop portals only; the
 * mobile portal does not load this file). Visual language follows the
 * DentaCore reference: plum primary, lavender surfaces, rounded cards.
 */

.cms-pt-tabs {
	padding: 0.5rem 1rem 0;
	border-bottom: 1px solid #e2e8f0;
	background: #fff;
	flex-wrap: nowrap;
	overflow-x: auto;
}

.cms-pt-tabs .nav-link {
	white-space: nowrap;
	color: #475569;
	font-weight: 600;
}

.cms-pt-tabs .nav-link.active {
	color: #800080;
	border-bottom-color: #800080;
}

.cms-pt-tabs .nav-link i {
	margin-right: 0.25rem;
}

.cms-odo {
	--odo-primary: #800080;
	--odo-primary-dark: #5e005e;
	--odo-lav-50: #fcf9fc;
	--odo-lav-100: #f8f2f8;
	--odo-lav-200: #efe3ef;
	--odo-lav-300: #dfc4df;
	--odo-border: #e2e8f0;
	--odo-text: #1e293b;
	--odo-muted: #64748b;
	color: var(--odo-text);
}

.cms-odo-banner {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: 0.75rem;
	margin-bottom: 1rem;
	padding: 0.9rem 1.1rem;
	background: var(--odo-lav-100);
	border: 1px solid var(--odo-lav-300);
	border-radius: 12px;
}

.cms-odo-card {
	background: #fff;
	border: 1px solid var(--odo-border);
	border-radius: 12px;
	box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
}

.cms-odo-card-head,
.cms-odo-toolbar {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: 0.6rem;
	padding: 0.9rem 1.15rem;
	border-bottom: 1px solid var(--odo-border);
}

.cms-odo-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem 0.85rem;
}

.cms-odo-legend-item {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	white-space: nowrap;
}

.cms-odo-abbr {
	padding: 0 0.3rem;
	border-radius: 4px;
	background: var(--odo-lav-100);
	color: var(--odo-primary-dark);
	font-size: 0.68rem;
	font-weight: 700;
}

.cms-odo .condition-swatch {
	display: inline-block;
	width: 14px;
	height: 14px;
	border-radius: 4px;
	border: 1px solid rgba(0, 0, 0, 0.18);
	vertical-align: middle;
}

/* ---- Board ---------------------------------------------------------- */

.cms-odo .odontogram-board {
	margin-bottom: 1rem;
	padding: 1rem;
	background: #fff;
	border: 1px solid var(--odo-lav-300);
	border-radius: 14px;
	overflow-x: auto;
}

.cms-odo-archlabel {
	text-align: center;
	margin: 0.15rem 0 0.5rem;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.03em;
	color: var(--odo-muted);
}

.cms-odo-sep {
	margin: 0.6rem 0;
	border: 0;
	border-top: 1px solid var(--odo-lav-300);
	opacity: 1;
}

.cms-odo .arch-row {
	display: flex;
	justify-content: center;
	gap: 6px;
	min-width: 780px;
}

.cms-odo .quadrant-divider {
	width: 3px;
	margin: 0 6px;
	border-radius: 2px;
	background: var(--odo-primary);
	opacity: 0.35;
}

.cms-odo .tooth-unit {
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 44px;
	padding: 5px 4px 3px;
	border: 2px solid transparent;
	border-radius: 8px;
	background: transparent;
	color: inherit;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.cms-odo .tooth-unit:hover {
	background: var(--odo-lav-100);
}

.cms-odo .tooth-unit:focus-visible {
	outline: 2px solid var(--odo-primary);
	outline-offset: 1px;
}

.cms-odo .tooth-unit.selected {
	border-color: var(--odo-primary);
	background: var(--odo-lav-200);
	box-shadow: 0 2px 8px rgba(128, 0, 128, 0.18);
}

.cms-odo .tooth-num {
	margin-bottom: 2px;
	font-size: 0.72rem;
	font-weight: 700;
	line-height: 1.2;
}

.cms-odo .tooth-svg {
	width: 34px;
	height: 34px;
	display: block;
}

.cms-odo .tooth-surface {
	stroke: #475569;
	stroke-width: 1.4;
	cursor: pointer;
	transition: opacity 0.15s ease;
}

.cms-odo .tooth-surface:hover {
	opacity: 0.78;
}

.cms-odo .tooth-surface.is-target {
	stroke: var(--odo-primary);
	stroke-width: 3;
	paint-order: stroke;
}

/* Text code under each tooth so findings never rely on colour alone. */
.cms-odo .tooth-code {
	min-height: 12px;
	margin-top: 1px;
	font-size: 0.62rem;
	font-weight: 700;
	line-height: 12px;
	color: var(--odo-primary-dark);
	white-space: nowrap;
}

/* ---- Inspector ------------------------------------------------------ */

.cms-odo-inspector {
	padding: 1rem;
	background: #f8f9fa;
	border: 1px solid var(--odo-border);
	border-radius: 12px;
}

.cms-odo-selected {
	padding: 0.5rem 0.75rem;
	background: #fff;
	border: 1px solid var(--odo-border);
	border-radius: 8px;
	font-weight: 700;
	color: var(--odo-primary);
}

.cms-odo .surface-btn {
	min-height: 32px;
	padding: 0 0.75rem;
	border: 1px solid var(--odo-border);
	border-radius: 8px;
	background: #fff;
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--odo-text);
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.cms-odo .surface-btn:hover:not(:disabled) {
	border-color: var(--odo-lav-300);
	background: var(--odo-lav-100);
}

.cms-odo .surface-btn.active {
	background: var(--odo-primary);
	border-color: var(--odo-primary);
	color: #fff;
}

.cms-odo .surface-btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.cms-odo .surface-btn:focus-visible {
	outline: 2px solid var(--odo-primary);
	outline-offset: 2px;
}

.cms-odo-chip {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.25rem 0.35rem 0.25rem 0.55rem;
	background: #fff;
	border: 1px solid var(--odo-border);
	border-left: 4px solid var(--odo-chip, var(--odo-primary));
	border-radius: 8px;
	font-size: 0.8rem;
	font-weight: 600;
}

.cms-odo-chip-x {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--odo-muted);
	cursor: pointer;
}

.cms-odo-chip-x:hover {
	background: #fdecee;
	color: #b02a37;
}

.cms-odo-chip-x:focus-visible {
	outline: 2px solid var(--odo-primary);
}

/* ---- Activity / plan / notes --------------------------------------- */

.cms-odo-history {
	max-height: 220px;
	overflow-y: auto;
	font-size: 0.85rem;
}

.cms-odo-history-row {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 0.25rem 1rem;
	padding: 0.45rem 0;
	border-bottom: 1px solid #f1f5f9;
}

.cms-odo-history-row:last-child {
	border-bottom: 0;
}

.cms-odo-history-row .text-muted {
	font-size: 0.78rem;
}

.cms-plan-declined td {
	opacity: 0.6;
}

.cms-plan-editing td {
	background: var(--odo-lav-50);
}

.cms-odo-totals {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: 0.75rem;
	padding: 1rem 1.15rem;
	background: var(--odo-lav-100);
	border: 1px solid var(--odo-lav-300);
	border-radius: 12px;
}

.cms-odo-totals-split {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem 1.25rem;
	color: var(--odo-muted);
}

.cms-odo-totals-split strong {
	color: var(--odo-text);
}

.cms-note {
	margin-bottom: 0.75rem;
	padding: 0.9rem 1rem;
	background: #fff;
	border: 1px solid var(--odo-border);
	border-left: 4px solid var(--odo-primary);
	border-radius: 10px;
}

.cms-note:last-child {
	margin-bottom: 0;
}

.cms-note header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25rem 0.75rem;
	margin-bottom: 0.5rem;
}

.cms-note-label {
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	color: var(--odo-primary);
}

.cms-note-section + .cms-note-section {
	margin-top: 0.5rem;
}

.cms-note-text {
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	font-size: 0.88rem;
}

.cms-print-frame {
	position: fixed;
	right: 0;
	bottom: 0;
	width: 0;
	height: 0;
	border: 0;
	visibility: hidden;
}

/* Below the xl breakpoint the modal is narrower (800px), so teeth get a
   little smaller and all 16 of an arch fit without sideways scrolling. */
@media (max-width: 1199.98px) {
	.cms-odo .odontogram-board {
		padding: 0.75rem 0.5rem;
	}

	.cms-odo .arch-row {
		min-width: 0;
		gap: 2px;
	}

	.cms-odo .quadrant-divider {
		margin: 0 3px;
	}

	.cms-odo .tooth-unit {
		width: 38px;
		padding: 4px 2px 2px;
	}

	.cms-odo .tooth-svg {
		width: 30px;
		height: 30px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cms-odo .tooth-unit,
	.cms-odo .tooth-surface,
	.cms-odo .surface-btn {
		transition: none;
	}
}

/* The theme forces nowrap on every table cell; plan rows contain long
   procedure names and an action column, so let them wrap inside the modal. */
.cms-odo .table > :not(caption) > * > * {
	white-space: normal;
}

.cms-odo .table td:last-child,
.cms-odo .table th:last-child {
	white-space: nowrap;
}

