/* ==========================================================================
   AIUG Vibe WP — Frontend Calendar Styles  v1.0.0
   All selectors scoped to .aiug- prefix — zero theme conflict.
   CSS custom properties scoped per calendar instance via injected <style>.
   ========================================================================== */

/* ── Custom Properties (defaults) ──────────────────────────────────────── */
.aiug-calendar-wrap {
	--aiug-accent:       #3B82F6;
	--aiug-accent-light: color-mix(in srgb, var(--aiug-accent) 12%, transparent);
	--aiug-accent-mid:   color-mix(in srgb, var(--aiug-accent) 25%, transparent);
	--aiug-text:         #111827;
	--aiug-text-muted:   #6B7280;
	--aiug-border:       #E5E7EB;
	--aiug-bg:           #FFFFFF;
	--aiug-bg-alt:       #F9FAFB;
	--aiug-radius:       8px;
	--aiug-shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
	--aiug-shadow-lg:    0 10px 40px rgba(0,0,0,.18);
	--aiug-font:         -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	--aiug-hour-h:       60px;

	font-family: var(--aiug-font);
	color: var(--aiug-text);
	background: var(--aiug-bg);
	border: 1px solid var(--aiug-border);
	border-radius: var(--aiug-radius);
	box-shadow: var(--aiug-shadow);
	overflow: hidden;
	position: relative;
	width: 100%;       /* fill whatever container the shortcode is placed in */
	box-sizing: border-box;
}

/* Browsers that don't support color-mix: fall back to opacity */
@supports not (color: color-mix(in srgb, red 10%, transparent)) {
	.aiug-calendar-wrap {
		--aiug-accent-light: rgba(59,130,246,.12);
		--aiug-accent-mid:   rgba(59,130,246,.25);
	}
}

/* ── Reset inside wrapper ───────────────────────────────────────────────── */
.aiug-calendar-wrap *,
.aiug-calendar-wrap *::before,
.aiug-calendar-wrap *::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

.aiug-calendar-wrap button {
	font-family: inherit;
	cursor: pointer;
	background: none;
	border: none;
}

/* ── Toolbar ────────────────────────────────────────────────────────────── */
.aiug-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 16px;
	border-bottom: 1px solid var(--aiug-border);
	background: var(--aiug-bg);
	gap: 8px;
	flex-wrap: wrap;
}

.aiug-toolbar__nav {
	display: flex;
	align-items: center;
	gap: 6px;
}

.aiug-toolbar__period {
	font-size: 1rem;
	font-weight: 600;
	min-width: 160px;
	text-align: center;
	white-space: nowrap;
}

.aiug-toolbar__right {
	display: flex;
	align-items: center;
	gap: 8px;
}

/* Nav arrow buttons */
.aiug-btn--nav {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 6px;
	color: var(--aiug-text);
	transition: background .15s, color .15s;
}

.aiug-btn--nav:hover {
	background: var(--aiug-accent-light);
	color: var(--aiug-accent);
}

/* Today button */
.aiug-btn--today {
	padding: 5px 12px;
	font-size: .85rem;
	font-weight: 500;
	border: 1px solid var(--aiug-border);
	border-radius: 6px;
	color: var(--aiug-text);
	transition: background .15s, border-color .15s, color .15s;
}

.aiug-btn--today:hover {
	background: var(--aiug-accent-light);
	border-color: var(--aiug-accent);
	color: var(--aiug-accent);
}

/* View select */
.aiug-view-select {
	padding: 5px 10px;
	font-size: .85rem;
	font-family: inherit;
	border: 1px solid var(--aiug-border);
	border-radius: 6px;
	background: var(--aiug-bg);
	color: var(--aiug-text);
	cursor: pointer;
	transition: border-color .15s;
}

.aiug-view-select:focus {
	outline: 2px solid var(--aiug-accent);
	outline-offset: 1px;
}

/* ── Loading / Error States ─────────────────────────────────────────────── */
.aiug-loading,
.aiug-error {
	padding: 40px;
	text-align: center;
	color: var(--aiug-text-muted);
	font-size: .9rem;
}

