/* v0.1.3: compact the actual calendar grid width without reducing readability */
@media (min-width: 641px) {
	.sac-calendar-card {
		width: min(660px, calc(100% - 32px));
		padding-inline: 18px;
	}

	.sac-weekdays,
	.sac-calendar-grid {
		width: min(100%, 520px);
		margin-inline: auto;
	}

	.sac-toolbar {
		width: min(100%, 600px);
		margin-inline: auto;
		margin-bottom: 10px;
	}

	.sac-legend {
		width: min(100%, 520px);
		margin-inline: auto;
		margin-top: 4px;
	}

	.sac-day-cell {
		height: 38px;
	}

	.sac-day {
		width: 38px;
		height: 38px;
		font-size: 13px;
	}

	.sac-day-number {
		width: 30px;
		height: 30px;
	}

	.sac-weekdays {
		font-size: 12px;
	}
}

/* Ensure the HTML hidden attribute always wins over component display rules. */
.sac-root [hidden] {
	display: none !important;
}

.sac-root {
	--sac-green: #29a84a;
	--sac-green-dark: #218d3d;
	--sac-green-soft: #eef9f1;
	--sac-orange: #f6a13a;
	--sac-text: #263347;
	--sac-muted: #8893a6;
	--sac-border: #e3e8ec;
	--sac-shadow: 0 8px 24px rgba(17, 35, 56, 0.06);
	font-family: inherit;
	color: var(--sac-text);
	width: 100%;
}

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

.sac-section-heading {
	text-align: center;
	margin: 0 auto 18px;
	padding-inline: 16px;
}

.sac-section-heading h2 {
	color: var(--sac-green);
	font-size: clamp(24px, 2.2vw, 34px);
	line-height: 1.3;
	font-weight: 600;
	margin: 0 0 6px;
}

.sac-section-heading p {
	color: var(--sac-muted);
	font-size: 15px;
	line-height: 1.7;
	margin: 0;
}

.sac-calendar-card {
	width: min(720px, calc(100% - 32px));
	margin: 0 auto;
	padding: 15px 17px 12px;
	background: #fff;
	border: 1px solid var(--sac-border);
	border-radius: 12px;
	box-shadow: var(--sac-shadow);
}

.sac-toolbar {
	direction: rtl;
	display: grid;
	grid-template-columns: minmax(86px, 1fr) auto minmax(86px, 1fr);
	align-items: center;
	gap: 10px;
	min-height: 34px;
	margin-bottom: 10px;
}

.sac-toolbar-center {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
}

.sac-month-title {
	font-size: 15px;
	line-height: 1.3;
	font-weight: 600;
	color: var(--sac-text);
	margin: 0;
	white-space: nowrap;
}

.sac-year-select {
	min-width: 70px;
	height: 30px;
	border: 1px solid #cfe9d6;
	border-radius: 8px;
	background: var(--sac-green-soft);
	color: var(--sac-green-dark);
	padding: 0 10px;
	font: inherit;
	font-size: 12px;
	cursor: pointer;
	outline: none;
}

.sac-year-select:focus-visible,
.sac-nav:focus-visible,
.sac-day:focus-visible,
.sac-reset-day:focus-visible,
.sac-card a:focus-visible {
	outline: 3px solid rgba(41, 168, 74, 0.25);
	outline-offset: 2px;
}

.sac-nav {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	width: fit-content;
	min-width: 70px;
	height: 30px;
	padding: 0 11px;
	border: 1px solid var(--sac-border);
	border-radius: 8px;
	background: #fff;
	color: #677386;
	font: inherit;
	font-size: 12px;
	cursor: pointer;
	transition: border-color .2s ease, color .2s ease, background .2s ease;
}

.sac-prev {
	justify-self: start;
}

.sac-next {
	justify-self: end;
}

.sac-nav:hover:not(:disabled) {
	border-color: #b9dec3;
	color: var(--sac-green-dark);
	background: var(--sac-green-soft);
}

.sac-nav:disabled {
	opacity: .38;
	cursor: default;
}

