/* Home page hero and features */
.hero-section {
	background: linear-gradient(180deg, var(--card), var(--bg));
	color: var(--text);
	border-radius: 18px;
	box-shadow: var(--shadow-lg);
	margin-bottom: 2rem;
	border: 1px solid var(--border);
}
.hero-section h1, .hero-section .display-4 { color: var(--text); }
.hero-section .btn-light { background: #fff; color: var(--primary-600); border: 1px solid rgba(59,130,246,.25); font-weight: 600; }
.hero-section .btn-outline-light { border-color: rgba(59,130,246,.35); color: var(--primary-600); }
.hero-section .card { background: #fff; border-radius: 14px; box-shadow: var(--shadow); }
.hero-section .card-title { color: var(--primary-600); }
.hero-section .muted { color: var(--muted); }
.features-section .card {
	border-radius: 14px;
	box-shadow: var(--shadow-sm);
}
.features-section .fs-2 {
	font-size: 2.2rem;
	line-height: 1;
}
.features-section .card-title {
	font-weight: 600;
}

/* Modern hero visuals */
.gradient-text {
	background: linear-gradient(90deg, #fff, #dbeafe, #bfdbfe);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}
.hero-animated { background: linear-gradient(180deg, var(--card), var(--bg)); }
.hero-animated .hero-decor .blob {
	position: absolute;
	width: 240px; height: 240px;
	border-radius: 50%;
	filter: blur(48px);
	opacity: 0.15;
	animation: float 9s ease-in-out infinite;
}
.hero-animated .hero-decor .blob:nth-child(1){ background: #a78bfa; top: -40px; right: -40px; }
.hero-animated .hero-decor .blob:nth-child(2){ background: #60a5fa; bottom: -60px; left: -30px; animation-delay: 2s; }
.hero-animated .hero-decor .grid {
	position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,0.08) 1px, transparent 1px);
	background-size: 28px 28px; opacity: 0.12;
}
@keyframes float {
	0%, 100% { transform: translateY(0); }
	50% { transform: translateY(-8px); }
}

/* Reveal on scroll (basic) */
.reveal { opacity: 0; transform: translateY(10px); transition: opacity .5s ease, transform .5s ease; }
.reveal.is-visible { opacity: 1; transform: none; }

/* Hover lift for cards */
.hover-lift { transition: transform .18s ease, box-shadow .18s ease; }
.hover-lift:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
:root {
	--bg: #f7f9fc;
	--card: #ffffff;
	--muted: #6c757d;
	--primary: #3b82f6;
	--primary-600: #2563eb;
	--text: #0f172a;
	--glass: rgba(255, 255, 255, 0.6);
	--border: rgba(15, 23, 42, 0.06);
	--badge-bg: #eef2ff;
	/* soft indigo */
	--badge-text: #3730a3;
	--card-hover: #f9fbff;
	--shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.06);
	--shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
	--shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
}

[data-theme="dark"] {
	--bg: #0b1220;
	--card: #071122;
	--muted: #9aa4b2;
	--primary: #60a5fa;
	--primary-600: #3b82f6;
	--text: #e6eef8;
	--glass: rgba(255, 255, 255, 0.04);
	--border: rgba(230, 238, 248, 0.06);
	--badge-bg: rgba(96, 165, 250, 0.15);
	--badge-text: #bfdbfe;
	--card-hover: rgba(255, 255, 255, 0.03);
	--shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.24);
	--shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
	--shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.32);
}

* {
	box-sizing: border-box
}

html, body { min-height: 100%; }

body {
	font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
	background: linear-gradient(180deg, var(--bg), #ffffff 60%);
	color: var(--text);
	padding-bottom: 0;
}

.container,
.container-fluid {
	max-width: 100%
}

.bg-gradient-primary {
	background: linear-gradient(90deg, var(--primary), var(--primary-600));
}

.card {
	background: var(--card);
	border: 0;
	border-radius: 12px
}

.card .card-body {
	padding: 1.25rem
}

.btn-primary {
	background: var(--primary);
	border: 0
}

.btn-primary:hover {
	background: var(--primary-600)
}

.shadow-sm {
	box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06)
}

#mainNavbar {
	backdrop-filter: blur(6px);
}

