/**
 * OpenStay — front-end styles.
 *
 * "Compact list-forward" design: cream card, occupied days painted as full
 * colored tiles (teal = reservation, terracotta = blocked), olive circle on
 * today, compact dot-list below. Reservation vs. unavailable are distinguished
 * by colour AND a lock icon, never by colour alone (accessibility).
 */

.openstay {
	--os-cream: #f6efe2;
	--os-panel: #ffffff;
	--os-teal: #17858c;
	--os-terracotta: #b85a33;
	--os-terracotta-dark: #a54c28;
	--os-today: #4a4237;
	--os-today-dark: #332d24;

	/* Per-type colors are configured in settings and applied inline (per tile
	   and per list dot) by openstay.js, since the type list is dynamic. */
	--os-ink: #2a2723;
	--os-muted: #8a8378;
	--os-border: #e7dfd0;
	--os-error: #b91c1c;
	--os-ok: #15803d;

	max-width: 980px;
	margin: 0 auto;
	padding: 1.5em;
	background: var(--os-cream);
	border-radius: 18px;
	color: var(--os-ink);
	box-sizing: border-box;
}

.openstay *,
.openstay *::before,
.openstay *::after {
	box-sizing: border-box;
}

/* --- Header -------------------------------------------------------------- */

.openstay__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 1em;
	margin: 0 0 1em;
}

.openstay__title {
	margin: 0;
	font-family: Georgia, "Times New Roman", serif;
	font-size: 1.6rem;
	font-weight: 600;
	color: var(--os-ink);
}

.openstay__subtitle {
	margin: 0.15em 0 0;
	font-size: 0.85rem;
	color: var(--os-muted);
}

/* --- Messages -------------------------------------------------------------- */

/* Kept in the DOM at all times as an aria-live region, but collapsed while
   empty. Spacing is applied only once a message (--ok/--error) is shown. */
.openstay__messages {
	font-weight: 600;
	font-size: 0.9rem;
}

.openstay__messages--error,
.openstay__messages--ok {
	min-height: 1.4em;
	margin: 0 0 0.5em;
}

.openstay__messages--error {
	color: var(--os-error);
}

.openstay__messages--ok {
	color: var(--os-ok);
}

/* --- Buttons ---------------------------------------------------------------- */

.openstay__btn {
	display: inline-block;
	padding: 0.55em 1.1em;
	border: 1px solid var(--os-border);
	border-radius: 10px;
	background: #fff;
	color: var(--os-ink);
	font: inherit;
	font-size: 0.95rem;
	cursor: pointer;
}

.openstay__btn:hover,
.openstay__btn:focus-visible {
	border-color: #c9bfa9;
}

.openstay__btn--primary {
	background: var(--os-terracotta);
	border-color: var(--os-terracotta);
	color: #fff;
	font-weight: 600;
}

.openstay__btn--primary:hover,
.openstay__btn--primary:focus-visible {
	background: var(--os-terracotta-dark);
	border-color: var(--os-terracotta-dark);
}

.openstay__btn--add {
	border-radius: 999px;
	white-space: nowrap;
}

.openstay__btn--danger {
	background: #fff;
	border-color: var(--os-error);
	color: var(--os-error);
}

/* The `hidden` attribute must win over the button's own display rule
   (e.g. the Delete button is hidden when creating a new entry). */
.openstay__btn[hidden] {
	display: none;
}

/* --- Calendar panel ---------------------------------------------------------- */

.openstay__panel {
	background: var(--os-panel);
	border-radius: 14px;
	padding: 1em 1em 1.25em;
	margin: 0 0 1.5em;
}

/* FullCalendar: strip the grid chrome (no borders anywhere). */
.openstay .fc-theme-standard .fc-scrollgrid,
.openstay .fc-theme-standard td,
.openstay .fc-theme-standard th {
	border: 0;
}

.openstay .fc .fc-toolbar.fc-header-toolbar {
	margin-bottom: 0.75em;
}

.openstay .fc .fc-toolbar-title {
	font-size: 1.05rem;
	font-weight: 700;
	color: var(--os-ink);
}

/* prev / next: small rounded outline buttons. */
.openstay .fc .fc-button {
	background: #fff;
	border: 1px solid var(--os-border);
	color: var(--os-ink);
	border-radius: 9px;
	padding: 0.3em 0.7em;
	font-size: 0.85rem;
	box-shadow: none;
}