.aiug-error {
	color: #DC2626;
}

/* ── Event chips (shared: month + all-day rows) ─────────────────────────── */
.aiug-event-chip {
	display: block;
	padding: 2px 6px;
	margin: 1px 2px;
	border-radius: 4px;
	font-size: .75rem;
	font-weight: 500;
	line-height: 1.4;
	/* Allow full title to wrap across multiple lines — no truncation */
	white-space: normal;
	word-break: break-word;
	overflow: visible;
	background: var(--aiug-accent);
	color: #fff;
	cursor: pointer;
	transition: filter .15s, transform .1s;
}

.aiug-event-chip:hover {
	filter: brightness(1.12);
	transform: translateY(-1px);
}

/* Multi-day chip variants */
.aiug-event-chip--multi {
	border-radius: 0;
	margin: 1px 0;
}

.aiug-event-chip--start {
	border-radius: 4px 0 0 4px;
	margin-left: 2px;
}

.aiug-event-chip--end {
	border-radius: 0 4px 4px 0;
	margin-right: 2px;
}

.aiug-more-events {
	font-size: .7rem;
	color: var(--aiug-text-muted);
	padding: 1px 4px;
	cursor: pointer;
}

.aiug-more-events:hover {
	color: var(--aiug-accent);
}

/* ── MONTH VIEW ─────────────────────────────────────────────────────────── */
.aiug-month-grid {
	display: grid;
	grid-template-columns: repeat(7, 1fr);
}

/* Day-name headers */
.aiug-month-header-cell {
	padding: 8px 4px;
	text-align: center;
	font-size: .75rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .04em;
	color: var(--aiug-text-muted);
	border-bottom: 1px solid var(--aiug-border);
	border-right: 1px solid var(--aiug-border);
	background: var(--aiug-bg-alt);
	/* Prevent content from expanding the column beyond its 1fr share */
	min-width: 0;
	overflow: hidden;
}

.aiug-month-header-cell:last-child {
	border-right: none;
}

/* Day cells */
.aiug-month-cell {
	min-height: 90px;
	padding: 4px 2px 4px;
	border-right: 1px solid var(--aiug-border);
	border-bottom: 1px solid var(--aiug-border);
	vertical-align: top;
	/* Fixed columns: content must not push the cell wider than its 1fr share */
	min-width: 0;
	overflow: hidden;
}

.aiug-month-cell:nth-child(7n) {
	border-right: none;
}

/* Last row: hide bottom border */
.aiug-month-cell:nth-last-child(-n+7) {
	border-bottom: none;
}

.aiug-month-cell--other {
	background: var(--aiug-bg-alt);
}

.aiug-month-cell--other .aiug-month-cell__number {
	color: #C9CDD4;
}

.aiug-month-cell--today {
	background: var(--aiug-accent-light);
}

.aiug-month-cell__number {
	font-size: .8rem;
	font-weight: 500;
	text-align: right;
	padding: 2px 6px 4px;
	color: var(--aiug-text-muted);
	line-height: 1;
}

.aiug-month-cell--today .aiug-month-cell__number {
	color: var(--aiug-accent);
	font-weight: 700;
}

.aiug-month-cell__events {
	overflow: hidden;
}

/* ── WEEK & DAY VIEW ────────────────────────────────────────────────────── */
.aiug-week-view,
.aiug-day-view {
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

/* Column header row */
.aiug-week-header {
	display: grid;
	grid-template-columns: 52px repeat(7, 1fr);
	border-bottom: 1px solid var(--aiug-border);
	background: var(--aiug-bg-alt);
}

.aiug-week-gutter {
	width: 52px;
	flex-shrink: 0;
	border-right: 1px solid var(--aiug-border);
}

.aiug-week-header-cell {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 8px 4px;
	border-right: 1px solid var(--aiug-border);
	text-align: center;
}

.aiug-week-header-cell:last-child {
	border-right: none;
}

.aiug-week-header-cell--today {
	background: var(--aiug-accent-light);
}

.aiug-week-day-name {
	font-size: .7rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .04em;
	color: var(--aiug-text-muted);
}

.aiug-week-day-num {
	font-size: 1.1rem;
	font-weight: 600;
	line-height: 1.6;
	color: var(--aiug-text);
}

.aiug-today-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: var(--aiug-accent);
	color: #fff !important;
	font-weight: 700;
}

