/*
 * This file is part of the Rapid Application Platform
 * Author: Salaheddin AbuEin
 * Copyright (C) 2026 Rapid Information Systems. All rights reserved.
 *
 * Conventions
 * -----------
 * The "flexy" class is the legacy page-shell hook. It is kept for backwards
 * compatibility with existing JSPs and is treated here as both a layout
 * primitive (vertical flex container) and a namespace.
 *
 * Component patterns:
 *   .flexy form / .flexy .info     — card surface
 *   .columnUserInput + .columnUserIcon — input with leading icon
 *   .flexy section                 — nav tile
 *   .message                       — alert / status banner
 *   .subBar                        — secondary text bar (version, links)
 */

/* ---------- Reset (lean) ---------- */
*,
*::before,
*::after {
	box-sizing: border-box;
}

html,
body {
	height: 100%;
}

body {
	margin: 0;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

img,
svg {
	display: block;
	max-width: 100%;
}

button,
input,
select,
textarea {
	font: inherit;
	color: inherit;
}

button {
	background: none;
	border: 0;
	padding: 0;
	cursor: pointer;
}

a {
	color: inherit;
}

:focus {
	outline: none;
}

:focus-visible {
	outline: 2px solid var(--ring);
	outline-offset: 2px;
	border-radius: 2px;
}

/* ---------- Design tokens ---------- */
:root {
	color-scheme: light;
	/* Brand */
	--accent: hsl(250, 88%, 32%);
	--accent-hover: hsl(250, 78%, 26%);
	--accent-soft: hsl(250, 88%, 96%);
	--accent-fg: #ffffff;
	/* Surfaces & text */
	--bg: #f5f6fa;
	--surface: #ffffff;
	--surface-alt: #f3f2f1;
	--text: #1a1c23;
	--text-muted: #5a606b;
	--text-subtle: #858a93;
	--border: #e2e4ea;
	--border-strong: #c5c9d3;
	/* Status */
	--danger: #c2271c;
	--danger-soft: #fdeceb;
	--success: #1f7a4d;
	--success-soft: #e7f5ee;
	--warning: #b75c00;
	--warning-soft: #fdf2e3;
	/* Effects & geometry */
	--ring: var(--accent);
	--shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
	--shadow-md: 0 6px 18px rgba(15, 23, 42, .08), 0 2px 6px rgba(15, 23, 42, .05);
	--radius-sm: 6px;
	--radius-md: 10px;
	--radius-lg: 14px;
	--container-narrow: 28rem;
	--container-wide: 64rem;
	/* Type */
	--font-sans: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
	color-scheme: dark;
	--accent: hsl(250, 90%, 72%);
	--accent-hover: hsl(250, 95%, 80%);
	--accent-fg: #0f1117;
	/* dark text on the lighter accent button */
	--ring: var(--accent);

	/* Status — current values are tuned for light surfaces only */
	--danger: #ff7a73;
	--danger-soft: #3a1c1a;
	--success: #5cc488;
	--success-soft: #14321f;
	--warning: #f3a04a;
	--warning-soft: #3a2716;

	--bg: #0f1117;
	--surface: #181a22;
	--surface-alt: #20232c;
	--text: #e8eaf0;
	--text-muted: #a8aebd;
	--text-subtle: #7e8595;
	--border: #2a2e3a;
	--border-strong: #3a3f4d;
	--accent-soft: hsl(250, 30%, 18%);
	--shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
	--shadow-md: 0 6px 18px rgba(0, 0, 0, .35);
}

/* No-JS fallback only. The inline head script sets data-theme before first
   paint, so once a theme has been chosen this must not override it: without
   :not() a bare :root here sits later in the file at equal specificity and
   wins, which makes light unselectable on an OS-dark device. */
@media (prefers-color-scheme : dark) {
	:root:not([data-theme]) {
		color-scheme: dark;
		--accent: hsl(250, 90%, 72%);
		--accent-hover: hsl(250, 95%, 80%);
		--accent-fg: #0f1117;
		/* dark text on the lighter accent button */
		--ring: var(--accent);

		/* Status — current values are tuned for light surfaces only */
		--danger: #ff7a73;
		--danger-soft: #3a1c1a;
		--success: #5cc488;
		--success-soft: #14321f;
		--warning: #f3a04a;
		--warning-soft: #3a2716;

		--bg: #0f1117;
		--surface: #181a22;
		--surface-alt: #20232c;
		--text: #e8eaf0;
		--text-muted: #a8aebd;
		--text-subtle: #7e8595;
		--border: #2a2e3a;
		--border-strong: #3a3f4d;
		--accent-soft: hsl(250, 30%, 18%);
		--shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
		--shadow-md: 0 6px 18px rgba(0, 0, 0, .35);
	}
}


/* ---------- Page shell ---------- */
body {
	font-family: var(--font-sans);
	font-size: 16px;
	color: var(--text);
	background: linear-gradient(180deg, var(--bg) 0%, var(--surface-alt) 100%);
	background-attachment: fixed;
	min-height: 100vh;
	min-height: 100dvh;
}

body.flexy {
	display: flex;
	flex-direction: column;
	align-items: stretch;
}

.flexy {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 1rem;
}

.flexy.row {
	flex-direction: row;
	flex-wrap: wrap;
}

/* ---------- Header ---------- */
body.flexy>header,
header.flexy {
	width: 100%;
	padding: 1rem clamp(1rem, 4vw, 2.5rem);
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	box-shadow: var(--shadow-sm);
	flex-direction: row;
	justify-content: space-between;
	align-items: center;
	position: sticky;
	top: 0;
	z-index: 10;
	gap: 1rem;
}

/* Logo */
.rapid-logo,
figure.rapid-logo,
figure.rapid-logo>a {
	display: inline-flex;
	align-items: center;
	color: var(--accent);
	text-decoration: none;
	margin: 0;
}

.rapid-logo svg,
figure.rapid-logo svg {
	width: 9.5rem;
	max-width: 100%;
	height: auto;
}

/* Header sub-bar */
.subBar {
	flex-direction: row;
	align-items: center;
	gap: 1rem;
	color: var(--text-muted);
	font-size: .875rem;
}

.subBar .versionColumn {
	white-space: nowrap;
}

/* ---------- Body ---------- */
body.flexy>.body,
.flexy>.body {
	width: 100%;
	flex: 1 0 auto;
	padding: clamp(2rem, 6vw, 4rem) 1rem;
	align-items: center;
	justify-content: flex-start;
	gap: 2rem;
}

.columnMiddle {
	width: 100%;
	max-width: var(--container-narrow);
	align-items: stretch;
	gap: 1.25rem;
}

.flexy.row.columnMiddle {
	flex-direction: row;
	flex-wrap: wrap;
	justify-content: center;
	max-width: var(--container-wide);
}

/* ---------- Card surfaces ---------- */
.flexy form,
.flexy .info {
	width: 100%;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-md);
	padding: clamp(1.25rem, 3vw, 2rem);
	gap: 1rem;
	align-items: stretch;
}

