/* Custom styles placeholder */

/* Base tweaks for readability */
html, body {
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

/* Font - Inter for modern UI */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');
body {
	font-family: "Inter", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

/* Motion tokens */
:root {
	--easing: cubic-bezier(.22, .61, .36, 1);
	--dur-fast: .18s;
	--dur-base: .32s;
	--dur-slow: .6s;
}

/* Design tokens */
:root {
	--sidebar-bg: #0f172a; /* slate-900 */
	--sidebar-bg-2: #111827; /* gray-900 */
	--sidebar-accent: #1f2937; /* gray-800 */
	--sidebar-text: #cbd5e1; /* slate-300 */
	--brand: #6366f1; /* indigo-500 */
	--brand-600: #4f46e5;
	--brand-700: #4338ca;
	--surface: #C7CDEC; /* light app background (preferred) */
	--card-bg: #ffffff;
	--card-border: #e5e7eb;
	--muted: #6b7280;
	--text: #0f172a;
	--ring: rgba(99,102,241,.4);
	--link: #4338ca;
}
html.dark:root {
	--card-bg: #111827;
	--card-border: #374151;
	--muted: #9ca3af;
	--surface: #0b1220;
	--text: #e5e7eb;
	--ring: rgba(99,102,241,.35);
	--link: #93c5fd;
}

/* App surface */
body { background: var(--surface); color: var(--text); }
/* Override Tailwind's bg-gray-100 for light theme across app pages */
html:not(.dark) body.bg-gray-100 { background-color: #C7CDEC !important; }

/* Global link color */
a { color: var(--link); }
a:hover { text-decoration: underline; }

/* Force darker text in light theme for common utility classes */
html:not(.dark) .text-gray-600 { color: #1f2937 !important; } /* gray-800 */
html:not(.dark) .text-gray-500 { color: #374151 !important; } /* gray-700 */
html:not(.dark) .text-gray-400 { color: #4b5563 !important; } /* gray-600 */
html:not(.dark) table thead th, html:not(.dark) table thead { color: #111827 !important; } /* gray-900 */
html:not(.dark) h1, html:not(.dark) h2, html:not(.dark) h3, html:not(.dark) h4, html:not(.dark) h5, html:not(.dark) h6 { color: #0f172a; }

/* Sidebar and content contrast in dark mode */
html.dark .bg-white { background-color: #1f2937 !important; }
html.dark .text-gray-900 { color: #e5e7eb !important; }
html.dark .border-gray-200 { border-color: #374151 !important; }

/* Link focus */
a:focus {
	outline: 2px solid #6366f1;
	outline-offset: 2px;
}

/* Global smooth transitions */
body, .app-topbar, .app-sidebar, .card, .form-input, .form-select, .form-textarea,
.menu-link, .status-pill, .theme-toggle, .btn-primary, .btn-ghost, table, th, td {
	transition:
		background-color var(--dur-base) var(--easing),
		color var(--dur-base) var(--easing),
		border-color var(--dur-base) var(--easing),
		box-shadow var(--dur-base) var(--easing),
		transform var(--dur-fast) var(--easing),
		opacity var(--dur-base) var(--easing);
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
		scroll-behavior: auto !important;
	}
}

/* App sidebar (template-inspired) */
.app-sidebar {
	background: radial-gradient(1200px 400px at -150px -100px, var(--sidebar-bg-2), var(--sidebar-bg));
	color: var(--sidebar-text);
	border-right: 1px solid rgba(255,255,255,0.06);
	border-top-right-radius: 1.25rem;
	border-bottom-right-radius: 0;
	box-shadow: 0 10px 30px rgba(2, 6, 23, 0.7);
	transition: width var(--dur-base) var(--easing), background-color var(--dur-base) var(--easing), color var(--dur-base) var(--easing), border-color var(--dur-base) var(--easing);
	height: 100vh;
	overflow: hidden; /* prevent sidebar itself from scrolling; internal area will scroll */
}

/* Mobile specific override for sidebar overlaying */
.app-sidebar.translate-x-0 {
	z-index: 50 !important; /* Ensure it sits above everything on mobile */
	width: 16rem !important; /* Ensure full width on mobile open */
	position: fixed !important; /* Force fixed positioning on mobile open */
	top: 0;
	left: 0;
	bottom: 0;
}
/* Ensure labels are forced visible when sidebar is open on mobile */
.app-sidebar.translate-x-0 .brand .brand-name,
.app-sidebar.translate-x-0 .menu-link .label,
.app-sidebar.translate-x-0 .promo {
	display: block !important;
}

.app-sidebar .brand {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 1rem 1.25rem;
	font-weight: 700;
	color: #e5e7eb;
}
.app-sidebar .menu {
	padding: 0.25rem 0.5rem 1rem 0.5rem;
	flex: 1 1 auto;            /* let menu take available vertical space */
	overflow-y: auto;          /* scroll only the menu area if content is tall */
	-ms-overflow-style: none;  /* IE/Edge hide scrollbar */
	scrollbar-width: none;     /* Firefox hide scrollbar */
}
.app-sidebar .menu::-webkit-scrollbar { width: 0; height: 0; } /* WebKit hide scrollbar */
/* ensure content isn't hidden behind the bottom logout area */
.app-sidebar .menu { padding-bottom: 4.5rem; }
.app-sidebar .menu-link {
	display: flex;
	align-items: center;
	gap: .625rem;
	padding: .625rem .75rem;
	border-radius: .5rem;
	color: var(--sidebar-text);
	transition:
		background-color var(--dur-fast) var(--easing),
		color var(--dur-fast) var(--easing),
		box-shadow var(--dur-fast) var(--easing),
		transform var(--dur-fast) var(--easing);
}
.app-sidebar .menu-link:hover {
	background: rgba(255,255,255,0.06);
	color: #fff;
	transform: translateX(2px);
}
.app-sidebar .menu-link.active {
	background: linear-gradient(135deg, var(--brand), var(--brand-600));
	color: #fff;
	box-shadow: 0 6px 16px rgba(99,102,241,.35);
}
.app-sidebar .promo {
	background: linear-gradient(135deg, #0ea5e9, #8b5cf6);
	color: #fff;
	border-radius: .75rem;
	padding: .875rem;
	display: flex;
	align-items: center;
	gap: .75rem;
	margin: 1rem;
	box-shadow: 0 10px 25px rgba(0,0,0,.25);
}
.app-sidebar .promo img {
	width: 44px;
	height: 44px;
	border-radius: .5rem;
	object-fit: cover;
}

/* Header / topbar */
.app-topbar {
	background: #ffffff;
	border-bottom: 1px solid var(--card-border);
	backdrop-filter: saturate(180%) blur(8px);
	position: sticky;
	top: 0;
	z-index: 30;
	transition: background-color var(--dur-base) var(--easing), border-color var(--dur-base) var(--easing);
}
html.dark .app-topbar {
	background: #0b1324;
	border-color: #1f2937;
}
/* Sun/Moon theme toggle */
.theme-toggle {
	border: 1px solid var(--card-border);
	border-radius: .5rem;
	padding: .25rem .5rem;
	font-size: 1rem;
	line-height: 1;
	background: #fff;
	color: #111827;
	box-shadow: 0 1px 1px rgba(0,0,0,.02);
	transform-origin: center;
}
html.dark .theme-toggle {
	background: #111827;
	color: #e5e7eb;
	border-color: #374151;
}
.theme-toggle .sun { display: inline; }
.theme-toggle .moon { display: none; }
html.dark .theme-toggle .sun { display: none; }
html.dark .theme-toggle .moon { display: inline; }
.theme-toggle:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,.08); }
.theme-toggle:active { transform: translateY(0); }

.avatar {
	width: 28px;
	height: 28px;
	border-radius: 999px;
	background: linear-gradient(135deg, var(--brand), var(--brand-700));
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	font-weight: 700;
	font-size: .75rem;
}

/* Cards */
.card {
	background: var(--card-bg);
	border: 1px solid var(--card-border);
	border-radius: .75rem;
	box-shadow:
		0 1px 1px rgba(0,0,0,0.02),
		0 4px 12px rgba(0,0,0,0.06);
	transition: box-shadow .2s ease, transform .2s ease;
}
.card:hover { box-shadow: 0 6px 24px rgba(0,0,0,.08); transform: translateY(-1px); }

/* Page entrance animation */
html.pre-animate main .card,
html.pre-animate main .kpi,
html.pre-animate main table,
html.pre-animate .promo,
html.pre-animate canvas {
	opacity: 0;
	transform: translateY(6px) scale(0.995);
}
html.animate main .card,
html.animate main .kpi,
html.animate main table,
html.animate .promo,
html.animate canvas {
	opacity: 1;
	transform: none;
	transition:
		opacity var(--dur-slow) var(--easing),
		transform var(--dur-slow) var(--easing);
}
/* Stagger common grids */
html.animate .grid > *:nth-child(1) { transition-delay: 40ms; }
html.animate .grid > *:nth-child(2) { transition-delay: 80ms; }
html.animate .grid > *:nth-child(3) { transition-delay: 120ms; }
html.animate .grid > *:nth-child(4) { transition-delay: 160ms; }
html.animate .grid > *:nth-child(5) { transition-delay: 200ms; }
html.animate .grid > *:nth-child(6) { transition-delay: 240ms; }

.card .card-header {
	padding: 1rem;
	border-bottom: 1px solid var(--card-border);
	font-weight: 600;
}
.card .card-body { padding: 1rem; }
.card .muted { color: var(--muted); }
.segmented {
	display: inline-flex;
	background: #f3f4f6;
	border: 1px solid var(--card-border);
	border-radius: .625rem;
	overflow: hidden;
}
.segmented button {
	padding: .375rem .75rem;
	font-size: .8125rem;
	color: #374151;
}
.segmented button.active {
	background: #fff;
	color: #111827;
	box-shadow: inset 0 0 0 1px var(--card-border);
}
.card .card-title {
	font-weight: 600;
	color: #111827;
}
html.dark .card .card-title { color: #e5e7eb; }
.kpi .value { font-size: 1.5rem; font-weight: 700; }
.kpi .label { color: var(--muted); font-size: .8125rem; }

/* Tables */
table thead tr { background: rgba(0,0,0,0.03); }
html.dark table thead tr { background: rgba(255,255,255,0.06); }
table tbody tr { transition: background-color .15s ease; }
table tbody tr:hover { background: rgba(99,102,241,0.06); }
html.dark table tbody tr:hover { background: rgba(99,102,241,0.1); }
table tbody tr:nth-child(odd) { background: rgba(0,0,0,0.015); }
html.dark table tbody tr:nth-child(odd) { background: rgba(255,255,255,0.025); }
th, td { vertical-align: middle; }

/* Status pills (Paid, Declined, In progress, etc.) - generic */
.status-pill {
	display: inline-flex;
	align-items: center;
	gap: .375rem;
	padding: .125rem .5rem;
	border-radius: 999px;
	font-size: .75rem;
	font-weight: 600;
	box-shadow: inset 0 0 0 1px rgba(0,0,0,.04);
}
.status-green { background: rgba(16,185,129,.12); color: #059669; }
.status-red { background: rgba(239,68,68,.12); color: #dc2626; }
.status-blue { background: rgba(59,130,246,.12); color: #2563eb; }

/* Forms */
.form-grid { display: grid; gap: .75rem; }
.form-row { display: grid; grid-template-columns: 1fr 2fr; gap: .75rem; }
.form-label { font-size: .8125rem; color: var(--muted); }
.form-input, .form-select, .form-textarea {
	background: #fff;
	color: #111827;
	border: 1px solid var(--card-border);
	border-radius: .5rem;
	padding: .5rem .625rem;
	transition: box-shadow .15s ease, border-color .15s ease;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
	outline: none;
	border-color: var(--brand);
	box-shadow: 0 0 0 4px var(--ring);
}
html.dark .form-input, html.dark .form-select, html.dark .form-textarea {
	background: #0f172a;
	color: #e5e7eb;
	border-color: #1f2937;
}

/* Button variants */
.btn-primary {
	background: linear-gradient(135deg, var(--brand), var(--brand-600));
	color: #fff;
	border: 0;
	border-radius: .5rem;
	padding: .5rem .875rem;
	font-weight: 600;
	box-shadow: 0 6px 16px rgba(99,102,241,.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(99,102,241,.28); }
.btn-primary:active { transform: translateY(0); box-shadow: 0 3px 10px rgba(99,102,241,.2); }
.btn-ghost {
	background: transparent;
	color: var(--brand-600);
	border: 1px solid var(--card-border);
	border-radius: .5rem;
	padding: .5rem .875rem;
}
.btn-ghost:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(0,0,0,.06); }
.btn-ghost:active { transform: translateY(0); }

/* Floating dropdown panels (navbar menus) */
.dropdown-panel {
	position: fixed;
	top: 3.5rem; /* ~ top-14 */
	right: 0.5rem;
	width: 20rem;
	max-width: 90vw;
	background: var(--card-bg);
	border: 1px solid var(--card-border);
	border-radius: .75rem;
	box-shadow: 0 10px 30px rgba(0,0,0,.15);
	z-index: 50;
	overflow: hidden;
}
.dropdown-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: .5rem .75rem;
	border-bottom: 1px solid var(--card-border);
	font-weight: 600;
}
.dropdown-body { max-height: 16rem; overflow: auto; }
.dropdown-footer {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: .5rem;
	padding: .5rem .75rem;
	border-top: 1px solid var(--card-border);
}

/* Quiet search input */
.search-wrap { position: relative; }
.search-wrap .search-icon {
	position: absolute;
	left: .5rem;
	top: 50%;
	transform: translateY(-50%);
	pointer-events: none;
	color: #9ca3af;
}
.search-input {
	padding-left: 2rem;
	border-radius: .5rem;
	background: #f5f6f8;
	border: 1px solid transparent;
	color: #111827;
	line-height: 1.25;
	height: 34px;
}
html.dark .search-input {
	background: #111827;
	border-color: #1f2937;
	color: #e5e7eb;
}
.search-input::placeholder { color: #9ca3af; }
.search-input:hover { border-color: var(--card-border); background: #f9fafb; }
.search-input:focus {
	background: #ffffff;
	border-color: var(--brand);
	box-shadow: 0 0 0 2px var(--ring);
	outline: none;
}
html.dark .search-input:focus { background: #0f172a; }

/* Subtle topbar icon buttons */
.topbar-btn {
	border-radius: .5rem;
	padding: .25rem .5rem;
}
.topbar-btn:hover { background: rgba(17,24,39,.05); }
html.dark .topbar-btn:hover { background: rgba(255,255,255,.06); }

/* Collapsed sidebar styles */
.app-sidebar.collapsed { width: 72px !important; }
.app-sidebar .brand { position: sticky; top: 0; z-index: 10; }
 .app-sidebar .brand .brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: .5rem; background: transparent; color: inherit; }
 .app-sidebar .brand .brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; background: transparent; }
.app-sidebar .brand .brand-name { margin-left: .5rem; }
.app-sidebar.collapsed .brand .brand-name { display: none; }
.app-sidebar .menu-link { display: flex; align-items: center; }
.app-sidebar .menu-link .icon { width: 20px; height: 20px; color: #cbd5e1; }
.app-sidebar .menu-link .label { margin-left: .5rem; color: inherit; }
.app-sidebar.collapsed .menu-link { justify-content: center; }
.app-sidebar.collapsed .menu-link .label { display: none; }
.app-sidebar.collapsed .promo { display: none; }

/* Submenu styles */
.app-sidebar .menu-group .menu-toggle { display: flex; align-items: center; justify-content: flex-start; width: 100%; padding: .625rem .75rem; border-radius: .5rem; color: var(--sidebar-text); background: transparent; }
.app-sidebar .menu-group .menu-toggle:hover { background: rgba(255,255,255,0.06); color: #fff; }
.app-sidebar .submenu { display: none; padding-left: .5rem; margin-top: .25rem; margin-bottom: .25rem; }
.app-sidebar .menu-group.open .submenu { display: block; }

/* Align top-level group buttons left padding with regular links */
.app-sidebar .menu-group > .menu-toggle.menu-link { padding-left: .75rem; }
/* Push caret to the far right like a chevron without affecting left spacing */
.app-sidebar .menu-group > .menu-toggle .caret { margin-left: auto; }

/* Mobile: start collapsed by default, allow toggle open (persisted) */
@media (max-width: 768px) {
	/* Off-canvas behavior handled via utility classes (transform/translate). */
	/* No fixed widths here to avoid horizontal overflow on small screens. */
	.form-row { grid-template-columns: 1fr; }
	.form-input, .form-select, .form-textarea { width: 100%; }
	.btn-primary, .btn-ghost { width: 100%; min-height: 40px; }
	.search-input { max-width: 100%; width: 100%; }
}
