/*
 * IR Master dashboard design tokens + app-shell components.
 * Palette pulled directly from staging.africafirm.com's live computed styles (not guessed):
 * cream background, near-black-green dark surface, gold accent, warm-cream text-on-dark.
 * Shared between the investor-facing dashboard and (in a later increment) the admin dashboard,
 * so both read as the same product rather than two different-looking screens.
 */

:root {
	--irm-cream: #faf7ee;
	--irm-cream-2: #f8ead5;
	--irm-ink: #33352b;
	--irm-dark: #111e04;
	--irm-dark-2: #060903;
	--irm-gold: #dbab35;
	--irm-gold-dark: #9c7a1f;
	--irm-olive-muted: #8a9463;
	--irm-border: rgba(51, 53, 43, 0.12);
	--irm-radius-card: 14px;
	--irm-radius-pill: 30px;
	--irm-shadow: 0 1px 2px rgba(17, 30, 4, 0.06), 0 8px 24px rgba(17, 30, 4, 0.05);
	--irm-font: Sora, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.irm-app {
	font-family: var(--irm-font);
	color: var(--irm-ink);
	background: var(--irm-cream);
	min-height: 100vh;
	display: flex;
}

.irm-app * {
	box-sizing: border-box;
}

/* Sidebar — collapsible to a narrow icon rail (not width: 0). Collapsing to nothing left the
   toggle with nowhere to live except a floating element outside the sidebar, which showed as a
   stray strip of the page's cream background next to the dark sidebar — found live via a user
   screenshot. The toggle now lives inside .irm-sidebar itself (text + icon, top of the panel),
   so there's never a gap: the dark background is continuous whether expanded or collapsed. */
.irm-sidebar {
	width: 240px;
	flex-shrink: 0;
	overflow: hidden;
	background: var(--irm-dark);
	color: var(--irm-cream-2);
	padding: 28px 20px;
	display: flex;
	flex-direction: column;
	gap: 32px;
	position: sticky;
	top: 0;
	height: 100vh;
	transition: width 0.18s ease, padding 0.18s ease;
}

.irm-app.is-collapsed .irm-sidebar {
	width: 64px;
	padding-left: 12px;
	padding-right: 12px;
}

.irm-sidebar-toggle {
	display: flex;
	align-items: center;
	gap: 8px;
	background: none;
	border: none;
	padding: 8px;
	margin: -8px;
	border-radius: 10px;
	color: rgba(248, 234, 213, 0.55);
	cursor: pointer;
	font-family: var(--irm-font);
	font-size: 12px;
	white-space: nowrap;
}

.irm-sidebar-toggle:hover {
	color: var(--irm-gold);
	background: rgba(219, 171, 53, 0.1);
}

.irm-sidebar-toggle-icon {
	font-size: 18px;
	line-height: 1;
	flex-shrink: 0;
	transition: transform 0.18s ease;
}

.irm-app.is-collapsed .irm-sidebar-toggle-icon {
	transform: rotate(180deg);
}

/* Collapsed: the toggle becomes an icon-only button, centred in the 64px rail rather than
   sitting flush-left (a user screenshot showed the collapsed icon poorly positioned) — same
   fix applied to nav links just below, since both are icon+label rows collapsing to icon-only. */
.irm-app.is-collapsed .irm-sidebar-toggle {
	width: 100%;
	justify-content: center;
}

.irm-app.is-collapsed .irm-sidebar-toggle-label,
.irm-app.is-collapsed .irm-sidebar-logo,
.irm-app.is-collapsed .irm-sidebar-nav-label,
.irm-app.is-collapsed .irm-sidebar-foot {
	display: none;
}

.irm-sidebar-logo {
	font-size: 18px;
	font-weight: 600;
	letter-spacing: 0.02em;
	color: var(--irm-cream-2);
}

.irm-sidebar-nav {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.irm-sidebar-nav a {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 14px;
	border-radius: 10px;
	font-size: 14px;
	color: rgba(248, 234, 213, 0.65);
	text-decoration: none;
}

.irm-sidebar-nav a.is-active,
.irm-sidebar-nav a:hover {
	background: rgba(219, 171, 53, 0.14);
	color: var(--irm-gold);
}

/* The icon is what stays visible when the label hides on collapse — never hidden itself, so a
   collapsed nav item is still a real, recognisable, clickable target rather than an empty pill
   (the bug a user screenshot flagged: labels were hiding but nothing replaced them). */
.irm-sidebar-nav-icon {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
}

.irm-app.is-collapsed .irm-sidebar-nav a {
	justify-content: center;
	padding: 10px 0;
}

.irm-sidebar-foot {
	margin-top: auto;
	font-size: 12px;
	color: rgba(248, 234, 213, 0.4);
}

/* Main column */
.irm-main {
	flex: 1;
	min-width: 0;
	padding: 32px 40px 64px;
}

.irm-topbar {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	margin-bottom: 28px;
}

.irm-topbar h1 {
	font-size: 26px;
	font-weight: 600;
	margin: 0;
	color: var(--irm-dark);
}

.irm-topbar-sub {
	font-size: 13px;
	color: var(--irm-olive-muted);
}

/* KPI tiles */
.irm-kpi-row {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: 16px;
	margin-bottom: 28px;
}

.irm-kpi-tile {
	background: #fff;
	border: 1px solid var(--irm-border);
	border-radius: var(--irm-radius-card);
	box-shadow: var(--irm-shadow);
	padding: 18px 20px;
}

.irm-kpi-label {
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--irm-olive-muted);
	margin-bottom: 8px;
}

.irm-kpi-value {
	font-size: 24px;
	font-weight: 600;
	color: var(--irm-dark);
}

/* Cards */
.irm-card {
	background: #fff;
	border: 1px solid var(--irm-border);
	border-radius: var(--irm-radius-card);
	box-shadow: var(--irm-shadow);
	padding: 22px 24px;
	margin-bottom: 20px;
	/* Wide content (the entities table on narrow screens) scrolls inside the card instead of
	   blowing out the page body — found live on a 390px-wide check of the Group dashboard. */
	overflow-x: auto;
}

.irm-card-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 14px;
}