.flexy .info {
	text-align: center;
	align-items: center;
	gap: .75rem;
}

.flexy .info h1 {
	margin: 0 0 .25rem;
	font-size: 1.5rem;
	color: var(--text);
}

.flexy .info p {
	margin: 0;
	color: var(--text-muted);
}

/* ---------- Forms ---------- */
.columnUserInput {
	position: relative;
	display: block;
	width: 100%;
}

.columnUserIcon {
	position: absolute;
	top: 0;
	left: 0;
	bottom: 0;
	width: 3rem;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
	color: var(--text-subtle);
	border-right: 1px solid var(--border);
	border-radius: var(--radius-md) 0 0 var(--radius-md);
	background: var(--surface-alt);
}

.flexy input[type="text"],
.flexy input[type="password"],
.flexy input[type="email"],
.flexy input[type="search"] {
	width: 100%;
	height: 3rem;
	padding: 0 1rem 0 4rem;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-md);
	font-size: 1rem;
	transition: border-color .15s, box-shadow .15s;
}

.flexy input[type="search"] {
	padding-left: 1rem;
}

.flexy input::placeholder {
	color: var(--text-subtle);
}

.flexy input:hover {
	border-color: var(--accent);
}

.flexy input:focus,
.flexy input:focus-visible {
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-soft);
	outline: none;
}