.sac-weekdays,
.sac-calendar-grid {
	display: grid;
	grid-template-columns: repeat(7, minmax(0, 1fr));
}

.sac-weekdays {
	border-bottom: 1px solid #edf0f2;
	padding-bottom: 5px;
	margin-bottom: 2px;
	color: #929caf;
	font-size: 10px;
	text-align: center;
}

.sac-weekdays span {
	padding: 4px 2px;
}

.sac-day-cell {
	min-width: 0;
	height: 34px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.sac-day-cell.is-outside {
	visibility: hidden;
}

.sac-day {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 34px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #9aa4b5;
	font: inherit;
	font-size: 13px;
	cursor: default;
}

.sac-day.has-activities {
	color: #334155;
	font-weight: 600;
	cursor: pointer;
}

.sac-day.has-activities:hover:not(.is-selected) {
	background: var(--sac-green-soft);
	color: var(--sac-green-dark);
}

.sac-day-number {
	position: relative;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border-radius: 50%;
}

.sac-activity-dot {
	position: absolute;
	z-index: 3;
	left: 50%;
	bottom: 0;
	width: 4px;
	height: 4px;
	border-radius: 50%;
	background: var(--sac-green);
	transform: translateX(-50%);
}

.sac-day.is-selected .sac-day-number {
	background: var(--sac-green);
	color: #fff;
}

.sac-day.is-selected .sac-activity-dot {
	background: #fff;
	bottom: 3px;
}

.sac-day.is-today .sac-day-number {
	border: 1.5px solid #62c57a;
}

.sac-day.is-today.is-selected .sac-day-number {
	border-color: var(--sac-green);
}

.sac-legend {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-start;
	gap: 7px 12px;
	padding-top: 6px;
	margin-top: 3px;
	border-top: 1px solid #f0f2f4;
	color: #98a1b0;
	font-size: 10px;
}

.sac-legend span {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	white-space: nowrap;
}

.sac-legend i {
	display: inline-block;
	flex: 0 0 auto;
}

.sac-legend-dot {
	width: 4px;
	height: 4px;
	border-radius: 50%;
	background: var(--sac-green);
}

.sac-legend-selected {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: var(--sac-green);
}

.sac-legend-today {
	width: 14px;
	height: 14px;
	border-radius: 50%;
	border: 1.5px solid #62c57a;
}

.sac-results {
	width: min(1180px, calc(100% - 24px));
	margin: 34px auto 0;
}

.sac-results-header {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 24px;
	margin-bottom: 18px;
}

.sac-results-title {
	margin: 0 0 4px;
	color: var(--sac-green);
	font-size: clamp(22px, 2vw, 30px);
	line-height: 1.35;
	font-weight: 600;
}

.sac-results-count {
	margin: 0;
	color: var(--sac-muted);
	font-size: 13px;
}

.sac-reset-day {
	border: 0;
	background: transparent;
	color: var(--sac-green-dark);
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 4px;
	cursor: pointer;
	padding: 6px 0;
}

.sac-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	min-height: 90px;
	color: var(--sac-muted);
	font-size: 14px;
}

.sac-spinner {
	width: 22px;
	height: 22px;
	border: 2px solid #dcefe1;
	border-top-color: var(--sac-green);
	border-radius: 50%;
	animation: sac-spin .8s linear infinite;
}

@keyframes sac-spin {
	to { transform: rotate(360deg); }
}

.sac-error {
	padding: 14px 16px;
	border: 1px solid #f2c9c9;
	border-radius: 10px;
	background: #fff5f5;
	color: #a33b3b;
	text-align: center;
}

.sac-cards {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 22px;
}

.sac-card {
	display: flex;
	flex-direction: column;
	min-width: 0;
	overflow: hidden;
	background: #fff;
	border: 1px solid #edf0f2;
	border-radius: 12px;
	box-shadow: 0 8px 22px rgba(17, 35, 56, 0.07);
	transition: transform .2s ease, box-shadow .2s ease;
}

.sac-card:hover {
	transform: translateY(-2px);
	box-shadow: 0 12px 28px rgba(17, 35, 56, 0.10);
}