/* All-day row */
.aiug-allday-row {
	display: flex;
	border-bottom: 1px solid var(--aiug-border);
	background: var(--aiug-bg-alt);
	min-height: 28px;
}

.aiug-allday-label {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	padding-right: 8px;
	font-size: .7rem;
	color: var(--aiug-text-muted);
}

.aiug-allday-cell {
	flex: 1;
	padding: 2px 2px;
	border-right: 1px solid var(--aiug-border);
}

.aiug-allday-cell:last-child {
	border-right: none;
}

/* Scrollable time grid */
.aiug-time-grid {
	position: relative;
	overflow-y: auto;
	max-height: 520px;
	flex: 1;
}

.aiug-time-inner {
	position: relative;
	/* height set inline via JS: HOURS * HOUR_HEIGHT */
}

.aiug-hour-line {
	position: absolute;
	left: 0;
	right: 0;
	height: 1px;
	background: var(--aiug-border);
	display: flex;
	align-items: flex-start;
	pointer-events: none;
}

.aiug-hour-label {
	display: block;
	width: 48px;
	font-size: .68rem;
	color: var(--aiug-text-muted);
	padding-right: 6px;
	text-align: right;
	margin-top: -9px;
	background: var(--aiug-bg);
	line-height: 1;
}

/* Day columns inside the time grid */
.aiug-day-columns {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 52px;
	right: 0;
	display: flex;
}

.aiug-day-columns--single {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 52px;
	right: 0;
}

.aiug-day-column {
	flex: 1;
	position: relative;
	border-right: 1px solid var(--aiug-border);
	min-height: 100%;
}

.aiug-day-column:last-child {
	border-right: none;
}

.aiug-day-column--today {
	background: var(--aiug-accent-light);
}

/* Timed event block */
.aiug-timed-event {
	position: absolute;
	left: 2px;
	right: 2px;
	background: var(--aiug-accent);
	color: #fff;
	border-radius: 4px;
	padding: 3px 5px;
	font-size: .72rem;
	overflow: hidden;
	cursor: pointer;
	transition: filter .15s, transform .1s;
	z-index: 1;
}

.aiug-timed-event:hover {
	filter: brightness(1.12);
	transform: scale(1.01);
	z-index: 2;
}

.aiug-timed-event__time {
	display: block;
	font-size: .65rem;
	opacity: .85;
	font-weight: 600;
}

.aiug-timed-event__title {
	display: block;
	font-weight: 500;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Day view header */
.aiug-day-header {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 16px;
	border-bottom: 1px solid var(--aiug-border);
	background: var(--aiug-bg-alt);
}

.aiug-day-header--today {
	background: var(--aiug-accent-light);
}

.aiug-day-header .aiug-week-day-name {
	font-size: .9rem;
	text-transform: uppercase;
	letter-spacing: .04em;
}

/* Day number badge in day view — contains only the digit, not the full date */
.aiug-day-header .aiug-week-day-num {
	font-size: 1.4rem;
}

/* Month + year text shown alongside the day number badge */
.aiug-day-header__monthyear {
	font-size: 1rem;
	font-weight: 600;
	color: var(--aiug-text);
}

/* ── YEAR VIEW ──────────────────────────────────────────────────────────── */
.aiug-year-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 1px;
	background: var(--aiug-border);
}

@media (min-width: 640px) {
	.aiug-year-grid {
		grid-template-columns: repeat(3, 1fr);
	}
}

@media (min-width: 1024px) {
	.aiug-year-grid {
		grid-template-columns: repeat(4, 1fr);
	}
}

.aiug-mini-month {
	background: var(--aiug-bg);
	padding: 12px 10px;
}