.openstay .fc .fc-button:hover,
.openstay .fc .fc-button:focus {
	background: #faf7f0;
	border-color: #c9bfa9;
	color: var(--os-ink);
	box-shadow: none;
}

.openstay .fc .fc-button:disabled {
	background: transparent;
	border-color: transparent;
	color: var(--os-muted);
}

/* "today": solid pill button matching the today circle colour. */
.openstay .fc .fc-today-button {
	background: var(--os-today);
	border: 1px solid var(--os-today);
	color: #fff;
	font-weight: 700;
	text-transform: none;
	border-radius: 999px;
	padding: 0.4em 1em;
	margin-left: 0.5em;
}

.openstay .fc .fc-today-button:hover,
.openstay .fc .fc-today-button:focus {
	background: var(--os-today-dark);
	border-color: var(--os-today-dark);
	color: #fff;
}

.openstay .fc .fc-today-button:disabled {
	background: var(--os-today);
	border-color: var(--os-today);
	color: #fff;
	opacity: 0.45;
}

/* Month / Year view switcher: pill group, active segment filled. */
.openstay .fc .fc-dayGridMonth-button,
.openstay .fc .fc-multiMonthYear-button {
	text-transform: none;
	font-weight: 600;
}

.openstay .fc .fc-button-primary.fc-button-active {
	background: var(--os-today);
	border-color: var(--os-today);
	color: #fff;
}

.openstay .fc .fc-button-primary.fc-button-active:hover,
.openstay .fc .fc-button-primary.fc-button-active:focus {
	background: var(--os-today-dark);
	border-color: var(--os-today-dark);
	color: #fff;
}

/* Weekday header: single narrow letters, muted. */
.openstay .fc .fc-col-header-cell-cushion {
	padding: 0.6em 0;
	font-size: 0.75rem;
	font-weight: 700;
	color: var(--os-muted);
	text-decoration: none;
	text-transform: uppercase;
}

/* Reset host-theme table-cell padding (e.g. Divi's global `td { padding: 6px
   24px }`). Without this the cell content box collapses to a few px wide, so
   the painted pills shrink to thin capsules in month view and vanish entirely
   in the compact year view. */
.openstay .fc table td,
.openstay .fc table th {
	padding: 0;
}

/* Day cells: centered numbers, generous height, no default event area. */
.openstay .fc .fc-daygrid-day-frame {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 74px;
}

/* Year view: compact months. Force every grid edge off so a host theme's
   default table/cell borders can't leak in (FullCalendar's border-style:hidden
   rules otherwise cancel only some edges, leaving stray top/left lines). */
.openstay .fc .fc-multimonth,
.openstay .fc .fc-multimonth-month,
.openstay .fc .fc-multimonth-header-table,
.openstay .fc .fc-multimonth-daygrid-table,
.openstay .fc .fc-multimonth-header-table th,
.openstay .fc .fc-multimonth-daygrid-table td {
	border: 0 !important;
}

.openstay .fc .fc-multimonth-title {
	font-weight: 700;
	color: var(--os-ink);
	text-transform: capitalize;
}

/* No gray filler on leading/trailing out-of-month cells. */
.openstay .fc .fc-day-disabled {
	background: transparent;
}

.openstay .fc .fc-multimonth .fc-daygrid-day-frame {
	min-height: 34px;
}

.openstay .fc .fc-multimonth .fc-daygrid-day-number {
	font-size: 0.8rem;
}

.openstay .fc .fc-multimonth .openstay__paint {
	inset: 1px;
	border-radius: 6px;
}

.openstay .fc .fc-multimonth .fc-day-today .fc-daygrid-day-number {
	width: 26px;
	height: 26px;
}

.openstay .fc .fc-daygrid-day-top {
	position: relative;
	z-index: 2;
	flex-direction: row;
}

.openstay .fc .fc-daygrid-day-number {
	padding: 0;
	font-size: 0.95rem;
	font-weight: 600;
	color: var(--os-ink);
	text-decoration: none;
}

.openstay .fc .fc-day-other .fc-daygrid-day-number {
	color: #c8c1b4;
}

.openstay .fc .fc-daygrid-day-events,
.openstay .fc .fc-daygrid-day-bottom {
	display: none;
}

/* Kill FullCalendar's default yellow "today" background. */
.openstay .fc .fc-day-today {
	background: transparent;
}

/* Today: filled circle behind the number, same colour as the today button. */
.openstay .fc .fc-day-today .fc-daygrid-day-number {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	border-radius: 50%;
	background: var(--os-today);
	color: #fff;
}

