/*
 * Alnora date fields: the dd/mm/yyyy box and its calendar (assets/js/alnc-date.js).
 *
 * Shared by the admin and every patient screen, so it reads only the brand variables
 * both define — and on a patient screen those are the clinic's own Customization
 * colors, set on the screen's root. Fallbacks are the stock Alnora palette.
 */
/*
 * No flash of the browser's own date box. In the admin the script is in the <head> and
 * converts each box before the first paint, so this rule normally never gets to act. It
 * is the fallback for a page where the script is held up (a slow or blocked file): the
 * native box keeps its place in the layout but is not drawn, and the swap turns it into
 * a hidden input, so the rule stops matching on its own.
 *
 * Only where scripts are known to run — WordPress puts "js" on the admin <body> before
 * anything is drawn — so with scripts off the ordinary date box is still there. And if
 * the script never arrives at all, the box is shown again after two seconds rather than
 * left blank. (Patient screens draw their date boxes from script, after this one has
 * loaded, so there is nothing there to flash.)
 */
.js .alnc-wrap input[type="date"] {
	visibility: hidden;
	animation: alnc-date-reveal 0s linear 2s forwards;
}
@keyframes alnc-date-reveal { to { visibility: visible; } }

.alnc-date {
	position: relative;
	display: block;
	width: 100%;
	max-width: 100%;
}
.alnc-date > .alnc-date__input {
	width: 100%;
	padding-right: 42px;
	font-variant-numeric: tabular-nums;
}
[dir="rtl"] .alnc-date > .alnc-date__input { padding-right: 12px; padding-left: 42px; }

.alnc-date__btn {
	position: absolute;
	top: 50%;
	right: 6px;
	transform: translateY(-50%);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: var(--alnc-radius-sm, 6px);
	background: transparent;
	color: var(--alnc-text-muted, #6b8287);
	cursor: pointer;
	box-shadow: none;
}
[dir="rtl"] .alnc-date__btn { right: auto; left: 6px; }
.alnc-date__btn:hover,
.alnc-date__btn:focus-visible,
.alnc-date__btn[aria-expanded="true"] {
	color: var(--alnc-teal, #0a4b5c);
	background: var(--alnc-teal-mist, #e6f2f1);
	outline: none;
}
.alnc-date__btn:disabled { opacity: .45; cursor: default; background: transparent; }

.alnc-date__pop {
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	z-index: 100050;
	width: 284px;
	max-width: calc(100vw - 32px);
	box-sizing: border-box;
	padding: 12px;
	background: var(--alnc-bg-card, #fff);
	border: 1px solid var(--alnc-border, #d8e2e0);
	border-radius: var(--alnc-radius-md, 10px);
	box-shadow: 0 14px 34px rgba(8, 40, 48, .16);
	color: var(--alnc-text-body, #1c2a2d);
	font-family: var(--alnc-font, inherit);
	font-size: 14px;
	line-height: 1.2;
}
[dir="rtl"] .alnc-date__pop { left: auto; right: 0; }
.alnc-date__pop *,
.alnc-date__pop *::before,
.alnc-date__pop *::after { box-sizing: border-box; }

.alnc-date__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-bottom: 8px;
}
.alnc-date__title { font-weight: 600; text-align: center; flex: 1; }
.alnc-date__nav {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: var(--alnc-radius-sm, 6px);
	background: transparent;
	color: var(--alnc-text-body, #1c2a2d);
	cursor: pointer;
}
[dir="rtl"] .alnc-date__nav svg { transform: scaleX(-1); }
.alnc-date__nav:hover:not(:disabled),
.alnc-date__nav:focus-visible { background: var(--alnc-bg-page, #f4f6f7); outline: none; }
.alnc-date__nav:disabled { opacity: .3; cursor: default; }

.alnc-date__grid {
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	gap: 2px;
}
.alnc-date__wd {
	padding: 4px 0 6px;
	text-align: center;
	font-size: 12px;
	font-weight: 600;
	color: var(--alnc-text-muted, #6b8287);
}
.alnc-date__day {
	height: 34px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: var(--alnc-radius-sm, 6px);
	background: transparent;
	color: inherit;
	font: inherit;
	font-variant-numeric: tabular-nums;
	cursor: pointer;
}
.alnc-date__day:hover:not(:disabled) { background: var(--alnc-teal-mist, #e6f2f1); }
.alnc-date__day:focus-visible { outline: 2px solid var(--alnc-teal, #0a4b5c); outline-offset: -2px; }
.alnc-date__day.is-today { box-shadow: inset 0 0 0 1px var(--alnc-teal, #0a4b5c); }
.alnc-date__day.is-selected,
.alnc-date__day.is-selected:hover { background: var(--alnc-teal, #0a4b5c); color: #fff; font-weight: 600; }
.alnc-date__day:disabled { opacity: .3; cursor: default; }

/* The admin's filter bars size their controls to the content, not the row. */
.alnc-filter-bar .alnc-date { display: inline-block; width: auto; vertical-align: middle; }
.alnc-filter-bar .alnc-date > .alnc-date__input { width: 160px; }

@media (prefers-reduced-motion: no-preference) {
	.alnc-date__pop { animation: alnc-date-in .12s ease-out; }
	@keyframes alnc-date-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
}