.irm-card-title {
	font-size: 16px;
	font-weight: 600;
	color: var(--irm-dark);
	margin: 0;
}

.irm-card-sub {
	font-size: 12px;
	color: var(--irm-olive-muted);
}

.irm-badge {
	display: inline-block;
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	background: rgba(219, 171, 53, 0.14);
	color: var(--irm-gold-dark);
	border-radius: 999px;
	padding: 3px 10px;
}

/* Form fields — first needed for the chrome-free Investors view (Section "consolidate admin
   modules"); the wp-admin `form-table` this replaces has no equivalent here, so these are new. */
.irm-field {
	margin-bottom: 16px;
	max-width: 420px;
}

.irm-label {
	display: block;
	font-size: 13px;
	font-weight: 600;
	color: var(--irm-ink);
	margin-bottom: 6px;
}

.irm-input,
.irm-select {
	width: 100%;
	font-family: var(--irm-font);
	font-size: 14px;
	color: var(--irm-ink);
	background: #fff;
	border: 1px solid var(--irm-border);
	border-radius: 8px;
	padding: 9px 12px;
}

.irm-input:focus,
.irm-select:focus {
	outline: none;
	border-color: var(--irm-gold-dark);
}

.irm-checkbox-row {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	color: var(--irm-ink);
	margin-top: 8px;
}

.irm-notice {
	margin-bottom: 16px;
	padding: 10px 16px;
	border-radius: 10px;
	font-size: 13px;
}

.irm-notice-success {
	background: rgba(138, 148, 99, 0.15);
	color: #4a5533;
}

.irm-notice-error {
	background: rgba(179, 58, 58, 0.12);
	color: #a33;
}

/* Buttons */
.irm-btn {
	display: inline-block;
	font-family: var(--irm-font);
	font-size: 13px;
	font-weight: 600;
	border-radius: var(--irm-radius-pill);
	padding: 9px 18px;
	background: var(--irm-dark);
	color: var(--irm-cream-2);
	border: none;
	cursor: pointer;
	text-decoration: none;
}