.aiug-mini-month__name {
	font-size: .8rem;
	font-weight: 700;
	text-align: center;
	margin-bottom: 8px;
	color: var(--aiug-text);
}

.aiug-mini-month__grid {
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	gap: 1px;
}

.aiug-mini-header {
	font-size: .6rem;
	text-align: center;
	color: var(--aiug-text-muted);
	font-weight: 600;
	padding-bottom: 3px;
}

.aiug-mini-day {
	aspect-ratio: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: .65rem;
	border-radius: 3px;
	cursor: pointer;
	transition: background .12s;
	color: var(--aiug-text);
}

.aiug-mini-day:hover {
	background: var(--aiug-accent-light);
}

.aiug-mini-day--empty {
	cursor: default;
	background: none !important;
}

.aiug-mini-day--today {
	background: var(--aiug-accent);
	color: #fff;
	font-weight: 700;
	border-radius: 50%;
}

.aiug-mini-day--today:hover {
	filter: brightness(1.1);
}

.aiug-mini-day--has-events {
	position: relative;
}

.aiug-mini-day--has-events::after {
	content: '';
	position: absolute;
	bottom: 1px;
	left: 50%;
	transform: translateX(-50%);
	width: 4px;
	height: 4px;
	border-radius: 50%;
	background: var(--aiug-accent);
}

.aiug-mini-day--today.aiug-mini-day--has-events::after {
	background: #fff;
}

/* ── MODAL ──────────────────────────────────────────────────────────────── */
.aiug-modal {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
}

.aiug-modal[hidden] {
	display: none;
}

.aiug-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, .55);
	backdrop-filter: blur(2px);
	cursor: pointer;
}

.aiug-modal__dialog {
	position: relative;
	z-index: 1;
	background: var(--aiug-bg);
	border-radius: var(--aiug-radius);
	box-shadow: var(--aiug-shadow-lg);
	display: flex;
	flex-direction: column;
	width: min(900px, 92vw);
	height: min(700px, 88vh);
	overflow: hidden;
	animation: aiug-modal-in .18s ease;
}

@keyframes aiug-modal-in {
	from { opacity: 0; transform: scale(.97) translateY(8px); }
	to   { opacity: 1; transform: scale(1)  translateY(0); }
}

@media (max-width: 520px) {
	.aiug-modal__dialog {
		width: 100vw;
		height: 100dvh;
		border-radius: 0;
	}
}

.aiug-modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 14px;
	border-bottom: 1px solid var(--aiug-border);
	background: var(--aiug-bg-alt);
	flex-shrink: 0;
}

.aiug-modal__title {
	font-weight: 600;
	font-size: .9rem;
	color: var(--aiug-text-muted);
}

.aiug-modal__actions {
	display: flex;
	gap: 4px;
}

.aiug-btn--icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 6px;
	color: var(--aiug-text-muted);
	transition: background .15s, color .15s;
}

.aiug-btn--icon:hover {
	background: var(--aiug-accent-light);
	color: var(--aiug-accent);
}

.aiug-modal__body {
	flex: 1;
	overflow: hidden;
}

.aiug-modal__iframe {
	width: 100%;
	height: 100%;
	border: none;
	display: block;
}

/* ── Responsive Tweaks ──────────────────────────────────────────────────── */
@media (max-width: 640px) {
	.aiug-toolbar {
		flex-direction: column;
		align-items: flex-start;
		gap: 8px;
	}

	.aiug-toolbar__period {
		min-width: unset;
		font-size: .9rem;
	}

	.aiug-month-cell {
		min-height: 60px;
	}

	.aiug-week-header {
		grid-template-columns: 36px repeat(7, 1fr);
	}

	.aiug-week-gutter {
		width: 36px;
	}

	.aiug-day-columns {
		left: 36px;
	}

	.aiug-hour-label {
		width: 32px;
		font-size: .6rem;
	}

	.aiug-week-header-cell {
		padding: 6px 2px;
	}

	.aiug-week-day-num {
		font-size: .85rem;
	}
}
