/*
 * Aspire Expense Management — frontend styles.
 * Everything is scoped under .aem-wrap / .aem-dashboard / .aem-login-wrap
 * so it never leaks into or is affected by the theme's own styles.
 */

.aem-wrap, .aem-wrap * , .aem-wrap *::before, .aem-wrap *::after {
	box-sizing: border-box;
}

.aem-wrap {
	--aem-primary: #1d4ed8;
	--aem-primary-dark: #1e3a8a;
	--aem-danger: #dc2626;
	--aem-success: #16a34a;
	--aem-bg: #f4f6fb;
	--aem-card-bg: #ffffff;
	--aem-border: #e2e8f0;
	--aem-text: #1f2937;
	--aem-text-muted: #6b7280;
	--aem-radius: 12px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: var(--aem-text);
	line-height: 1.5;
	max-width: 1200px;
	margin: 20px auto;
	padding: 0 16px;
}

/* ---------------- Login ---------------- */
.aem-login-wrap {
	display: flex;
	justify-content: center;
	align-items: center;
	min-height: 60vh;
}
.aem-login-card {
	background: var(--aem-card-bg);
	border: 1px solid var(--aem-border);
	border-radius: var(--aem-radius);
	padding: 36px 32px;
	max-width: 380px;
	width: 100%;
	box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}
.aem-login-header { text-align: center; margin-bottom: 20px; }
.aem-login-header h2 { margin: 0 0 4px; font-size: 22px; color: var(--aem-primary-dark); }
.aem-login-header p { margin: 0; color: var(--aem-text-muted); font-size: 14px; }
.aem-login-form label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 13px; }
.aem-login-form input {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid var(--aem-border);
	border-radius: 8px;
	font-size: 14px;
}
.aem-text-center { text-align: center; }

