/*
 * Frontend "M365 Dashboard" — app-shell met zijbalk, topbar en kaarten.
 * Stijl geïnspireerd op Metronic/shadcn-achtige admin-UI's.
 *
 * Alles gescoped onder .m365mc-dashboard zodat het thema niet beïnvloed wordt.
 * Bevat ook shims voor WordPress-admin-classes (button, widefat, notice, …).
 */

/* Full-screen sjabloon: kale body, app-shell zweeft op een lichte achtergrond. */
body.m365mc-fullscreen { margin: 0; background: #eef1f5; }
body.m365mc-fullscreen .m365mc-dashboard { padding: 0 16px; }

.m365mc-dashboard {
	--m365-accent: #3581ca;
	--m365-accent-dark: #2a6aa8;
	--m365-accent-soft: rgba( 53, 129, 202, 0.12 );
	--m365-card: #ffffff;
	--m365-page: #fafbfc;
	--m365-border: #e6e8ec;
	--m365-text: #1f2933;
	--m365-muted: #6b7280;
	--m365-radius: 12px;
	--m365-shadow: 0 1px 3px rgba( 16, 24, 40, 0.06 ), 0 1px 2px rgba( 16, 24, 40, 0.04 );

	max-width: 1280px;
	margin: 24px auto;
	color: var( --m365-text );
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 14px;
	line-height: 1.55;
}

.m365mc-dashboard .m365mc-icon { display: block; }

/* App-shell -------------------------------------------------------------- */
.m365mc-app {
	display: flex;
	align-items: stretch;
	background: var( --m365-card );
	border: 1px solid var( --m365-border );
	border-radius: 14px;
	overflow: hidden;
	box-shadow: var( --m365-shadow );
	min-height: 620px;
}

/* Zijbalk ---------------------------------------------------------------- */
.m365mc-sidebar {
	width: 248px;
	flex-shrink: 0;
	display: flex;
	flex-direction: column;
	padding: 16px 14px;
	background: var( --m365-card );
	border-right: 1px solid var( --m365-border );
}
.m365mc-brand {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
	padding: 6px 10px 16px;
	font-weight: 700;
	font-size: 15px;
}
.m365mc-brand-mark { color: var( --m365-accent ); display: flex; }
.m365mc-brand-logo { max-height: 34px; max-width: 150px; width: auto; height: auto; }
.m365mc-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.m365mc-nav-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 12px;
	border-radius: 8px;
	color: var( --m365-muted );
	font-weight: 600;
	text-decoration: none;
	transition: background 0.15s ease, color 0.15s ease;
}
.m365mc-nav-item:hover { background: #f3f5f8; color: var( --m365-text ); }
.m365mc-nav-item.is-active { background: var( --m365-accent-soft ); color: var( --m365-accent ); }
.m365mc-nav-item .m365mc-icon { width: 18px; height: 18px; }

.m365mc-sidebar-foot {
	margin-top: 12px;
	padding-top: 14px;
	border-top: 1px solid var( --m365-border );
	display: flex;
	flex-direction: column;
	gap: 2px;
	font-size: 13px;
}
.m365mc-sidebar-user { font-weight: 600; color: var( --m365-text ); }
.m365mc-logout { color: var( --m365-accent ); text-decoration: none; }
.m365mc-logout:hover { text-decoration: underline; }

/* Hoofdkolom ------------------------------------------------------------- */
.m365mc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var( --m365-page ); }
.m365mc-topbar {
	padding: 18px 24px;
	background: var( --m365-card );
	border-bottom: 1px solid var( --m365-border );
}
.m365mc-page-title { margin: 0; font-size: 20px; font-weight: 700; color: var( --m365-text ); }
.m365mc-content { padding: 24px; flex: 1; }