.sac-card-image {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 8.8;
	overflow: hidden;
	background: #f1f4f3;
}

.sac-card-image img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform .35s ease;
}

.sac-card:hover .sac-card-image img {
	transform: scale(1.025);
}

.sac-card-image--placeholder {
	background:
		linear-gradient(135deg, rgba(41,168,74,.08), rgba(246,161,58,.08)),
		#f5f7f6;
}

.sac-card-body {
	display: flex;
	flex: 1;
	flex-direction: column;
	align-items: flex-start;
	padding: 16px 18px 15px;
	text-align: right;
}

.sac-card-badge {
	display: inline-flex;
	align-items: center;
	min-height: 23px;
	padding: 3px 10px;
	margin-bottom: 10px;
	border-radius: 999px;
	background: #fff6eb;
	color: #e7942f;
	font-size: 10px;
	line-height: 1.4;
}

.sac-card h4 {
	margin: 0 0 10px;
	font-size: 15px;
	line-height: 1.55;
	font-weight: 600;
}

.sac-card h4 a {
	color: var(--sac-green);
	text-decoration: none;
}

.sac-card-meta {
	display: grid;
	gap: 5px;
	list-style: none;
	padding: 0;
	margin: 0 0 12px;
	color: #7e8999;
	font-size: 12px;
}

.sac-card-meta li {
	display: flex;
	align-items: center;
	gap: 6px;
}

.sac-meta-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 15px;
	color: #7f8997;
	font-size: 13px;
}

.sac-card-excerpt {
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
	margin: 0 0 14px;
	color: #596579;
	font-size: 13px;
	line-height: 1.8;
}

.sac-card-more {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	margin-top: auto;
	color: var(--sac-green);
	font-size: 13px;
	font-weight: 500;
	text-decoration: none;
}

.sac-card-more:hover {
	color: var(--sac-green-dark);
}

.sac-empty {
	max-width: 560px;
	margin: 34px auto 20px;
	padding: 22px 18px;
	text-align: center;
}

.sac-empty-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 54px;
	height: 54px;
	margin-bottom: 14px;
	border-radius: 50%;
	background: var(--sac-green-soft);
	color: #7dcc90;
	font-size: 27px;
}

.sac-empty h4 {
	margin: 0 0 8px;
	color: #485467;
	font-size: 19px;
	font-weight: 600;
}

.sac-empty p {
	margin: 0;
	color: var(--sac-muted);
	font-size: 13px;
	line-height: 1.8;
}

.sac-admin-message {
	padding: 16px;
	border: 1px solid #ead7ad;
	border-radius: 8px;
	background: #fffaf0;
	color: #795d24;
	text-align: center;
}

