/*
* global.css
* styles for the entire application
*/

/* ------- Color Scheme ------- */
:root {
	/* surfaces */
	--bg: #faf8f4; /* background color */
	--surface: #fff; /* main surface color */
	--surface-2: #f5f2eb;
	--surface-3: #ece8de;

	/* ink */
	--ink: #1a1a1a; /* main text color */
	--ink-2: #3d3a35;
	--muted: #8a8478; /* muted text color */
	--muted-2: #b5afa1;

	/* lines */
	--line: #e5e0d4;
	--line-strong: #cfc8b8;

	/* accent (warm coral) */
	--accent: oklch(62% 0.14 38deg);
	--accent-ink: oklch(45% 0.14 38deg);
	--accent-soft: oklch(95% 0.035 38deg);

	/* priorities */
	--pri-urgent: oklch(55% 0.18 25deg);

	/* status */
	--st-open: oklch(55% 0.08 250deg);
	--st-prog: oklch(62% 0.12 70deg);
	--st-resolved: oklch(55% 0.1 150deg);
	--st-closed: oklch(55% 0.02 80deg);

	/* overlays & shapes */
	--pill: 999rem;
	--scrim: #0e0d0c66;
	--scrim-light: #0e0d0c44;

	/* feedback */
	--danger: #d93025;
	--danger-bg: #fce8e6;

	/* type */
	--sans: -apple-system, blinkmacsystemfont, 'Segoe UI', roboto, 'Helvetica Neue', helvetica, arial, sans-serif;
	--mono: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Menlo', consolas, monospace;

	/* layout */
	--sidebar-w: clamp(10rem, 18vw, 15.714rem);
	--divider-w: 0.429rem;

	/* radii */
	--r-1: 0.286rem;
	--r-2: 0.429rem;
	--r-3: 0.714rem;

	/* shadow */
	--shadow-1: 0 0.071rem 0 #00000008, 0 0.071rem 0.143rem #00000008;
	--shadow-2: 0 0.071rem 0 #00000008, 0 0.286rem 1.143rem #00000010;
	--shadow-pop: 0 0.071rem 0 #00000010, 0 0.714rem 2.857rem #0000001f;
}

* {
	box-sizing: border-box;
}

/* font size for the root element */
html {
	font-size: 87.5%;
	color-scheme: light;
}

html,
body {
	margin: 0;
	padding: 0;
	background: var(--bg);
	color: var(--ink);
	font-family: var(--sans);
	font-size: 1rem;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizelegibility;
}

/* links */
a {
	color: inherit;
	text-decoration: none;
}

button {
	font: inherit;
	color: inherit;
}

/* ------- typographic ------- */

.h-2 {
	font-size: 1.143rem;
	font-weight: 600;
	letter-spacing: -0.005em;
}

.muted {
	color: var(--muted);
}

/* ------- small utilities ------- */
.redirect-page {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 100vh;
}

.optional-label {
	font-weight: 400;
	color: var(--muted);
}

/* ------- brand logo ------- */

/*
 * Allegro mark from frontend/imgs/file.svg.
 * Used on login, signup, teams, and tracker.
 */

.logo {
	display: block;
	width: 1.714rem;
	height: 1.714rem;
	flex: 0 0 auto;
	object-fit: contain;
}

/* ------- buttons ------- */
.btn {
	display: inline-flex;
	align-items: center;
	gap: 0.429rem;
	background: var(--surface);
	border: 0.071rem solid var(--line-strong);
	color: var(--ink);
	padding: 0.5rem 0.857rem;
	border-radius: var(--r-2);
	font-size: 0.929rem;
	font-weight: 500;
	cursor: pointer;
	transition:
		background 0.12s,
		border-color 0.12s,
		transform 0.04s;
	white-space: nowrap;
}

.btn:hover {
	background: var(--surface-2);
	border-color: var(--ink-2);
}

.btn:active {
	transform: translateY(0.036rem);
}