.flexy input::-ms-clear {
	display: none;
}

/* ---------- Buttons ---------- */
.flexy button:not(.theme-toggle),
.flexy a.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: .5rem;
	height: 3rem;
	padding: 0 1.25rem;
	font-size: .9375rem;
	font-weight: 600;
	color: var(--accent-fg);
	background: var(--accent);
	border: 1px solid var(--accent);
	border-radius: var(--radius-md);
	cursor: pointer;
	text-decoration: none;
	transition: background-color .15s, box-shadow .15s, transform .05s;
}

.flexy button:hover,
.flexy a.btn:hover {
	background: var(--accent-hover);
	border-color: var(--accent-hover);
	color: var(--accent-fg);
}

.flexy button:active {
	transform: translateY(1px);
}

.flexy button:focus-visible,
.flexy a.btn:focus-visible {
	box-shadow: 0 0 0 3px var(--accent-soft);
}

.flexy button[disabled] {
	background: var(--surface-alt);
	border-color: var(--border);
	color: var(--text-subtle);
	cursor: not-allowed;
}

/* Secondary — auto-applied to <button type="button"> next to a submit, and to .btn-secondary */
.flexy form .row>button[type="button"],
.flexy .btn-secondary {
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border-strong);
}

.flexy form .row>button[type="button"]:hover,
.flexy .btn-secondary:hover {
	background: var(--surface-alt);
	border-color: var(--accent);
	color: var(--accent);
}

/* Add-to-home-screen pill */
.flexy .addButton {
	display: none;
	margin: 0 auto 1rem;
	background: var(--surface);
	color: var(--accent);
	border-color: var(--border-strong);
}

.flexy .addButton:hover,
.flexy .addButton:focus-visible {
	background: var(--accent-soft);
	border-color: var(--accent);
	color: var(--accent);
}

/* ---------- Messages / alerts ---------- */
.flexy .message {
	width: 100%;
	max-width: var(--container-narrow);
	margin: 0;
	padding: .875rem 1rem;
	border-radius: var(--radius-md);
	background: var(--danger-soft);
	color: var(--danger);
	border-left: 4px solid var(--danger);
	font-size: .9375rem;
	text-align: center;
}

.flexy .message a {
	color: inherit;
	font-weight: 600;
}

/* ---------- Nav tiles (index.jsp) ---------- */
.flexy section {
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 100%;
	max-width: 16rem;
	height: fit-content;
	padding: 1.5rem;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-sm);
	transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
	gap: .75rem;
}

.flexy section:hover,
.flexy section:focus-within {
	transform: translateY(-2px);
	box-shadow: var(--shadow-md);
	border-color: var(--accent);
}

.flexy section a {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: .75rem;
	text-decoration: none;
	color: var(--text);
	font-size: 1rem;
	font-weight: 600;
	width: 100%;
}

.flexy section:has(.apps) {
	max-width: 24rem;
	align-items: stretch;
}

/* FontAwesome stack inside tiles */
.flexy .fa-stack {
	font-size: 2rem;
	width: 4em;
	height: 4em;
	line-height: 4em;
}

.flexy .fa-stack i.fa-stack-2x {
	bottom: .5em;
	color: var(--accent-soft);
	transition: color .15s;
}

