/* ---------- Base ---------- */
:root {
	--nav-height: 60px;
	--primary: #3e2993;
	--primary-faded: #d8d4e9;
	--primary-light: #9e94c9;
	--primary-bright: #513e9d;
	--bg: #e6e7ed;
	--bg-welcome: #d0cbe5;
	--fg: #001752;
	--fg-muted: #888888;
	--magenta: #f80070;
	--orange: #ed5b40;
	--green: #6d9529;
	--cyan: #0093a2;
	--blue: #3e2993;
	--white: #ffffff;
	--border: #aaaaaa;
	--max-width: 60rem;
}

html, body {
	margin: 0;
	padding: 0;
	width: 100%;
	height: 100vh;
	overflow: hidden;
	font-family: Montserrat, sans-serif;
	color: var(--fg);
	background-color: var(--bg);
}

summary { list-style: none; }
summary::-webkit-details-marker { display: none; }

/* ---------- Sign in ---------- */
.auth-redirect { display: flex; align-items: center; justify-content: center; height: 100vh; background: var(--bg); color: var(--fg); }
.auth-card { background: var(--white); padding: 2rem 3rem; border-radius: 16px; box-shadow: 0 10px 30px #00000026; text-align: center; max-width: 420px; }
.auth-card h1 { margin: 0 0 .5rem; font-size: 1.8rem; }
.auth-card p { margin: .5rem 0; color: var(--fg-muted); }
.auth-error { color: #b00020 !important; font-weight: 600; }
.auth-retry { margin-top: 1rem; border: none; background: var(--primary); color: var(--white); padding: .6rem 1.25rem; border-radius: 999px; cursor: pointer; font-weight: 600; font-family: inherit; font-size: 1rem; display: inline-block; text-decoration: none; }
.auth-retry:hover { background: var(--primary-bright); }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-rows: 60px 1fr; height: 100vh; width: 100%; }
.content { overflow-y: auto; }

/* ---------- Nav ---------- */
.nav {
	background-color: var(--white);
	color: var(--fg);
	display: flex;
	align-items: center;
	font-size: 1.5rem;
	justify-content: center;
	gap: 1rem;
	border-bottom: 1px solid var(--border);
}
.nav .nav-inner { width: 100%; max-width: min(1200px, 90%); display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0 auto; }
.nav .nav-search { display: flex; align-items: center; flex: 1; max-width: 520px; position: relative; }
.nav input {
	width: 100%;
	height: 2.25rem;
	border-radius: 999px;
	border: 1px solid var(--border);
	padding: 0 1rem;
	font-size: 1rem;
	font-family: inherit;
	outline: none;
}
.nav input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-faded); }
.nav .nav-account-wrap { position: relative; display: flex; align-items: center; }
.nav .nav-account { display: inline-flex; align-items: center; line-height: 1; font-size: 1rem; font-weight: bold; color: var(--primary); text-decoration: none; cursor: pointer; }
.nav .nav-account-menu {
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	min-width: 180px;
	background: var(--white);
	border: 1px solid var(--border);
	border-radius: 10px;
	box-shadow: 0 10px 25px rgba(0, 0, 0, 0.14);
	padding: 0.4rem;
	z-index: 30;
}
.nav .nav-signout {
	width: 100%;
	border: none;
	background: transparent;
	color: var(--fg);
	font-size: 0.95rem;
	font-family: inherit;
	font-weight: 600;
	text-align: left;
	padding: 0.55rem 0.6rem;
	border-radius: 8px;
	cursor: pointer;
}
.nav .nav-signout:hover { background: var(--primary-faded); color: var(--primary); }