.btn.primary {
	background: var(--ink);
	color: #f7f4ee;
	border-color: var(--ink);
}

.btn.primary:hover {
	background: #000;
	border-color: #000;
}

.btn.ghost {
	background: transparent;
	border-color: transparent;
}

.btn.ghost:hover {
	background: var(--surface-2);
	border-color: var(--line);
}

.btn.sm {
	padding: 0.286rem 0.571rem;
	font-size: 0.857rem;
}

.btn.icon {
	padding: 0.429rem;
	aspect-ratio: 1;
	justify-content: center;
}

.btn[disabled] {
	opacity: 0.4;
	cursor: not-allowed;
}

.btn[hidden] {
	display: none !important;
}

/* ------- inputs ------- */
.input,
.textarea,
select.input {
	width: 100%;
	background: var(--surface);
	border: 0.071rem solid var(--line-strong);
	border-radius: var(--r-2);
	padding: 0.643rem 0.786rem;
	font-size: 1rem;
	font-family: var(--sans);
	color: var(--ink);
	transition:
		border-color 0.12s,
		box-shadow 0.12s;
}

.textarea {
	resize: vertical;
	min-height: 7.143rem;
	line-height: 1.55;
}

.input:focus,
.input:focus-visible,
.textarea:focus,
.textarea:focus-visible,
select.input:focus,
select.input:focus-visible {
	outline: none;
	border-color: var(--ink);
	box-shadow: 0 0 0 0.214rem #00000010;
}

.input::placeholder,
.textarea::placeholder {
	color: var(--muted-2);
}

.field {
	margin-bottom: 1rem;
}

.field > label {
	display: block;
	font-size: 0.893rem;
	font-weight: 500;
	margin-bottom: 0.429rem;
	color: var(--ink-2);
}

.field .hint {
	font-size: 0.857rem;
	color: var(--muted);
	margin-top: 0.286rem;
}

.field .req {
	color: var(--accent-ink);
}

.input.sm,
select.input.sm {
	padding: 0.357rem 0.571rem;
	font-size: 0.857rem;
}

/* ------- chips ------- */

.chip {
	width: fit-content;
	display: inline-flex;
	align-items: center;
	gap: 0.286rem;
	font-size: 0.821rem;
	font-weight: 500;
	padding: 0.143rem 0.571rem;
	border-radius: var(--pill);
	background: var(--surface-2);
	color: var(--ink-2);
	border: 0.071rem solid var(--line);
	white-space: nowrap;
	line-height: 1.7;
}

.chip.sm {
	font-size: 0.75rem;
	padding: 0.071rem 0.429rem;
	line-height: 1.5;
}

.chip.st-open {
	color: var(--st-open);
	background: oklch(97% 0.015 250deg);
	border-color: oklch(88% 0.03 250deg);
}

.chip.st-prog {
	color: var(--st-prog);
	background: oklch(97% 0.025 70deg);
	border-color: oklch(88% 0.05 70deg);
}

.chip.st-resolved {
	color: var(--st-resolved);
	background: oklch(97% 0.02 150deg);
	border-color: oklch(88% 0.04 150deg);
}

.chip.st-closed {
	color: var(--st-closed);
	background: var(--surface-2);
}

/* ------- modal ------- */
.backdrop {
	position: fixed;
	inset: 0;
	background: var(--scrim);
	display: none;
	align-items: center;
	justify-content: center;
	z-index: 100;
	backdrop-filter: blur(0.143rem);
}

.backdrop.open {
	display: flex;
}

.modal {
	background: var(--surface);
	border-radius: var(--r-3);
	box-shadow: var(--shadow-pop);
	width: min(40rem, 92vw);
	max-height: 92vh;
	overflow: auto;
	border: 0.071rem solid var(--line);
}

.modal-head {
	padding: 1.286rem 1.571rem 0.429rem;
}

.modal-head h3 {
	margin: 0 0 0.143rem;
	font-size: 1.286rem;
	font-weight: 600;
}