.flexy .fa-stack i.fa-stack-1x {
	color: var(--accent);
	transition: transform .15s, color .15s;
}

.flexy section:hover .fa-stack i.fa-stack-2x,
.flexy section:focus-within .fa-stack i.fa-stack-2x {
	color: var(--accent);
}

.flexy section:hover .fa-stack i.fa-stack-1x,
.flexy section:focus-within .fa-stack i.fa-stack-1x {
	color: var(--accent-fg);
	transform: scale(1.05);
}

/* ---------- Apps list (index.jsp) ---------- */
.flexy .apps {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: .75rem;
	width: 100%;
}

.flexy .apps b {
	display: block;
	text-align: center;
	color: var(--text-muted);
	font-weight: 500;
	padding: .5rem;
}

.flexy .apps ul,
.flexy .apps ol {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: .375rem;
	max-height: 50vh;
	overflow-y: auto;
}

.flexy .apps li {
	background: var(--surface-alt);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	transition: border-color .12s, background-color .12s;
}

.flexy .apps li:hover {
	border-color: var(--accent);
	background: var(--accent-soft);
}

.flexy .apps li a {
	display: block;
	padding: .625rem .875rem;
	color: var(--text);
	text-decoration: none;
	font-weight: 500;
}

.flexy .apps li a:hover,
.flexy .apps li a:focus-visible {
	color: var(--accent);
}

.flexy .apps li a.appCached {
	font-style: italic;
}

.flexy .apps li a.appCached::after {
	content: "cached";
	margin-left: .5rem;
	padding: .1rem .4rem;
	font-size: .75rem;
	font-style: normal;
	font-weight: 500;
	background: var(--accent-soft);
	color: var(--accent);
	border-radius: 999px;
	vertical-align: middle;
}

.flexy .apps #search-apps {
	height: 2.5rem;
	padding: 0 .875rem;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-sm);
	width: 100%;
}

/* ---------- Bottom links bar inside columnMiddle ---------- */
.columnMiddle>.subBar {
	margin-top: 1rem;
	flex-direction: row;
	flex-wrap: wrap;
	justify-content: center;
	gap: 1.5rem;
	color: var(--text-muted);
	border-top: 1px solid var(--border);
	padding-top: 1rem;
	width: 100%;
}

.columnMiddle>.subBar .link a {
	color: var(--accent);
	font-weight: 600;
	text-decoration: none;
	transition: color .12s ease;
}

.columnMiddle>.subBar .link a:hover,
.columnMiddle>.subBar .link a:focus-visible {
	color: var(--accent-hover);
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* ---------- 2FA verifying state ---------- */
.flexy .getting-verified {
	display: none;
	flex-direction: column;
	align-items: center;
	gap: 1rem;
	color: var(--text-muted);
	font-size: 1.125rem;
	padding: 2rem 1rem;
}

.flexy .getting-verified .glyph {
	font-size: 2.5rem;
	color: var(--accent);
}

.flexy .columnMiddle.verifying {
	display: none;
}

.flexy .getting-verified.verifying {
	display: flex;
}

#other-methods {
	width: 100%;
	margin: .5rem 0 0;
	text-align: center;
}
 
#other-methods > summary {
	cursor: pointer;
	color: var(--accent);
	font-weight: 600;
	font-size: .9375rem;
	list-style: none;          /* hide the default disclosure triangle */
	padding: .25rem 0;
}
 
#other-methods > summary::-webkit-details-marker {
	display: none;             /* Safari / older Chrome */
}
 
#other-methods > summary:hover,
#other-methods > summary:focus-visible {
	text-decoration: underline;
}
 
#other-methods > button {
	margin: .625rem auto 0;
}
 
#other-methods .help {
	margin: .625rem 0 0;
	color: var(--text-muted);
	font-size: .875rem;
}
 
.card-footer-links {
	margin: 1rem 0 0;
	font-size: .9375rem;
	text-align: center;
}
 