/* Kaarten ---------------------------------------------------------------- */
.m365mc-dashboard .m365mc-card {
	background: var( --m365-card );
	border: 1px solid var( --m365-border );
	border-radius: var( --m365-radius );
	box-shadow: var( --m365-shadow );
	padding: 20px 24px;
	margin: 0 0 20px;
	max-width: none;
}
.m365mc-content h1 {
	font-size: 18px;
	font-weight: 700;
	margin: 0 0 16px;
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px;
}
.m365mc-content h1 .m365mc-header-action { margin-left: auto; }
.m365mc-content h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
.m365mc-content > .wrap { margin: 0; }

/* Statistiek-tegels ------------------------------------------------------ */
.m365mc-stats {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 230px, 1fr ) );
	grid-auto-rows: 1fr; /* alle rijen even hoog → alle tegels even groot */
	gap: 16px;
	margin-bottom: 20px;
}
.m365mc-stat {
	display: flex;
	align-items: center;
	gap: 14px;
	box-sizing: border-box;
	min-height: 92px;
	padding: 18px 20px;
	background: var( --m365-card );
	border: 1px solid var( --m365-border );
	border-radius: var( --m365-radius );
	box-shadow: var( --m365-shadow );
	text-decoration: none;
	color: var( --m365-text );
	transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
a.m365mc-stat:hover {
	border-color: var( --m365-accent );
	box-shadow: 0 4px 14px rgba( 53, 129, 202, 0.18 );
	transform: translateY( -1px );
}
.m365mc-stat-icon {
	width: 46px;
	height: 46px;
	flex-shrink: 0;
	display: grid;
	place-items: center;
	border-radius: 10px;
	background: var( --m365-accent-soft );
	color: var( --m365-accent );
}
.m365mc-stat-icon .m365mc-icon { width: 22px; height: 22px; }
.m365mc-stat-body { display: flex; flex-direction: column; }
.m365mc-stat-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.m365mc-stat-label { font-size: 13px; color: var( --m365-muted ); }

/* Login ------------------------------------------------------------------ */
.m365mc-login {
	max-width: 400px;
	margin: 40px auto;
	background: var( --m365-card );
	border: 1px solid var( --m365-border );
	border-radius: var( --m365-radius );
	box-shadow: var( --m365-shadow );
	padding: 32px 32px 28px;
}
.m365mc-login-logo { text-align: center; margin-bottom: 18px; }
.m365mc-login-logo img { max-height: 72px; max-width: 100%; width: auto; height: auto; }
.m365mc-login h2 { margin-top: 0; font-size: 20px; text-align: center; color: var( --m365-accent ); }
.m365mc-login > p.description { text-align: center; margin-bottom: 22px; }
.m365mc-login p { margin: 0 0 16px; }
.m365mc-login label { display: block; margin-bottom: 6px; font-weight: 600; }
.m365mc-login .regular-text { width: 100%; }
.m365mc-login-remember label { font-weight: 400; color: var( --m365-muted ); }
.m365mc-login .button-primary { width: 100%; padding: 11px; font-size: 15px; }
.m365mc-login .m365mc-sso { margin-bottom: 18px; }
.m365mc-login .m365mc-sso-button { width: 100%; padding: 12px; font-size: 15px; text-align: center; }
.m365mc-login-divider { display: flex; align-items: center; text-align: center; color: var( --m365-muted ); font-size: 12px; margin: 18px 0; }
.m365mc-login-divider::before,
.m365mc-login-divider::after { content: ""; flex: 1; border-bottom: 1px solid var( --m365-border ); }
.m365mc-login-divider span { padding: 0 12px; }

/* Knoppen ---------------------------------------------------------------- */
.m365mc-dashboard .button {
	display: inline-block;
	padding: 8px 16px;
	border: 1px solid var( --m365-border );
	border-radius: 8px;
	background: var( --m365-card );
	color: var( --m365-text );
	font-size: 13px;
	font-weight: 600;
	line-height: 1.4;
	cursor: pointer;
	text-decoration: none;
	vertical-align: middle;
	transition: all 0.15s ease;
}
.m365mc-dashboard .button:hover { border-color: var( --m365-accent ); color: var( --m365-accent ); }
.m365mc-dashboard .button-primary {
	background: var( --m365-accent );
	border-color: var( --m365-accent );
	color: #fff;
	box-shadow: 0 2px 6px rgba( 53, 129, 202, 0.3 );
}
.m365mc-dashboard .button-primary:hover { background: var( --m365-accent-dark ); border-color: var( --m365-accent-dark ); color: #fff; }
.m365mc-dashboard .button-link-delete { background: none; border-color: transparent; color: #d63638; box-shadow: none; }
.m365mc-dashboard .button-link-delete:hover { background: #fdeced; border-color: transparent; color: #b32d2e; }
.m365mc-dashboard .button-link-add { background: none; border-color: transparent; color: var( --m365-accent ); box-shadow: none; }
.m365mc-dashboard .button-link-add:hover { background: var( --m365-accent-soft ); border-color: transparent; color: var( --m365-accent-dark ); }
.m365mc-dashboard .page-title-action {
	font-size: 12px;
	font-weight: 600;
	padding: 6px 14px;
	border-radius: 999px;
	border-color: var( --m365-accent );
	color: var( --m365-accent );
}
.m365mc-dashboard .page-title-action:hover { background: var( --m365-accent ); color: #fff; }

/* Formuliervelden -------------------------------------------------------- */
.m365mc-dashboard input[type="text"],
.m365mc-dashboard input[type="password"],
.m365mc-dashboard input[type="search"],
.m365mc-dashboard select,
.m365mc-dashboard textarea {
	padding: 9px 12px;
	border: 1px solid #cfd3da;
	border-radius: 8px;
	font-size: 14px;
	background: #fff;
	color: var( --m365-text );
	max-width: 100%;        /* nooit breder dan de container (mobiel) */
	box-sizing: border-box;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
/* Lange opties (mailgroepen) niet de selectbreedte laten opblazen. */
.m365mc-dashboard select { text-overflow: ellipsis; }
.m365mc-dashboard input:focus,
.m365mc-dashboard select:focus,
.m365mc-dashboard textarea:focus {
	outline: none;
	border-color: var( --m365-accent );
	box-shadow: 0 0 0 3px rgba( 53, 129, 202, 0.15 );
}
.m365mc-dashboard .regular-text { width: 25em; max-width: 100%; }
.m365mc-dashboard .large-text { width: 100%; }
.m365mc-dashboard .description { color: var( --m365-muted ); font-size: 13px; }
.m365mc-dashboard label[for="m365mod-group"] { display: inline-block; margin-right: 10px; }

/* Tabellen --------------------------------------------------------------- */
.m365mc-dashboard .widefat {
	width: 100%;
	border-collapse: separate;
	border-spacing: 0;
	border: 1px solid var( --m365-border );
	border-radius: 10px;
	overflow: hidden;
	background: #fff;
}
.m365mc-dashboard .widefat th {
	padding: 11px 14px;
	background: #f8f9fb;
	color: var( --m365-muted );
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.4px;
	text-align: left;
	border-bottom: 1px solid var( --m365-border );
}
.m365mc-dashboard .widefat td {
	padding: 11px 14px;
	border-bottom: 1px solid #f0f1f4;
	text-align: left;
	vertical-align: middle;
}
.m365mc-dashboard .widefat th,
.m365mc-dashboard .widefat td { border-left: 0; border-right: 0; }
.m365mc-dashboard .widefat tbody tr:last-child td { border-bottom: none; }
.m365mc-dashboard .widefat tbody tr:hover { background: #f8fbff; }

/* Twee kolommen + ledenlijst --------------------------------------------- */
.m365mc-dashboard .m365mc-two-col { display: flex; gap: 28px; flex-wrap: wrap; }
.m365mc-dashboard .m365mc-two-col > div { flex: 1 1 320px; }
.m365mc-dashboard .m365mc-member-list { max-height: 440px; overflow-y: auto; overflow-x: auto; }
/* Brede tabellen scrollen horizontaal binnen hun kader i.p.v. de pagina te breken. */
.m365mc-dashboard #m365usr-list,
#m365dash-modal-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Rol-badge (eigenaar/lid) ----------------------------------------------- */
.m365mc-dashboard .m365mc-role {
	display: inline-block;
	font-size: 11px;
	font-weight: 600;
	padding: 1px 8px;
	border-radius: 10px;
	background: #eef0f3;
	color: var( --m365-muted );
	vertical-align: middle;
}
.m365mc-dashboard .m365mc-role-owner { background: #fff3cd; color: #664d03; }
.m365mc-dashboard .m365mc-role-on { background: #d1e7dd; color: #0f5132; }
.m365mc-dashboard .m365mc-role-off { background: #f8d7da; color: #842029; }

/* Ledenkop met "+ Lid toevoegen" */
.m365mc-dashboard .m365mc-members-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.m365mc-dashboard .m365mc-members-head h2 { margin: 0; }
.m365mc-dashboard .m365mc-add-plus { font-weight: 700; font-size: 16px; line-height: 1; }

/* Modal (lid toevoegen) */
.m365mc-modal { position: fixed; inset: 0; z-index: 100000; }
.m365mc-modal-backdrop { position: absolute; inset: 0; background: rgba( 16, 24, 40, 0.55 ); }
.m365mc-modal-box {
	position: relative;
	width: 520px;
	max-width: 92vw;
	margin: 8vh auto 0;
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 20px 60px rgba( 16, 24, 40, 0.35 );
	padding: 20px 24px;
	max-height: 80vh;
	overflow: auto;
}
.m365mc-modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.m365mc-modal-head h2 { margin: 0; font-size: 17px; }
.m365mc-modal-close { background: none; border: none; font-size: 26px; line-height: 1; cursor: pointer; color: var( --m365-muted ); padding: 0 4px; }
.m365mc-modal-close:hover { color: var( --m365-text ); }
.m365mc-modal-box .m365usr-pw { font-size: 14px; font-weight: 600; }
.m365mc-modal-foot { margin-top: 16px; display: flex; gap: 8px; justify-content: flex-end; }

/* Werkbalk boven de gebruikerslijst (filter + bulk-actie) */
.m365usr-toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; }
.m365usr-toolbar .regular-text { flex: 1; min-width: 220px; }
.m365usr-toolbar #m365usr-bulk-reset[disabled] { opacity: .55; cursor: not-allowed; }
.m365usr-bulk-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.m365usr-bulk-actions .button[disabled] { opacity: .55; cursor: not-allowed; }

/* Klikbare statistiektegel (opent een popup) */
.m365mc-stat-action { cursor: pointer; }
.m365mc-stat-action:hover { box-shadow: 0 4px 16px rgba( 16, 24, 40, 0.12 ); }
#m365dash-modal .check-column { width: 2.5em; text-align: center; vertical-align: middle; }
#m365dash-modal .m365mc-modal-box { width: 720px; }
#m365dash-bulk-delete[disabled] { opacity: .55; cursor: not-allowed; }
tr.m365dash-failed { background: #fbeaea !important; }
#m365usr-list .check-column { width: 2.5em; text-align: center; vertical-align: middle; }

/* Selectielijst in de "lid toevoegen"-modal */
.m365mc-dashboard .m365mod-staged-wrap,
.m365mc-modal .m365mod-staged-wrap { margin-top: 14px; border-top: 1px solid var( --m365-border, #e6e8ec ); padding-top: 12px; }
.m365mod-staged-title { font-size: 13px; margin: 0 0 8px; }
.m365mod-staged { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.m365mod-staged li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 10px; background: #f4f6f9; border-radius: 6px; }
.m365mod-staged li.m365mod-empty { background: none; padding: 0; }
.m365mod-unstage { border: none; background: none; color: #d63638; font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px; }
.m365mod-unstage:hover { color: #8a1f21; }

/* Modulelijst (fallback) ------------------------------------------------- */
.m365mc-dashboard .m365mc-modules { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 12px; }
.m365mc-dashboard .m365mc-modules li { margin: 0; }
.m365mc-dashboard .m365mc-modules a {
	display: block;
	padding: 14px 20px;
	background: #f8fbff;
	border: 1px solid var( --m365-border );
	border-radius: 10px;
	font-weight: 600;
	text-decoration: none;
}
.m365mc-dashboard .m365mc-modules a:hover { border-color: var( --m365-accent ); }

/* Notices ---------------------------------------------------------------- */
.m365mc-dashboard .notice {
	background: #fff;
	border: 1px solid var( --m365-border );
	border-left: 4px solid #72aee6;
	border-radius: 8px;
	padding: 10px 14px;
	margin: 12px 0;
}
.m365mc-dashboard .notice p { margin: 0.3em 0; }
.m365mc-dashboard .notice-success { border-left-color: #00a32a; background: #f3fbf4; }
.m365mc-dashboard .notice-error { border-left-color: #d63638; background: #fdf3f3; }
.m365mc-dashboard .notice-warning { border-left-color: #dba617; background: #fffaf0; }

/* Spinner ---------------------------------------------------------------- */
.m365mc-dashboard .spinner { display: none; }
.m365mc-dashboard .spinner.is-active {
	display: inline-block;
	width: 16px;
	height: 16px;
	margin-left: 8px;
	vertical-align: middle;
	border: 2px solid var( --m365-border );
	border-top-color: var( --m365-accent );
	border-radius: 50%;
	animation: m365mc-spin 0.7s linear infinite;
}
@keyframes m365mc-spin { to { transform: rotate( 360deg ); } }

/* Responsief ------------------------------------------------------------- */
@media ( max-width: 880px ) {
	.m365mc-app { flex-direction: column; min-height: 0; }
	.m365mc-sidebar { width: auto; border-right: none; border-bottom: 1px solid var( --m365-border ); }
	.m365mc-nav { flex-direction: row; flex-wrap: wrap; }
	.m365mc-nav-item { flex: 0 0 auto; }
	.m365mc-sidebar-foot { flex-direction: row; justify-content: space-between; align-items: center; }
}

/* Telefoon --------------------------------------------------------------- */
@media ( max-width: 600px ) {
	body.m365mc-fullscreen .m365mc-dashboard { padding: 0 10px; }
	.m365mc-dashboard { margin: 12px auto; }

	.m365mc-topbar { padding: 14px 16px; }
	.m365mc-page-title { font-size: 18px; }
	.m365mc-content { padding: 16px; }
	.m365mc-dashboard .m365mc-card { padding: 16px; margin-bottom: 16px; }

	/* Eén tegel per rij, wat compacter. */
	.m365mc-stats { grid-template-columns: 1fr; gap: 12px; }

	/* De keuzelijsten (inline min-width 320/380px) mogen krimpen. */
	.m365mc-dashboard #m365usr-school,
	.m365mc-dashboard #m365mod-group { min-width: 0 !important; width: 100%; }
	.m365mc-dashboard .regular-text { width: 100%; }

	/* Werkbalk en knoppenrijen netjes onder elkaar. */
	.m365usr-toolbar { align-items: stretch; }
	.m365usr-toolbar .regular-text { min-width: 0; }
	.m365usr-bulk-actions .button { flex: 1 1 auto; text-align: center; }
	.m365usr-modal-foot,
	.m365mc-modal-foot { flex-wrap: wrap; }

	/* Modals bijna schermvullend. */
	.m365mc-modal-box,
	#m365dash-modal .m365mc-modal-box {
		width: 96vw;
		max-width: 96vw;
		margin-top: 4vh;
		max-height: 90vh;
		padding: 16px;
	}

	/* Titel + actieknop onder elkaar i.p.v. uitgelijnd. */
	.m365mc-content h1 .m365mc-header-action,
	.m365mc-content h1 .page-title-action { margin-left: 0; }
}