/* Painted occupied tiles. Background color is set inline per type in JS. */
.openstay__paint {
	position: absolute;
	inset: 3px;
	z-index: 1;
	border-radius: 10px;
	background: var(--os-muted);
}

/* Turnover days: the tile is split along the diagonal (top-right ↔ bottom-left).
   The departing stay takes the top-left half, the arriving stay the bottom-right
   half. A checkout day with no same-day arrival shows only its departing half. */
.openstay__paint--depart {
	clip-path: polygon( 0 0, 100% 0, 0 100% );
}

.openstay__paint--arrive {
	clip-path: polygon( 100% 0, 100% 100%, 0 100% );
}

/* Booked days: white number for contrast against the painted tile. Needs the
   `.openstay .fc` prefix to outrank `.openstay .fc .fc-daygrid-day-number`. */
.openstay .fc .openstay__day--occupied .fc-daygrid-day-number {
	color: #fff;
}

.openstay__day--occupied .fc-daygrid-day-frame {
	cursor: pointer;
}

/* Selection highlight while drag-creating. */
.openstay .fc .fc-highlight {
	background: rgba( 23, 133, 140, 0.25 );
	border-radius: 10px;
}

/* --- List -------------------------------------------------------------------- */

.openstay__list-section {
	margin: 0;
}

.openstay__list-title {
	margin: 0 0 0.6em;
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--os-muted);
}

/* `.openstay` scope + !important to beat host-theme list defaults (e.g. Divi's
   content `ul { padding: 0 0 23px 1em }`). */
.openstay .openstay__list {
	list-style: none;
	margin: 0;
	padding: 0 !important;
}

.openstay__item {
	display: flex;
	align-items: center;
	gap: 0.6em;
	padding: 0.75em 1em;
	margin: 0 0 0.5em;
	background: var(--os-panel);
	border-radius: 10px;
}

.openstay__item--empty {
	color: var(--os-muted);
}

.openstay__dot {
	flex: 0 0 auto;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--os-muted);
}

.openstay__item-label {
	font-weight: 700;
}

.openstay__item-dates {
	margin-left: auto;
	color: #6f6a60;
	font-size: 0.92rem;
	white-space: nowrap;
}

/* Admin rows: name, type, contact details and dates all on one line
   (wrapping only when the row genuinely runs out of width). */
.openstay__item--admin {
	flex-wrap: wrap;
}

/* Admin: the name is a button that opens the edit popup.
   Hard overrides on every state: themes commonly restyle button:hover /
   :focus / :active (dark background, borders, shadows) and that must never
   leak into this text-looking control. */
.openstay .openstay__item-label--edit,
.openstay .openstay__item-label--edit:hover,
.openstay .openstay__item-label--edit:focus,
.openstay .openstay__item-label--edit:active {
	background: transparent !important;
	border: 0 !important;
	box-shadow: none !important;
	outline: none;
	padding: 0 !important;
	margin: 0;
	font: inherit;
	font-weight: 700;
	color: var(--os-ink) !important;
	text-align: left;
	text-decoration: none;
	cursor: pointer;
}

.openstay .openstay__item-label--edit:hover,
.openstay .openstay__item-label--edit:focus-visible {
	color: var(--os-teal) !important;
	text-decoration: underline;
}

/* Keep a visible keyboard-focus indicator despite the outline reset. */
.openstay .openstay__item-label--edit:focus-visible {
	outline: 2px solid var(--os-teal);
	outline-offset: 2px;
}

.openstay__item-type {
	flex: 0 0 auto;
	padding: 0.1em 0.6em;
	border: 1px solid var(--os-border);
	border-radius: 999px;
	font-size: 0.78rem;
	color: var(--os-muted);
	white-space: nowrap;
}

/* Inline details (admin only): email, phone, times, note. Sits between the
   type badge and the right-aligned dates, on the same line. */
.openstay__item-meta {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25em 1.25em;
	color: #6f6a60;
	font-size: 0.88rem;
}

.openstay__item-contact,
.openstay__item-contact:visited {
	color: var(--os-teal);
	text-decoration: none;
}

.openstay__item-contact:hover,
.openstay__item-contact:focus-visible {
	text-decoration: underline;
}

/* --- Modal --------------------------------------------------------------------- */