/* ---------------- Buttons ---------------- */
.aem-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 10px 18px;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 600;
	border: 1px solid transparent;
	cursor: pointer;
	text-decoration: none;
	transition: transform .08s ease, box-shadow .15s ease, opacity .15s ease;
}
.aem-btn:active { transform: translateY(1px); }
.aem-btn-primary { background: var(--aem-primary); color: #fff; box-shadow: 0 4px 14px rgba(29,78,216,0.25); }
.aem-btn-primary:hover { background: var(--aem-primary-dark); color: #fff; }
.aem-btn-outline { background: transparent; border-color: var(--aem-border); color: var(--aem-text); }
.aem-btn-outline:hover { background: #f1f5f9; }
.aem-btn-danger { background: var(--aem-danger); color: #fff; }
.aem-btn-sm { padding: 6px 12px; font-size: 13px; }
.aem-btn-block { width: 100%; margin-top: 20px; }

/* ---------------- Dashboard shell ---------------- */
.aem-topbar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	flex-wrap: wrap;
	gap: 12px;
	margin-bottom: 18px;
}
.aem-topbar-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.aem-topbar-title h1 { font-size: 22px; margin: 0; color: var(--aem-primary-dark); }
.aem-user-chip {
	background: #eef2ff;
	color: var(--aem-primary-dark);
	padding: 4px 12px;
	border-radius: 999px;
	font-size: 13px;
	font-weight: 600;
}

.aem-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	background: #eef1f6;
	padding: 6px;
	border-radius: 10px;
	margin-bottom: 20px;
}
.aem-tab {
	flex: 1 1 auto;
	background: transparent;
	border: none;
	padding: 10px 14px;
	border-radius: 8px;
	font-weight: 600;
	font-size: 14px;
	color: var(--aem-text-muted);
	cursor: pointer;
	white-space: nowrap;
}
.aem-tab.active { background: var(--aem-card-bg); color: var(--aem-primary-dark); box-shadow: 0 2px 8px rgba(15,23,42,0.08); }

.aem-panel { display: none; animation: aemFade .2s ease; }
.aem-panel.active { display: block; }
@keyframes aemFade { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none; } }

.aem-alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.aem-alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.aem-alert-success { background: #f0fdf4; color: #14532d; border: 1px solid #bbf7d0; }

/* ---------------- Stat cards (Power BI-style KPI tiles) ---------------- */
.aem-stat-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: 14px;
	margin-bottom: 20px;
}
.aem-stat-card {
	position: relative;
	background: var(--aem-card-bg);
	border: 1px solid var(--aem-border);
	border-radius: var(--aem-radius);
	padding: 18px 18px 18px 22px;
	overflow: hidden;
	box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
	transition: box-shadow .15s ease, transform .15s ease;
}
.aem-stat-card:hover { box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08); transform: translateY(-1px); }
.aem-stat-card::before {
	content: "";
	position: absolute;
	left: 0; top: 0; bottom: 0;
	width: 5px;
	background: var(--aem-accent, var(--aem-primary));
}
.aem-stat-card:nth-child(1) { --aem-accent: #2563eb; }
.aem-stat-card:nth-child(2) { --aem-accent: #7c3aed; }
.aem-stat-card:nth-child(3) { --aem-accent: #0891b2; }
.aem-stat-card:nth-child(4) { --aem-accent: #ea580c; }
.aem-stat-card:nth-child(5) { --aem-accent: #16a34a; }
.aem-stat-highlight { background: #eff6ff; }
.aem-stat-label { display: block; font-size: 11.5px; color: var(--aem-text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; font-weight: 600; }
.aem-stat-value { font-size: 22px; font-weight: 800; color: #111827; letter-spacing: -0.01em; }

.aem-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 782px) { .aem-grid-2 { grid-template-columns: 1fr; } }

/* ---------------- Chart cards ---------------- */
.aem-chart-grid {
	display: grid;
	grid-template-columns: 2fr 1fr;
	gap: 16px;
	margin-bottom: 16px;
}
@media (max-width: 900px) { .aem-chart-grid { grid-template-columns: 1fr; } }

.aem-chart-card { display: flex; flex-direction: column; }
.aem-chart-card-wide { grid-column: auto; }
.aem-chart-card-head {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 6px;
	margin-bottom: 4px;
}
.aem-chart-subtitle { font-size: 12px; color: var(--aem-text-muted); }
.aem-chart-canvas-wrap { position: relative; height: 240px; margin-top: 10px; }
.aem-chart-canvas-wrap-tall { height: 280px; }
.aem-chart-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 14px;
	justify-content: center;
	margin-top: 14px;
	font-size: 12.5px;
}
.aem-chart-legend-item { display: flex; align-items: center; gap: 6px; color: var(--aem-text); }
.aem-chart-legend-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }

.aem-card {
	background: var(--aem-card-bg);
	border: 1px solid var(--aem-border);
	border-radius: var(--aem-radius);
	padding: 20px;
	margin-bottom: 16px;
}
.aem-card h3 { margin-top: 0; font-size: 16px; color: var(--aem-primary-dark); }
.aem-card-narrow { max-width: 720px; }

.aem-cat-row, .aem-recent-row {
	display: flex;
	justify-content: space-between;
	padding: 10px 0;
	border-bottom: 1px solid var(--aem-border);
	font-size: 14px;
}
.aem-recent-row small { display: block; color: var(--aem-text-muted); font-size: 12px; }
.aem-empty { color: var(--aem-text-muted); font-size: 14px; text-align: center; padding: 16px 0; }

/* ---------------- Forms ---------------- */
.aem-form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.aem-form-field { flex: 1 1 220px; margin-bottom: 14px; }
.aem-form-field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.aem-form-field input, .aem-form-field select, .aem-form-field textarea {
	width: 100%;
	padding: 9px 12px;
	border: 1px solid var(--aem-border);
	border-radius: 8px;
	font-size: 14px;
	background: #fff;
}
.aem-form-actions { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.aem-filter-row { align-items: end; }
.aem-filter-actions { display: flex; gap: 10px; flex: 1 1 220px; }

/* ---------------- Table ---------------- */
.aem-table-scroll { width: 100%; overflow-x: auto; }
.aem-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 720px; }
.aem-table th, .aem-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--aem-border); }
.aem-table th { background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--aem-text-muted); }
.aem-table tr:hover td { background: #f9fafb; }
.aem-row-actions { display: flex; gap: 8px; }
.aem-icon-btn {
	background: #f1f5f9;
	border: 1px solid var(--aem-border);
	border-radius: 6px;
	padding: 5px 10px;
	font-size: 12px;
	cursor: pointer;
}
.aem-icon-btn:hover { background: #e2e8f0; }
.aem-icon-btn.aem-delete-cat, .aem-row-actions .aem-delete { color: var(--aem-danger); }

.aem-pagination { display: flex; gap: 6px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.aem-pagination button {
	border: 1px solid var(--aem-border);
	background: #fff;
	border-radius: 6px;
	padding: 6px 12px;
	cursor: pointer;
	font-size: 13px;
}
.aem-pagination button.active { background: var(--aem-primary); color: #fff; border-color: var(--aem-primary); }

/* ---------------- Categories ---------------- */
.aem-cat-manage-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--aem-border); }
.aem-subcat-list { width: 100%; margin-left: 16px; }
.aem-subcat-row { padding: 6px 0; border-bottom: 1px dashed var(--aem-border); font-size: 13px; }
.aem-cat-actions { display: flex; gap: 6px; }

/* ---------------- Modal ---------------- */
.aem-modal {
	position: fixed; inset: 0; background: rgba(15,23,42,0.5);
	display: flex; align-items: center; justify-content: center; z-index: 100000; padding: 16px;
}
.aem-modal-content {
	background: #fff; border-radius: var(--aem-radius); padding: 24px; max-width: 480px; width: 100%;
	max-height: 85vh; overflow-y: auto; position: relative;
}
.aem-modal-close { position: absolute; top: 12px; right: 16px; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--aem-text-muted); }
.aem-view-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--aem-border); font-size: 14px; }
.aem-view-row strong { color: var(--aem-text-muted); font-weight: 600; }

/* ---------------- Full-screen page templates ---------------- */
/* Applied via body_class() on the optional "Full Screen" page templates,
   which skip the theme's header/nav/footer entirely. */
body.aem-fullscreen-page {
	margin: 0 !important;
	padding-top: 0 !important;
	background: #f4f6fb;
}
body.aem-fullscreen-page #wpadminbar { display: none !important; }
html:has(body.aem-fullscreen-page) { margin-top: 0 !important; }

body.aem-fullscreen-login {
	background: linear-gradient(135deg, #eef2ff 0%, #f4f6fb 60%, #e0f2fe 100%);
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
}
body.aem-fullscreen-login .aem-login-wrap {
	min-height: 0;
	margin: 0;
	width: 100%;
}
body.aem-fullscreen-dashboard .aem-dashboard {
	margin: 24px auto;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 600px) {
	.aem-topbar { flex-direction: column; align-items: flex-start; }
	.aem-tabs { overflow-x: auto; }
	.aem-stat-grid { grid-template-columns: 1fr 1fr; }
}