@media (max-width: 900px) {
	.sac-calendar-card {
		width: min(86%, 720px);
	}

	.sac-cards {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 640px) {
	.sac-section-heading {
		margin-bottom: 18px;
	}

	.sac-calendar-card {
		width: calc(100% - 18px);
		padding: 12px 9px 10px;
		border-radius: 12px;
	}

	.sac-toolbar {
		grid-template-columns: 1fr auto 1fr;
		gap: 6px;
		margin-bottom: 12px;
	}

	.sac-toolbar-center {
		flex-direction: column;
		gap: 5px;
	}

	.sac-month-title {
		font-size: 15px;
	}

	.sac-year-select {
		min-width: 72px;
		height: 31px;
		font-size: 12px;
	}

	.sac-nav {
		min-width: 40px;
		width: 40px;
		height: 34px;
		padding: 0;
		font-size: 16px;
	}

	.sac-nav span:not([aria-hidden="true"]) {
		display: none;
	}

	.sac-weekdays {
		font-size: 10px;
	}

	.sac-day-cell {
		height: 34px;
	}

	.sac-day {
		width: 38px;
		height: 34px;
		font-size: 12px;
	}

	.sac-day-number {
		width: 28px;
		height: 28px;
	}

	.sac-legend {
		justify-content: center;
		gap: 8px 11px;
		font-size: 9px;
	}

	.sac-results {
		width: calc(100% - 24px);
		margin-top: 34px;
	}

	.sac-results-header {
		align-items: flex-start;
		flex-direction: column;
		gap: 6px;
	}

	.sac-cards {
		grid-template-columns: 1fr;
		gap: 18px;
	}

	.sac-card h4 {
		font-size: 16px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.sac-root *,
	.sac-root *::before,
	.sac-root *::after {
		scroll-behavior: auto !important;
		animation-duration: .01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: .01ms !important;
	}
}


/* =========================================================
   v0.1.4 — Compact geometry + clearer/larger typography
   These rules are intentionally LAST so they win.
   ========================================================= */

@media (min-width: 641px) {
	/* Make the component itself compact instead of shrinking the content. */
	.sac-root .sac-calendar-card {
		width: min(610px, calc(100% - 32px));
		padding: 13px 15px 10px;
		border-radius: 12px;
	}

	/* Keep all internal controls on the same compact visual axis. */
	.sac-root .sac-toolbar {
		width: min(100%, 545px);
		grid-template-columns: 78px minmax(0, 1fr) 78px;
		gap: 8px;
		min-height: 34px;
		margin: 0 auto 8px;
	}

	.sac-root .sac-toolbar-center {
		gap: 8px;
	}

	/* Slightly larger and clearer than v0.1.3. */
	.sac-root .sac-month-title {
		font-size: 17px;
		font-weight: 700;
		line-height: 1.25;
	}

	.sac-root .sac-year-select {
		min-width: 76px;
		height: 32px;
		padding-inline: 9px;
		font-size: 13px;
		font-weight: 600;
	}

	.sac-root .sac-nav {
		min-width: 70px;
		height: 32px;
		padding-inline: 9px;
		font-size: 13px;
	}

	/* THIS is the key change: narrower actual seven-column grid. */
	.sac-root .sac-weekdays,
	.sac-root .sac-calendar-grid {
		width: 448px;
		max-width: 100%;
		margin-inline: auto;
	}

	.sac-root .sac-weekdays {
		padding-bottom: 5px;
		margin-bottom: 1px;
		font-size: 13px;
		font-weight: 500;
	}

	.sac-root .sac-weekdays span {
		padding: 3px 0;
	}

	/* Less unused vertical air, while keeping 36px clickable cells. */
	.sac-root .sac-day-cell {
		height: 36px;
	}

	.sac-root .sac-day {
		width: 36px;
		height: 36px;
		font-size: 14px;
		line-height: 1;
	}

	.sac-root .sac-day-number {
		width: 31px;
		height: 31px;
		font-weight: 500;
	}

	.sac-root .sac-day.has-activities {
		font-weight: 700;
	}

	.sac-root .sac-activity-dot {
		width: 5px;
		height: 5px;
		bottom: 0;
	}

	/* Compact legend, but do not make its labels tiny. */
	.sac-root .sac-legend {
		width: 448px;
		max-width: 100%;
		margin: 3px auto 0;
		padding-top: 6px;
		gap: 6px 12px;
		font-size: 11.5px;
		line-height: 1.3;
	}

	.sac-root .sac-legend span {
		gap: 5px;
	}

	/* Bring results closer to the filter control. */
	.sac-root .sac-results {
		margin-top: 30px;
	}
}

/* Tablet: compact, but don't over-compress the text. */
@media (min-width: 641px) and (max-width: 900px) {
	.sac-root .sac-calendar-card {
		width: min(610px, calc(100% - 28px));
	}

	.sac-root .sac-weekdays,
	.sac-root .sac-calendar-grid,
	.sac-root .sac-legend {
		width: min(448px, 100%);
	}
}

/* Mobile keeps full-width usability and readable type. */
@media (max-width: 640px) {
	.sac-root .sac-calendar-card {
		width: calc(100% - 18px);
		padding: 11px 8px 9px;
	}

	.sac-root .sac-month-title {
		font-size: 16px;
		font-weight: 700;
	}

	.sac-root .sac-year-select {
		font-size: 13px;
	}

	.sac-root .sac-weekdays {
		font-size: 11px;
	}

	.sac-root .sac-day {
		font-size: 13px;
	}

	.sac-root .sac-legend {
		font-size: 10px;
	}
}


/* =========================================================
   v0.1.5 — Remove side dead space + compact centered toolbar
   Intentionally appended LAST so these rules win.
   ========================================================= */

@media (min-width: 641px) {
	/* The card now hugs the actual calendar content. */
	.sac-root .sac-calendar-card {
		width: min(490px, calc(100% - 28px));
		padding: 11px 12px 9px;
	}

	/* Put previous / month+year / next together as one compact group. */
	.sac-root .sac-toolbar {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
		width: fit-content;
		max-width: 100%;
		grid-template-columns: none;
		gap: 8px;
		margin: 0 auto 8px;
		min-height: 34px;
	}

	.sac-root .sac-prev,
	.sac-root .sac-next {
		justify-self: auto;
		flex: 0 0 auto;
	}

	.sac-root .sac-toolbar-center {
		flex: 0 0 auto;
		gap: 7px;
	}

	.sac-root .sac-nav {
		min-width: 68px;
		height: 32px;
		padding-inline: 9px;
		font-size: 13px;
	}

	.sac-root .sac-month-title {
		font-size: 17px;
		font-weight: 700;
	}

	.sac-root .sac-year-select {
		min-width: 76px;
		height: 32px;
		font-size: 13px;
		font-weight: 600;
	}

	/* Let the grid fill the now-narrow card instead of sitting inside a wider shell. */
	.sac-root .sac-weekdays,
	.sac-root .sac-calendar-grid,
	.sac-root .sac-legend {
		width: 100%;
		max-width: none;
		margin-inline: 0;
	}

	.sac-root .sac-weekdays {
		font-size: 13px;
		font-weight: 500;
	}

	.sac-root .sac-day {
		font-size: 14px;
	}

	.sac-root .sac-day-cell {
		height: 36px;
	}

	.sac-root .sac-legend {
		justify-content: center;
		gap: 6px 11px;
		padding-top: 6px;
		margin-top: 3px;
		font-size: 11.5px;
	}
}

/* Keep tablet compact as well without crushing the calendar. */
@media (min-width: 641px) and (max-width: 900px) {
	.sac-root .sac-calendar-card {
		width: min(490px, calc(100% - 24px));
	}
}


/* =========================================================
   v0.1.6 — Toolbar spans Saturday/Friday columns more naturally
   Intentionally appended LAST so these rules win.
   ========================================================= */

@media (min-width: 641px) {
	/* Keep the compact card width from v0.1.5 */
	.sac-root .sac-calendar-card {
		width: min(490px, calc(100% - 28px));
	}

	/* Make the toolbar align visually with the 7 calendar columns */
	.sac-root .sac-toolbar {
		display: grid;
		grid-template-columns: repeat(7, minmax(0, 1fr));
		align-items: center;
		justify-items: stretch;
		width: 100%;
		max-width: none;
		gap: 6px;
		margin: 0 auto 8px;
		min-height: 34px;
	}

	/* Put السابق over the Saturday side and التالي over the Friday side */
	.sac-root .sac-prev {
		grid-column: 1 / 2;
		justify-self: stretch;
		width: 100%;
		min-width: 0;
	}

	.sac-root .sac-next {
		grid-column: 7 / 8;
		justify-self: stretch;
		width: 100%;
		min-width: 0;
	}

	/* Keep month/year centered as the main focal group */
	.sac-root .sac-toolbar-center {
		grid-column: 3 / 6;
		justify-self: center;
		align-items: center;
		gap: 7px;
	}

	/* Slightly wider buttons than v0.1.5 */
	.sac-root .sac-nav {
		width: 100%;
		height: 32px;
		min-width: 0;
		padding-inline: 10px;
		font-size: 13px;
	}

	.sac-root .sac-month-title {
		font-size: 17px;
		font-weight: 700;
	}

	.sac-root .sac-year-select {
		min-width: 76px;
		height: 32px;
		font-size: 13px;
		font-weight: 600;
	}
}