.modal-head p {
	margin: 0;
	color: var(--muted);
	font-size: 0.929rem;
}

.modal-body {
	padding: 1rem 1.571rem 0.429rem;
}

.modal-foot {
	padding: 0.857rem 1.571rem 1.286rem;
	display: flex;
	gap: 0.571rem;
	justify-content: flex-end;
}

.modal-small {
	max-width: 28.571rem;
}

/* ------- dropzone ------- */
.dropzone {
	border: 0.071rem dashed var(--line-strong);
	border-radius: var(--r-2);
	padding: 1.143rem;
	text-align: center;
	background: var(--surface-2);
	color: var(--muted);
	font-size: 0.929rem;
	cursor: pointer;
	transition:
		background 0.12s,
		border-color 0.12s;
}

.dropzone:hover,
.dropzone.drag {
	background: var(--accent-soft);
	border-color: var(--accent);
	color: var(--accent-ink);
}

.dropzone .browse {
	text-decoration: underline;
	color: var(--ink);
	cursor: pointer;
}

.dropzone .small {
	display: block;
	font-family: var(--mono);
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	margin-top: 0.429rem;
	color: var(--muted-2);
}

.file-chip {
	display: inline-flex;
	align-items: center;
	gap: 0.429rem;
	font-family: var(--mono);
	font-size: 0.821rem;
	background: var(--surface-2);
	border: 0.071rem solid var(--line);
	padding: 0.286rem 0.571rem;
	border-radius: var(--r-1);
	margin: 0.286rem 0.286rem 0 0;
}

.file-chip .x {
	cursor: pointer;
	color: var(--muted);
	font-size: 1rem;
	line-height: 1;
}

.file-chip .x:hover {
	color: var(--ink);
}

/* ------- toast ------- */
.toast {
	position: fixed;
	right: 1.429rem;
	bottom: 1.429rem;
	background: var(--ink);
	color: #f7f4ee;
	border-radius: var(--r-2);
	padding: 0.714rem 1rem;
	font-size: 0.929rem;
	box-shadow: var(--shadow-pop);
	opacity: 0;
	transform: translateY(0.571rem);
	transition:
		opacity 0.2s,
		transform 0.2s;
	pointer-events: none;
	z-index: 200;
}

.toast.show {
	opacity: 1;
	transform: translateY(0);
}

/* ------- avatar ------- */
.avatar {
	width: 2rem;
	height: 2rem;
	border-radius: 50%;
	background: var(--surface-3);
	color: var(--ink-2);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 0.786rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	border: 0.071rem solid var(--line);
}

.avatar.sm {
	width: 1.571rem;
	height: 1.571rem;
	font-size: 0.679rem;
}

/* ------- user menu (teams + tracker topbar avatar) ------- */
.user-switch {
	position: relative; /* anchor for .user-dropdown */
}

.user-avatar {
	padding: 0;
	font: inherit;
	cursor: pointer; /* button styled as .avatar circle */
}

.user-avatar:hover {
	background: var(--surface-2);
}

.user-dropdown {
	position: absolute;
	top: calc(100% + 0.286rem);
	right: 0; /* align panel to top-right avatar */
	background: var(--surface);
	border: 0.071rem solid var(--line);
	border-radius: var(--r-2);
	box-shadow: var(--shadow-pop);
	min-width: min(10rem, 80vw);
	padding: 0.286rem;
	display: none;
	z-index: 20;
}

.user-dropdown.open {
	display: block; /* toggled by helpers.js */
}

.user-dropdown .item {
	display: block;
	width: 100%;
	padding: 0.5rem 0.714rem;
	border: none;
	border-radius: 0.286rem;
	background: transparent;
	font: inherit;
	font-size: 0.929rem;
	color: var(--ink);
	text-align: left;
	cursor: pointer;
}

.user-dropdown .item:hover {
	background: var(--surface-2);
}