/* Sandwich menu */
.sandwich-menu { position: relative; }
.sandwich-menu > summary { color: var(--primary); cursor: pointer; padding: 4px 0; display: flex; }
.menu-panel {
	position: absolute;
	top: 44px;
	left: 0;
	min-width: 320px;
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 6px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
	padding: 8px;
	overflow: hidden;
	z-index: 10;
}
.menu-link, .menu-item > summary {
	width: 100%;
	min-height: 40px;
	padding: 8px 10px;
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	color: inherit;
	text-decoration: none;
	font-size: 1rem;
	line-height: 1.2;
	box-sizing: border-box;
	cursor: pointer;
}
.menu-link:hover, .menu-item > summary:hover { background: #f4f4f4; }
.menu-caret { font-size: 14px; line-height: 1; width: 16px; display: inline-flex; justify-content: center; opacity: .7; }
.menu-caret::before { content: "▸"; }
.menu-item[open] > summary .menu-caret::before { content: "▾"; }
.submenu { margin: 4px 0 0 12px; padding-left: 12px; border-left: 2px solid #e5e5e5; }
.submenu .submenu { margin-left: 12px; }

/* Drive search */
.nav-search-results {
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	right: 0;
	font-size: 1rem;
	background: var(--white);
	border: 1px solid var(--border);
	border-radius: 10px;
	box-shadow: 0 10px 25px #0000001f;
	padding: .5rem;
	max-height: 320px;
	overflow-y: auto;
	z-index: 20;
}
.nav-search-results ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; }
.nav-search-results li a { display: flex; align-items: center; gap: .5rem; padding: .5rem .6rem; border-radius: 8px; color: var(--fg); text-decoration: none; font-weight: 500; }
.nav-search-results li a:hover { background: var(--primary-faded); }
.nav-search-results img { width: 18px; height: 18px; }
.search-status { padding: .4rem .6rem; color: var(--fg-muted); }
.search-error { padding: .4rem .6rem; color: #b00020; font-weight: 600; }

/* ---------- Hero ---------- */
.hero {
	position: relative;
	overflow: hidden;
	height: 10rem;
	background-color: var(--fg);
	color: var(--white);
	text-align: center;
	z-index: 0;
	padding: 2rem;
}
.hero h1 { font-size: 3rem; position: relative; z-index: 2; }
.hero-square { position: absolute; z-index: 1; border-radius: 8px; opacity: 0.8; }
@media (max-width: 800px) {
	.hero { padding: 1.5rem; }
	.hero h1 { font-size: 2rem; }
}
@media (max-width: 600px) {
	.hero { padding: 1rem; }
}

/* ---------- Main grid & cards ---------- */
.main-grid {
	margin: 0 auto;
	margin-top: -60px;
	max-width: min(1200px, 90%);
	display: grid;
	gap: 2rem;
	grid-template-columns: 3fr 2fr;
}
@media (max-width: 900px) {
	.main-grid { grid-template-columns: 1fr; }
}

.card {
	z-index: 2;
	background-color: white;
	box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
	border-radius: 8px;
	overflow: hidden;
	grid-column: 1 / -1;
	grid-row: span 1;
	display: grid;
	grid-template-rows: auto 1fr auto;
}
.card.narrow { grid-column: span 1; }

/* Left and right columns of the home page (each a vertical stack of cards). */
.grid-column { display: flex; flex-direction: column; gap: 2rem; min-width: 0; }
.card.tall { grid-row: span 2; }
.card.rounded-tl { border-top-left-radius: 4rem; }
.card h1 { font-size: 1.2rem; margin-top: 1.2rem; }
.card a { text-decoration: none; font-weight: bold; color: var(--primary); }
@media (max-width: 900px) {
	.card, .card.narrow { grid-column: 1 / -1; }
}

.card-header { padding-left: 1.5rem; display: flex; align-items: baseline; }
.card-header > *:last-child { margin-right: 2rem; }
.card-body { padding: 1.5rem; }
.card-body p { margin: 0; }
.spacer { margin-left: auto; }

/* Welcome card */
.welcome-card {
	background-color: var(--bg-welcome);
	grid-template-columns: 1fr auto;
	grid-template-rows: none;
	grid-template-areas:
		"header corner"
		"buttons buttons";
}
.welcome-card .welcome-header { grid-area: header; }
.welcome-card .welcome-header h1 { font-size: 1.5rem; padding-left: 1.5rem; }
.welcome-card .buttons-bar { grid-area: buttons; }
.welcome-corner {
	grid-area: corner;
	background-color: var(--white);
	margin-left: auto;
	margin-right: 0 !important;
	align-self: flex-start;
	padding: 1rem 4rem;
	border-bottom-left-radius: 4rem;
	cursor: default;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}
.welcome-corner .heart { width: 32px; height: 32px; color: var(--primary); }
@media (max-width: 600px) {
	.welcome-card {
		grid-template-columns: 1fr;
		grid-template-areas: "header" "buttons" "corner";
	}
	.welcome-corner { border-bottom-left-radius: 0; border-top-left-radius: 4rem; }
}

.buttons-bar {
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	gap: 1rem;
	margin: 1rem 1.5rem 2rem 1.5rem;
}
@media (max-width: 900px) {
	.buttons-bar { grid-template-columns: 1fr; }
}

.app-button {
	display: inline-flex;
	position: relative;
	align-items: center;
	height: 4rem;
	background-color: var(--white);
	color: var(--primary);
	font-weight: bold;
	font-family: inherit;
	font-size: 1rem;
	border: none;
	border-radius: 8px;
}
.app-button > img { height: 3rem; width: 3rem; object-fit: cover; margin: 0.5rem; }
.app-button div.label { text-align: left; margin-right: 0.5rem; }
.app-button[data-name="Reporting Center"] div.label { margin-left: -0.3rem; }
.app-button:hover { box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); color: var(--primary-bright); }
.app-button:active { box-shadow: 0 0 5px var(--primary); }
.app-button .heart {
	position: absolute;
	right: 0;
	top: 0;
	padding: 4px;
	width: 16px;
	height: 16px;
	color: var(--primary-faded);
	cursor: pointer;
}
.app-button .heart:hover { color: var(--primary-bright); }
.app-button[data-favorite="true"] .heart-outline,
.app-button[data-favorite="false"] .heart-filled { display: none; }
/* Selected: solid dark heart. Unselected: outline only. */
.app-button .heart-filled { color: var(--primary); }
.app-button .heart-outline { color: var(--primary-light); }
.buttons-bar.favorites-only .heart { display: none; }
.buttons-bar.favorites-only .app-button[data-favorite="false"] { display: none; }

/* Favorites toggle switch */
.toggle {
	width: 30px;
	height: 16px;
	padding: 0;
	border: none;
	background: #ccc;
	border-radius: 25px;
	position: relative;
	cursor: pointer;
	transition: background 0.3s;
}
.toggle.on { background: var(--primary); }
.toggle-knob {
	width: 12px;
	height: 12px;
	background: white;
	border-radius: 50%;
	position: absolute;
	top: 2px;
	left: 2px;
	transition: transform 0.3s;
}
.toggle.on .toggle-knob { transform: translateX(14px); }

/* Featured article card */
.card.featured-card {
	background-color: var(--primary);
	color: var(--white);
	display: flex;
}
.featured-card img { width: 50%; flex-shrink: 0; object-fit: cover; }
.featured-card > div { padding: 1.5rem; display: flex; flex-direction: column; justify-content: space-between; }
.featured-card a { color: var(--white); }
@media (max-width: 900px) {
	.card.featured-card { flex-direction: column; }
	.featured-card img { width: 100%; height: 200px; }
}

/* Footer */
.footer { margin-top: 6rem; display: flex; }
.footer > div {
	display: flex;
	padding: 0 4rem;
	height: 4rem;
	align-items: center;
	margin-left: auto;
	background-color: var(--white);
	border-top-left-radius: 6rem;
}

/* ---------- Modals ---------- */
.new-staff-cta {
	position: fixed;
	top: calc(var(--nav-height) + 16px);
	right: max(5vw, calc((100vw - 1200px) / 2));
	z-index: 15;
	border: none;
	border-radius: 999px;
	background: var(--magenta);
	color: var(--white);
	font-family: inherit;
	font-size: .95rem;
	font-weight: 700;
	line-height: 1;
	padding: .5rem 1rem;
	cursor: pointer;
	text-decoration: none;
	box-shadow: 0 10px 24px #f8007059;
}
.new-staff-cta:hover { filter: brightness(1.05); }
.new-staff-modal-backdrop { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 1rem; background: #0006; z-index: 40; }
.featured-article-modal-backdrop { background: #0000008c; z-index: 1000; }
.new-staff-modal { width: min(720px, 100%); line-height: 2; background: var(--white); border-radius: 14px; border: 1px solid var(--border); box-shadow: 0 20px 40px #0003; padding: 1.25rem 1.25rem 1rem; box-sizing: border-box; max-height: 100%; overflow: auto; }
.new-staff-modal.featured-article-modal-shell { width: min(980px, 100%); max-height: 90vh; overflow: auto; line-height: normal; padding: 0; box-shadow: 0 20px 40px #00000047; }
.new-staff-modal h2 { margin: 0 0 .75rem; color: var(--fg); }
.new-staff-modal p { margin: 0 0 1rem; color: var(--fg); line-height: 1.5; }
.new-staff-close { display: block; width: fit-content; margin-left: auto; border: none; border-radius: 8px; background: var(--primary); color: var(--white); text-decoration: none; font-family: inherit; font-size: .95rem; font-weight: 600; line-height: 1; padding: .55rem .9rem; cursor: pointer; }
.new-staff-actions { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.new-staff-hide-toggle { display: inline-flex; align-items: center; gap: .45rem; font-size: .95rem; color: var(--fg); }
.new-staff-hide-toggle input { margin: 0; }

.staff-training-modal { line-height: 1.5; }
.staff-training-columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 0 0 1rem; }
.staff-training-column h3 { margin: 0 0 .5rem; font-size: 1rem; color: var(--fg); }
.staff-training-column ul { margin: 0; padding-left: 1rem; }
.staff-training-column li + li { margin-top: .35rem; }
.staff-training-column a { color: var(--primary); }

.boostlingo-modal, .boostlingo-modal--narrow { width: min(700px, 90vw); }
.boostlingo-modal--wide { width: min(1180px, 95vw); }
.boostlingo-layout { display: grid; grid-template-columns: minmax(640px, 1fr) minmax(320px, auto); gap: 1rem; }
.boostlingo-links-column { display: grid; gap: 1rem; align-content: start; }
.boostlingo-link-group h3 { margin: 0 0 .45rem; color: var(--fg); }
.boostlingo-link-group ul { margin: 0; padding-left: 1rem; }
.boostlingo-link-group li + li { margin-top: .35rem; }
.boostlingo-link-group a { color: var(--primary); }
.boostlingo-topic-tabs { display: inline-flex; flex-wrap: nowrap; gap: 0; justify-content: center; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; margin-bottom: .75rem; }
.boostlingo-topic-tab-link { display: inline-flex; align-items: center; line-height: 1.5; justify-content: center; text-decoration: none; border: none; border-right: 1px solid var(--border); padding: .35rem .65rem; color: var(--primary); font-size: .92rem; font-weight: 600; }
.boostlingo-topic-tab-link:last-child { border-right: none; }
.boostlingo-topic-tab-link.is-active { background: var(--primary-faded); color: var(--primary); }
.boostlingo-topic-view { font-size: 1.2rem; }
.boostlingo-topic-view h3 { margin: 0 0 .5rem; }
.boostlingo-footer-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.boostlingo-footer-actions .new-staff-close { margin-left: 0; }
@media (max-width: 900px) {
	.staff-training-columns, .boostlingo-layout { grid-template-columns: 1fr; }
}

/* Featured article modal */
.article-header { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.article-title { flex: 1 1 auto; min-width: 0; }
.article-title h1 { margin: 0; color: var(--primary); font-size: 1.3rem; line-height: 1.3; }
.article-title-input {
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 0.35rem 0.6rem;
	font-size: 1rem;
	font-family: inherit;
	font-weight: 700;
	color: var(--primary);
}
.article-actions { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; flex-shrink: 0; }
.article-btn {
	border: 1px solid var(--border);
	background: var(--white);
	color: var(--fg);
	border-radius: 8px;
	font-family: inherit;
	font-size: 0.9rem;
	font-weight: 600;
	cursor: pointer;
	padding: 0.45rem 0.8rem;
	text-decoration: none;
}
.article-btn:hover { background: var(--primary-faded); }
.article-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.modal-x { border: 0; border-radius: 8px; background: transparent; color: var(--fg); cursor: pointer; font-size: 1.6rem; line-height: 1; padding: 0.2rem 0.4rem; text-decoration: none; }
.modal-x:hover { background: var(--primary-faded); }
.image-picker {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 0.7rem;
	border: 1px dashed var(--border);
	border-radius: 8px;
	padding: 0.35rem 0.6rem;
	font-weight: 600;
	cursor: pointer;
}
.image-picker input { display: none; }
.selected-file { margin: 0 0 0.8rem; color: var(--fg-muted, #666); font-size: 0.9rem; }
.article-body { padding: 1rem 1.5rem 1.5rem; }
.article-body img { width: min(340px, 45%); float: left; margin: 0 1rem 0.6rem 0; border-radius: 10px; object-fit: cover; }
.article-body p { line-height: 1.6; margin: 0 0 0.8rem; }
.article-body::after { content: ''; display: block; clear: both; }
.article-preview-input {
	display: block;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
	clear: both;
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 0.45rem 0.6rem;
	margin-bottom: 0.8rem;
	font-size: 1rem;
	font-family: inherit;
	color: var(--fg);
	resize: vertical;
	min-height: 5.5rem;
}
.editor-toolbar { clear: both; display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.8rem; margin-bottom: 0.6rem; }
.toolbar-btn { border: 1px solid var(--border); background: var(--white); color: var(--fg); border-radius: 6px; font-family: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer; padding: 0.35rem 0.55rem; }
.toolbar-btn[aria-pressed='true'] { background: var(--primary-faded); }
.editor { border: 1px solid var(--border); border-radius: 8px; padding: 0.55rem 0.7rem; min-height: 200px; outline: none; line-height: 1.6; }
.editor p { margin: 0 0 0.8rem; }
.error-text { color: #b00020; font-weight: 600; }
@media (max-width: 700px) {
	.article-body img { float: none; width: 100%; margin: 0 0 1rem 0; }
}

/* ---------- AI assistant ---------- */
.nav .nav-assistant {
	font-size: 0.9rem;
	font-weight: 700;
	color: var(--primary);
	text-decoration: none;
	border: 1px solid var(--primary-light);
	border-radius: 999px;
	padding: 0.4rem 0.9rem;
	white-space: nowrap;
}
.nav .nav-assistant:hover { background: var(--primary-faded); }

.assistant-modal { width: min(820px, 100%); height: min(85vh, 900px); display: flex; flex-direction: column; line-height: 1.5; }
.assistant-header { display: flex; align-items: center; gap: 0.75rem; }
.assistant-header h2 { margin: 0 !important; flex: 1; }
.assistant-notice {
	margin: 0.75rem 0 !important;
	padding: 0.6rem 0.8rem;
	border-left: 4px solid var(--magenta);
	background: #fff0f6;
	border-radius: 6px;
	font-size: 0.9rem;
}
.assistant-log {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
	padding: 0.25rem 0.1rem 0.75rem;
}
.assistant-msg { max-width: 85%; padding: 0.6rem 0.85rem; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.assistant-msg--user { align-self: flex-end; background: var(--primary); color: var(--white); border-bottom-right-radius: 4px; }
.assistant-msg--assistant { align-self: flex-start; background: var(--bg); color: var(--fg); border-bottom-left-radius: 4px; }
.assistant-msg--error { align-self: center; color: #b00020; font-weight: 600; font-size: 0.9rem; }
.assistant-msg.is-pending::after { content: "Thinking…"; color: var(--fg-muted); font-style: italic; }
.assistant-form { display: flex; gap: 0.5rem; align-items: flex-end; border-top: 1px solid var(--border); padding-top: 0.75rem; }
.assistant-form textarea {
	flex: 1;
	resize: none;
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 0.55rem 0.7rem;
	font-family: inherit;
	font-size: 1rem;
	color: var(--fg);
}
.assistant-form textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-faded); }
.assistant-form .auth-retry { margin-top: 0; }

/* ---------- MIS Support popup ---------- */
/* Same height as the Boostlingo popup (its 75vh / 900px document plus title and button), with roomier padding. */
.mis-support-modal {
	line-height: 1.5;
	min-height: calc(min(75vh, 900px) + 7rem);
	padding: 3rem 4rem 2.5rem;
	display: flex;
	flex-direction: column;
}
.mis-support-modal > div { flex: 1; }
.mis-support-modal .new-staff-close { margin-top: 1.5rem; }
@media (max-width: 600px) {
	.mis-support-modal { padding: 1.5rem; }
}
/* Generous vertical spacing between the title, intro, team cards and closing note. */
.mis-support-modal h2 { margin-bottom: 1.25rem !important; }
.mis-support-modal > div > p:first-child { margin-bottom: 1.5rem !important; }
.support-team { margin: 0 0 1.5rem; padding: 1rem 1.5rem; border-left: 4px solid var(--primary-light); background: var(--bg); border-radius: 6px; }
.support-team h3 { margin-bottom: 0.6rem !important; }
.support-team .support-scope { margin: 0 0 0.75rem !important; }
.support-team li + li { margin-top: 0.45rem; }

/* Closing notes: two bullet points in one pink callout box. */
.mis-support-modal .support-notice {
	margin: 2rem 0 1rem;
	padding: 1rem 1.5rem;
	border: 2px solid var(--magenta);
	border-left-width: 8px;
	border-radius: 8px;
	background: #fff0f6;
	color: var(--magenta);
	font-size: 1.1rem;
	font-weight: 700;
	line-height: 1.5;
}
.mis-support-modal .support-notice ul { margin: 0; padding-left: 1.25rem; }
.mis-support-modal .support-notice li + li { margin-top: 0.6rem; }
.mis-support-modal .support-notice a { color: var(--magenta); text-decoration: underline; }