.card-footer-links a {
	color: var(--text-muted);
}
 
.card-footer-links a:hover,
.card-footer-links a:focus-visible {
	color: var(--accent);
	text-decoration: underline;
}
 
 
/* ---- 3. Message severity --------------------------------------------- */
/*  The page now emits .message .message-error / -success / -info so the
    adapter's messageType survives. Starting point only — align these with
    whatever .alert-error / .alert-success / .alert-info already do in
    styles/mentoring/login.css, and check both themes.                     */
 
.message.message-error {
	color: #b3261e;
}
 
.message.message-success {
	color: #1b5e20;
}
 
.message.message-info {
	color: var(--text-muted);
}
 
[data-theme="dark"] .message.message-error {
	color: #f2b8b5;
}
 
[data-theme="dark"] .message.message-success {
	color: #a5d6a7;
}

pre {
	white-space: pre-wrap;
	text-wrap-style: pretty;
}

/* ---------- Support page (signed-in but unauthorised) ---------- */
.who {
	background: var(--surface-alt);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	padding: .875rem 1rem;
	margin: 1rem 0;
	color: var(--text);
	font-size: .9375rem;
	text-align: left;
	width: 100%;
}

.who div {
	margin: .15rem 0;
}

.loginAlt {
	text-align: center;
}

.actions {
	display: flex;
	flex-wrap: wrap;
	gap: .75rem;
	margin-top: 1rem;
	justify-content: center;
}

.actions a {
	display: inline-flex;
	align-items: center;
	padding: .625rem 1rem;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-md);
	text-decoration: none;
	color: var(--text);
	font-weight: 500;
	transition: border-color .12s, color .12s, background-color .12s;
}

.actions a:hover,
.actions a:focus-visible {
	border-color: var(--accent);
	color: var(--accent);
	background: var(--accent-soft);
}

/* ---------- Legacy hooks kept for compatibility ---------- */
.midTitle {
	display: none;
}

/* superseded by header */
.image {
	display: none;
}

/* old logo box, superseded by .rapid-logo */

/* Offline state — index.jsp toggles `offline` on <body> */
body.offline .requiresOnline {
	display: none !important;
}

/* ---------- Responsive ---------- */
@media (max-width : 640px) {
	body.flexy>header {
		padding: .75rem 1rem;
	}

	.rapid-logo svg,
	figure.rapid-logo svg {
		width: 7.5rem;
	}

	.flexy section {
		max-width: 100%;
	}

	body.flexy>.body {
		padding: 1.5rem .75rem;
	}
}

/* ---------- Theme toggle (header pill) ---------- */
button.theme-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.5rem;
	height: 2.5rem;
	padding: 0;
	/* add this */
	flex: 0 0 auto;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: var(--surface);
	color: var(--text-muted);
	cursor: pointer;
	transition: color .15s, border-color .15s, background-color .15s,
		transform .05s;
}

button.theme-toggle:hover,
button.theme-toggle:focus-visible {
	color: var(--accent);
	border-color: var(--accent);
	background: var(--accent-soft);
}

button.theme-toggle:active {
	transform: scale(.96);
}

.theme-icon {
	display: inline-block;
	width: 1.25rem;
	height: 1.25rem;
	background-color: currentColor;
	-webkit-mask-image: url('../images/moon.svg');
	mask-image: url('../images/moon.svg');
	-webkit-mask-size: contain;
	mask-size: contain;
	-webkit-mask-repeat: no-repeat;
	mask-repeat: no-repeat;
	-webkit-mask-position: center;
	mask-position: center;
}

[data-theme="dark"] .theme-icon {
	-webkit-mask-image: url('../images/sun.svg');
	mask-image: url('../images/sun.svg');
}

@media print {
	body {
		background: #fff;
	}

	body.flexy>header,
	.columnMiddle>.subBar {
		display: none;
	}
}