/* Ensure profile dropdown always overlays page content */
#mainNavbar { position: relative; z-index: 1200; }
.navbar .dropdown-menu { z-index: 2000; }

.display-5 {
	font-weight: 600
}

.table thead th {
	border-bottom: 1px solid rgba(0, 0, 0, 0.05)
}

.card-title {
	font-weight: 600
}

/* Filters panel styling */
.filters-card {
	background: linear-gradient(180deg, var(--card), var(--card-hover));
	border: 1px solid var(--border);
}
.filters-card .card-title {
	color: var(--primary);
}
.filters-card .form-label {
	color: var(--muted);
}
.filters-card .btn-primary {
	box-shadow: var(--shadow-sm);
}
/* Quick-add suggestion chips (visible, clickable) */
.suggestion-chip {
	background: rgba(59, 130, 246, 0.14); /* light blue */
	color: #0b3b87;
	border: 1px solid rgba(59, 130, 246, 0.35);
	cursor: pointer;
	user-select: none;
	border-radius: 999px;
	padding: 0.3rem 0.55rem;
	font-weight: 500;
}
.suggestion-chip:hover {
	background: rgba(59, 130, 246, 0.22);
	box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .suggestion-chip {
	background: rgba(96, 165, 250, 0.28);
	color: #e6f0ff;
	border-color: rgba(96, 165, 250, 0.55);
}
[data-theme="dark"] .suggestion-chip:hover {
	background: rgba(96, 165, 250, 0.36);
}

/* table row animations */
#resultsTable tbody tr {
	transition: opacity 200ms ease, transform 200ms ease
}

/* focus outlines for accessibility */
button:focus,
a:focus,
input:focus,
select:focus {
	outline: 3px solid rgba(99, 102, 241, 0.18);
	outline-offset: 2px
}

/* reduce motion */
@media (prefers-reduced-motion: reduce) {
	#resultsTable tbody tr {
		transition: none !important
	}
}

/* improved spacing for mobile */
@media (max-width:576px) {
	.card .card-body {
		padding: 1rem
	}

	.hero .col-md-7 {
		padding: 1rem
	}

	.hero .col-md-5 {
		padding: 1rem
	}
}

/* small responsive helpers */
@media (max-width:768px) {
	.container {
		padding: 0 1rem
	}
}

.muted {
	color: var(--muted)
}

.hero {
	padding: 2.5rem
}