.irm-btn:hover {
	background: var(--irm-dark-2);
	color: var(--irm-gold);
}

/* Groups multiple .irm-btn pills (e.g. the Export CSV/XLSX/PDF row) as one flex child inside a
   .irm-card-head, so `justify-content: space-between` spaces the group away from the title —
   not every button individually across the row. */
.irm-btn-group {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

/* input[type=submit]/button share .irm-btn with the <a> pill links elsewhere — a plain <input>
   or <button> needs its browser-default border/appearance stripped to actually look like one. */
input[type="submit"].irm-btn,
button.irm-btn {
	appearance: none;
	-webkit-appearance: none;
	border: none;
}

/* Small circular icon-only button — first needed for the per-line "remove" control on the
   Financial Period form's dynamic Lines table (user-requested, 2026-09-03). */
.irm-icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	padding: 0;
	border-radius: 50%;
	border: 1px solid var(--irm-border);
	background: transparent;
	color: var(--irm-olive-muted);
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
}

.irm-icon-btn:hover {
	background: rgba(179, 58, 58, 0.1);
	border-color: rgba(179, 58, 58, 0.4);
	color: #a33;
}

/* Tables inside cards (the "view underlying data" fallback). Cells are nowrap so a table with
   many columns (e.g. the 9-column entities table) scrolls horizontally inside its .irm-card
   (overflow-x: auto) instead of each cell wrapping its own content into a tall, unreadable
   stack — found live via a real narrow-screen screenshot the user shared, where organisation
   names were wrapping across 4 lines per row instead of the table just scrolling sideways. */
.irm-table {
	width: 100%;
	min-width: max-content;
	border-collapse: collapse;
	font-size: 13px;
}

.irm-table th,
.irm-table td {
	text-align: left;
	padding: 8px 10px;
	border-bottom: 1px solid var(--irm-border);
	white-space: nowrap;
}

.irm-table th {
	color: var(--irm-olive-muted);
	font-weight: 500;
	text-transform: uppercase;
	font-size: 11px;
	letter-spacing: 0.03em;
}

.irm-empty {
	color: var(--irm-olive-muted);
	font-size: 13px;
}

/* Table pagination + column filters (dashboard-shell.js) — table.irm-table-tools opt-in. */
.irm-table-toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 12px;
}

.irm-table-search {
	max-width: 240px;
}

.irm-table-filter {
	max-width: 200px;
}

.irm-table-daterange {
	display: flex;
	align-items: center;
	gap: 6px;
}

.irm-table-daterange-label {
	font-size: 12px;
	color: var(--irm-olive-muted);
}

.irm-table-daterange input[type="date"] {
	max-width: 150px;
}

.irm-table-pager {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-top: 12px;
	font-size: 13px;
	color: var(--irm-olive-muted);
}

.irm-table-pager-btn {
	padding: 4px 12px;
	font-size: 12px;
}

.irm-table-pager-btn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

/* Shown only on narrow screens, right above a wide table — a hard-cut scrollable edge with no
   cue reads as broken, not scrollable, so this makes the affordance explicit. */
.irm-scroll-hint {
	display: none;
	font-size: 12px;
	color: var(--irm-olive-muted);
	margin-bottom: 8px;
}

@media (max-width: 780px) {
	.irm-app {
		flex-direction: column;
	}
	/* Sidebar collapse is a desktop affordance — mobile already compacts the sidebar into a
	   horizontal bar below, so the toggle is hidden and the collapsed-rail width never applies. */
	.irm-sidebar,
	.irm-app.is-collapsed .irm-sidebar {
		width: 100%;
		height: auto;
		position: static;
		overflow: visible;
		flex-direction: row;
		align-items: center;
		flex-wrap: wrap;
		padding: 16px 20px;
	}
	.irm-sidebar-toggle {
		display: none;
	}
	.irm-sidebar-nav {
		flex-direction: row;
	}
	.irm-scroll-hint {
		display: block;
	}
	.irm-main {
		padding: 20px;
	}
}