/* gentle focus ring */
:focus-visible {
	outline: 0.143rem solid var(--ink);
	outline-offset: 0.143rem;
	border-radius: 0.143rem;
}

/* ===== Dark Mode ====== */

/*
* — applied by toggling .dark on <html>
*   The FOUC-prevention inline script in each page reads
*   localStorage('theme') and sets this class before paint.
*/
html.dark {
	color-scheme: dark;

	--bg: #14130f;
	--surface: #1c1a16;
	--surface-2: #25221d;
	--surface-3: #2f2c25;
	--ink: #f0ece2;
	--ink-2: #c9c4b7;
	--muted: #8a8478;
	--muted-2: #5a554b;
	--line: #2a2722;
	--line-strong: #3a3733;
	--accent-soft: oklch(30% 0.05 38deg);
	--shadow-1: 0 0.071rem 0 #00000030, 0 0.071rem 0.143rem #00000040;
	--shadow-2: 0 0.071rem 0 #00000040, 0 0.286rem 1.143rem #00000050;
	--shadow-pop: 0 0.071rem 0 #00000040, 0 0.714rem 2.857rem #00000080;
}

/* Surfaces that use var(--ink) as background need inverted contrast in dark mode */
html.dark .btn.primary {
	background: #f0ece2;
	color: #1a1a1a;
	border-color: #f0ece2;
}

html.dark .btn.primary:hover {
	background: #fff;
	border-color: #fff;
}

html.dark .toast {
	background: #f0ece2;
	color: #1a1a1a;
}

html.dark .logo {
	filter: invert(1);
}

/* theme toggle icon (sun/moon) */
.theme-toggle::before {
	content: '☾';
	font-size: 1rem;
	line-height: 1;
}

html.dark .theme-toggle::before {
	content: '☀';
}

/* Shared full-page error state used when a page cannot load its primary data. */
.page-error {
	text-align: center;
	max-width: 27.143rem;
}

.page-error .glyph {
	width: 4rem;
	height: 4rem;
	margin: 0 auto 1.286rem;
	border: 0.071rem dashed var(--line-strong);
	border-radius: 0.857rem;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--muted-2);
	font-size: 1.714rem;
	background: var(--surface);
}

.page-error h2 {
	margin: 0 0 0.571rem;
	font-size: 1.357rem;
	font-weight: 600;
	letter-spacing: -0.01em;
}

.page-error p {
	margin: 0 0 1.429rem;
	color: var(--muted);
	font-size: 0.964rem;
	line-height: 1.55;
}

.page-error p code {
	font-family: var(--mono);
	font-size: 0.857rem;
	background: var(--surface-2);
	border: 0.071rem solid var(--line);
	border-radius: 0.286rem;
	padding: 0.071rem 0.357rem;
	color: var(--ink-2);
}

.page-error .pe-actions {
	display: flex;
	gap: 0.571rem;
	justify-content: center;
	margin-bottom: 1.286rem;
}

.page-error .pe-status {
	display: inline-flex;
	align-items: center;
	gap: 0.571rem;
	font-family: var(--mono);
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--muted-2);
	background: var(--surface-2);
	border: 0.071rem solid var(--line);
	border-radius: var(--pill);
	padding: 0.286rem 0.714rem;
}

.page-error .pe-status .code {
	color: var(--pri-urgent);
	font-weight: 700;
}

/* ------- form field error states ------- */
.input.invalid {
	border-color: var(--pri-urgent);
	box-shadow: 0 0 0 0.214rem oklch(55% 0.18 25deg / 12%);
}

.field-error {
	font-size: 0.857rem;
	color: var(--pri-urgent);
	margin-top: 0.286rem;
	display: flex;
	align-items: center;
	gap: 0.357rem;
	flex-wrap: wrap;
}

.field-error .action-link {
	background: none;
	border: none;
	padding: 0;
	font: inherit;
	font-size: inherit;
	color: var(--accent-ink);
	text-decoration: underline;
	cursor: pointer;
}