/* Results grid and card defaults */
.results-grid {
	display: grid;
	column-gap: 0.6rem;
	row-gap: 1rem;
	align-items: start;
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Subtle scrollbar styling (supported browsers) */
.results-grid::-webkit-scrollbar {
	height: 10px;
}

.results-grid::-webkit-scrollbar-track {
	background: transparent;
}

.results-grid::-webkit-scrollbar-thumb {
	background: rgba(15, 23, 42, 0.15);
	border-radius: 999px;
}

.results-grid:hover::-webkit-scrollbar-thumb {
	background: rgba(15, 23, 42, 0.28);
}

/* fixed 3 columns across breakpoints for consistency */

.result-card {
	transition: transform 220ms ease, opacity 220ms ease, box-shadow 220ms ease, border-color 200ms ease, background-color 200ms ease;
	opacity: 1;
	transform: none;
	padding: 1rem;
	/* slightly reduced to keep height compact */
	min-height: 130px;
	/* shorter to form a rectangle */
	scroll-snap-align: start;
	overflow: hidden;
	/* keep card rectangular if content is long */
	background: linear-gradient(180deg, var(--card), var(--card-hover));
	border: 1px solid var(--border);
	box-shadow: var(--shadow-sm);
	cursor: pointer;
	/* whole card is clickable */
}

/* Locked state for free users beyond first 3 cards */
.result-card.locked { position: relative; }
.result-card.locked > *:not(.lock-overlay) { filter: blur(2px) grayscale(0.2); }
.result-card .lock-overlay {
	position: absolute;
	inset: 0;
	background: rgba(7, 17, 34, 0.6);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0.75rem;
}
.result-card .lock-overlay .lock-overlay-inner {
	background: rgba(255,255,255,0.1);
	border: 1px solid rgba(255,255,255,0.2);
	border-radius: 10px;
	padding: 0.75rem 1rem;
	backdrop-filter: blur(4px);
}
.result-card .lock-overlay .lock-icon { font-size: 1.25rem; }

.result-card[style*="display: none"] {
	opacity: 0;
	transform: translateY(6px);
	pointer-events: none
}

.result-card:hover {
	transform: translateY(-3px);
	box-shadow: var(--shadow);
	border-color: rgba(59, 130, 246, 0.25);
}

.result-card.is-selected {
	border-color: rgba(59, 130, 246, 0.45);
	box-shadow: var(--shadow-lg);
	background: linear-gradient(180deg, var(--card-hover), var(--card));
}


/* Truncation helpers for a tidy rectangular tile */
.result-card h5 {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.result-card .muted.small,
.result-card .mt-2.small.muted {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Color accents for info */
.result-card .fw-bold {
	color: var(--primary);
}

.result-card .badge {
	background: var(--badge-bg) !important;
	color: var(--badge-text) !important;
	border: 1px solid rgba(59, 130, 246, 0.15);
}

.result-card .badge:hover {
	filter: brightness(0.98);
}

/* Tag/context highlighting when filters match */
.result-card .tags-list .badge.match,
.result-card .card-context .badge.match {
	background: rgba(34,197,94,.18) !important; /* green tint */
	color: #065f46 !important;
	border-color: rgba(34,197,94,.4);
}
.result-card .card-context .badge.warn-match {
	background: rgba(245,158,11,.2) !important; /* amber */
	color: #92400e !important;
	border-color: rgba(245,158,11,.45);
}

.result-card .card-context .badge.score-badge {
	background: rgba(99,102,241,.18) !important; /* indigo */
	color: #3730a3 !important;
	border-color: rgba(99,102,241,.4);
	font-weight: 600;
}

/* Checkbox alignment polish */
.result-card .form-check-input:focus {
	box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Utility to hide container until JS reveals it */
.results-hidden {
	visibility: hidden
}

/* Presets chips */
#presetChips .preset-chip {
	border-radius: 999px;
}

/* Rating stars */
.rating-stars .star {
	font-size: 1.1rem;
	color: #e1e7ff;
}
.rating-stars .star.filled {
	color: #f59e0b; /* amber */
}
.rating-select input[type="radio"] {
	display: none;
}
.rating-select label {
	display: inline-block;
	margin: 0.15rem 0.25rem 0.15rem 0;
	padding: 0.25rem 0.5rem;
	border: 1px solid rgba(59,130,246,.25);
	border-radius: 999px;
	cursor: pointer;
	user-select: none;
}
.rating-select input[type="radio"]:checked + label,
.rating-select label:hover,
.rating-select label:focus {
	background: rgba(59,130,246,.12);
}

/* Details hero */
.details-hero .hero-image .ratio {
	background: linear-gradient(135deg, rgba(59,130,246,.08), rgba(59,130,246,.02));
}

.map-embed iframe {
	filter: saturate(1.05) contrast(1.02);
}

/* Details polish */
.details-hero h3 { font-weight: 700; }
.details-section + .details-section { margin-top: 1rem; }
.map-embed-compact { max-width: 720px; }
.map-embed-compact .ratio { box-shadow: var(--shadow-sm); }

/* Details: utility chips and badges */
.info-pill {
	background: var(--card-hover);
	border: 1px solid var(--border);
	color: var(--text);
	border-radius: 999px;
	padding: 0.1rem 0.6rem;
	font-size: .85rem;
}
.badge {
	background: var(--badge-bg) !important;
	color: var(--badge-text) !important;
	border: 1px solid rgba(59,130,246,.18);
}
.badge.match {
	background: rgba(34,197,94,.18) !important;
	color: #065f46 !important;
	border-color: rgba(34,197,94,.4);
}
.badge.warn-match {
	background: rgba(245,158,11,.2) !important;
	color: #92400e !important;
	border-color: rgba(245,158,11,.45);
}
.badge.score-badge {
	background: rgba(99,102,241,.18) !important;
	color: #3730a3 !important;
	border-color: rgba(99,102,241,.4);
	font-weight: 600;
}
.tag-badge { border-radius: 999px; }
.list-compact .list-group-item { padding: .55rem .75rem; }
.section-card { border: 1px solid var(--border); }

/* App footer */
.app-footer {
	background: linear-gradient(180deg, var(--card), var(--bg));
	border-top: 1px solid var(--border);
	margin-bottom: 0;
}
.app-footer a { text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }

/* Minimal motion effects for Home */
.title-accent {
	height: 4px;
	width: 120px;
	background: linear-gradient(90deg, var(--primary), var(--primary-600));
	border-radius: 999px;
	position: relative;
	margin-bottom: 0.75rem;
	overflow: hidden;
}
.title-accent::after {
	content: '';
	position: absolute; top: 0; left: -30%; height: 100%; width: 30%;
	background: rgba(255,255,255,.6);
	filter: blur(6px);
	animation: accent-sheen 2.6s ease-in-out infinite;
}
@keyframes accent-sheen { 0%{ left:-30%; } 60%{ left: 110%; } 100%{ left: 110%; } }

.btn-animated { position: relative; overflow: hidden; }
.btn-animated::after {
	content: '';
	position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
	width: 0; height: 2px; background: currentColor;
	transition: width .2s ease;
}
.btn-animated:hover::after, .btn-animated:focus::after { width: 70%; }

.pulse-border { position: relative; }
.pulse-border::before {
	content: '';
	position: absolute; inset: 0; border-radius: 12px;
	border: 1px solid rgba(59,130,246,.22);
	animation: pulse 3s ease-in-out infinite;
	pointer-events: none;
}
@keyframes pulse {
	0%, 100% { opacity: 0; transform: scale(.99); }
	40% { opacity: .6; transform: scale(1.02); }
}

/* Subtle gradient for hero card */
.soft-gradient {
	background: linear-gradient(180deg, var(--card), rgba(59,130,246,0.04));
	border-radius: 12px;
}

/* Bordered sign card */
.card-bordered { border: 1px solid rgba(15,23,42,0.08); }

/* Premium info card */
.premium-card { border-left: 4px solid rgba(59,130,246,.35); }
.premium-card .icon-check { color: #10b981; margin-right: .4rem; }

/* Premium polish for free users */
body.free-user .badge.bg-warning.text-dark {
	background-color: #fef3c7 !important; /* softer amber */
	color: #92400e !important;
	border: 1px dashed rgba(245, 158, 11, 0.5);
}
body.free-user .filters-card .form-check-input[disabled],
body.free-user .filters-card .form-select[disabled],
body.free-user .filters-card .form-control[disabled] {
	background-color: #f9fafb;
	color: #6b7280;
	opacity: 1;
}
body.free-user .filters-card .form-check-input[disabled] {
	border-color: rgba(245, 158, 11, 0.45);
}
body.free-user .filters-card .small.muted {
	color: #9aa4b2;
}
/* Premium quick-add suggestion chips (board exams) remain clickable only when premium; style stays consistent */
body.free-user .suggestion-chip[data-value] {
	filter: grayscale(0.15) brightness(0.98);
}

/* Free-limit banner polishing */
#freeLimitBanner {
	border: 1px dashed rgba(59,130,246,.35);
}

/* Forms: prevent textarea resizing to keep layout consistent */
textarea { resize: none; }