.openstay__modal {
	position: fixed;
	inset: 0;
	/* Above Divi's fixed header (et_fixed_header sits around 99999). */
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1em;

	/* The modal is portaled to <body> (see openstay.js), so it lives outside
	   the `.openstay` token scope. Redeclare the design tokens it uses so the
	   buttons, borders and text keep their colors. */
	--os-panel: #ffffff;
	--os-terracotta: #b85a33;
	--os-terracotta-dark: #a54c28;
	--os-ink: #2a2723;
	--os-muted: #8a8378;
	--os-border: #e7dfd0;
	--os-error: #b91c1c;
	--os-ok: #15803d;
}

/* Restore the border-box reset the modal lost by leaving `.openstay *`, so
   full-width inputs don't overflow the dialog. */
.openstay__modal,
.openstay__modal *,
.openstay__modal *::before,
.openstay__modal *::after {
	box-sizing: border-box;
}

.openstay__modal[hidden] {
	display: none;
}

.openstay__modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba( 42, 39, 35, 0.5 );
}

.openstay__modal-dialog {
	position: relative;
	z-index: 1;
	width: 100%;
	max-width: 440px;
	max-height: 90vh;
	overflow-y: auto;
	padding: 1.25em;
	background: #fff;
	border-radius: 14px;
	box-shadow: 0 10px 40px rgba( 0, 0, 0, 0.25 );
}

.openstay__modal-title {
	margin-top: 0;
	font-family: Georgia, "Times New Roman", serif;
}

.openstay__field {
	display: flex;
	flex-direction: column;
	gap: 0.25em;
	margin: 0 0 0.9em;
}

.openstay__field label {
	font-weight: 600;
}

.openstay__field input,
.openstay__field select,
.openstay__field textarea {
	width: 100%;
	padding: 0.5em;
	border: 1px solid var(--os-border);
	border-radius: 8px;
	font: inherit;
}

.openstay__hint {
	font-size: 0.85em;
	color: var(--os-muted);
}

/* Icon + label line above the email / phone inputs. */
.openstay__field-label {
	display: flex;
	align-items: center;
	gap: 0.45em;
}

/* Envelope / handset icon linking to mailto: / tel:. */
.openstay__contact-link {
	display: inline-flex;
	align-items: center;
	color: var(--os-teal);
	line-height: 1;
}

.openstay__contact-link:hover,
.openstay__contact-link:focus-visible {
	color: var(--os-today);
}

.openstay__contact-link[hidden] {
	display: none;
}

/* Date + optional time on one line. */
.openstay__datetime {
	display: flex;
	gap: 0.5em;
}

.openstay__datetime input {
	width: auto;
}

.openstay__datetime input[type="date"] {
	flex: 1 1 auto;
	min-width: 0;
}

.openstay__datetime input[type="time"] {
	flex: 0 0 auto;
}

.openstay__modal-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5em;
	margin-top: 1em;
}

/* --- Admin hover tooltip --------------------------------------------------------- */

.openstay__tooltip {
	position: fixed;
	z-index: 100001;
	max-width: 280px;
	padding: 0.6em 0.75em;
	background: var(--os-ink);
	color: #fff;
	border-radius: 8px;
	font-size: 0.85rem;
	line-height: 1.35;
	box-shadow: 0 6px 20px rgba( 0, 0, 0, 0.3 );
	pointer-events: none;
}

.openstay__tooltip[hidden] {
	display: none;
}

.openstay__tip-row {
	display: flex;
	gap: 0.5em;
}

.openstay__tip-row + .openstay__tip-row {
	margin-top: 0.2em;
}

.openstay__tip-label {
	flex: 0 0 auto;
	font-weight: 700;
	opacity: 0.7;
}

.openstay__tip-val {
	word-break: break-word;
}

body.openstay-modal-open {
	overflow: hidden;
}

/* --- Responsive ------------------------------------------------------------------ */

@media ( max-width: 600px ) {
	.openstay {
		padding: 1em;
		border-radius: 12px;
	}

	.openstay .fc .fc-daygrid-day-frame {
		min-height: 52px;
	}

	.openstay .fc .fc-day-today .fc-daygrid-day-number {
		width: 38px;
		height: 38px;
	}

	/* Year view: stack months on small screens. */
	.openstay .fc .fc-multimonth-multicol .fc-multimonth-month {
		width: 100% !important;
	}

	.openstay__item {
		flex-wrap: wrap;
	}

	.openstay__item-dates {
		flex-basis: 100%;
		margin-left: 1.35em;
	}

	.openstay__modal-dialog {
		max-width: 100%;
	}
}
