/*
 * EstateLens application stylesheet (Propshaft manifest).
 *
 * Bootstrap 5 + Bootstrap Icons are vendored under stylesheets/vendor and linked
 * separately in the layout <head> (so Propshaft fingerprints each and rewrites
 * the icon-font url()s). This file holds the EstateLens theme — ported from the
 * legacy Flask base.html inline <style> (sidebar, aurora background, glass cards).
 */

:root {
  --primary-accent: #3B82F6;
  --secondary-accent: #22D3EE;
  --sidebar-bg: #2A4585;
  --sidebar-text: #FFFFFF;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.1);
  --sidebar-active-bg: rgba(255, 255, 255, 0.2);
  --sidebar-width: 260px;
  --background-start: #F0F9FF;
  --background-end: #E0F2FE;
  --card-bg: rgba(255, 255, 255, 0.6);
  --card-hover-bg: rgba(255, 255, 255, 0.8);
  --card-border: rgba(0, 0, 0, 0.05);
  --text-primary: #0F172A;
  --text-secondary: #53515a;
  --shadow-color: rgba(17, 122, 222, 0.08);
  --danger: #dc3545;
  --warning: #ffc107;
  --info: #0dcaf0;
}

body {
  font-family: 'Poppins', system-ui, sans-serif;
  background-color: var(--background-start);
  color: var(--text-primary);
  overflow-x: hidden;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 1.5rem 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform 0.3s ease-in-out;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.5rem 1.5rem 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.sidebar-header .logo { height: 88px; width: auto; max-width: 100%; }
.sidebar-logo-link { display: block; line-height: 0; }

.sidebar-nav { list-style: none; padding: 0; margin: 0; }
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1rem;
  margin-bottom: 0.35rem;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  /* Larger & bolder for readability (#65 feedback). */
  font-size: 1.02rem;
  font-weight: 600;
  transition: background-color 0.2s ease;
}
.sidebar-nav li a .bi { font-size: 1.25rem; }
.sidebar-nav li a:hover { background-color: var(--sidebar-hover-bg); }
.sidebar-nav li a.active { background-color: var(--sidebar-active-bg); font-weight: 700; }
.sidebar-nav .sidebar-heading {
  padding: 1rem 1rem 0.35rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.65);
}

/* --- Accordion-collapsible sections (#93) --- */
.sidebar-group { display: block; }
.sidebar-group-toggle {
  /* The heading is a full-width button: [icon] Title …… [chevron]. */
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: color 0.2s ease;
}
.sidebar-group-toggle:hover { color: #fff; }
.sidebar-group-toggle .sidebar-section-icon { font-size: 1rem; opacity: 0.85; }
.sidebar-group-toggle .sidebar-chevron {
  margin-left: auto;
  font-size: 0.85rem;
  transition: transform 0.2s ease;
}
.sidebar-group.is-collapsed .sidebar-chevron { transform: rotate(-90deg); }

.sidebar-group-body {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow: hidden;
  max-height: 40rem;
  transition: max-height 0.25s ease;
}
.sidebar-group.is-collapsed .sidebar-group-body { max-height: 0; }

.sidebar-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid rgba(255, 255, 255, 0.15); font-size: 0.85rem; }
.sidebar-footer .btn { width: 100%; }

/* --- Main content --- */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 2rem;
  min-height: 100vh;
  background-image: linear-gradient(to bottom, var(--background-start) 0%, var(--background-end) 100%);
  position: relative;
  /* Reflow smoothly when the sidebar is collapsed/expanded (#65). */
  transition: margin-left 0.3s ease-in-out;
}

.aurora-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; overflow: hidden; }
.aurora-blob { position: absolute; border-radius: 50%; filter: blur(140px); opacity: 0.6; }
.blob-1 { width: 600px; height: 600px; background: rgba(59, 130, 246, 0.2); top: -20%; left: -10%; animation: moveBlob1 25s infinite alternate ease-in-out; }
.blob-2 { width: 700px; height: 700px; background: rgba(34, 211, 238, 0.15); bottom: -25%; right: -20%; animation: moveBlob2 30s infinite alternate ease-in-out; }
@keyframes moveBlob1 { from { transform: translate(-20%, 20%) scale(1.0); } to { transform: translate(20%, -20%) scale(1.2); } }
@keyframes moveBlob2 { from { transform: translate(15%, -10%) rotate(60deg); } to { transform: translate(-15%, 10%) rotate(-20deg); } }

.page-header { padding: 0 0 2rem 0; margin-bottom: 1.5rem; }
.page-header h1 { font-weight: 700; background: -webkit-linear-gradient(45deg, var(--primary-accent), var(--secondary-accent)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.page-header p { color: var(--text-secondary); font-weight: 400; font-size: 1.2rem; }

.app-footer { text-align: center; padding-top: 2rem; color: var(--text-secondary); font-size: 0.9rem; border-top: 1px solid #ddd; }

/* --- Cards --- */
.dashboard-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 1rem; backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); box-shadow: 0 8px 32px var(--shadow-color); transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1); height: 100%; position: relative; overflow: hidden; }
.dashboard-card:hover { transform: translateY(-10px) scale(1.03); box-shadow: 0 16px 40px rgba(20, 110, 190, 0.18); background: var(--card-hover-bg); }
.card-body-content { position: relative; z-index: 2; padding: 1rem; }
.card-icon { font-size: 3rem; color: var(--text-secondary); transition: all 0.4s ease; }
.dashboard-card:hover .card-icon { color: var(--primary-accent); transform: scale(1.15) rotate(-8deg); }
.card-title { font-weight: 600; color: var(--text-primary); }
.card-text { font-size: 0.9rem; color: var(--text-secondary); }

.insight-card { background: rgba(255, 255, 255, 0.6); border: 1px solid rgba(0, 0, 0, 0.08); border-radius: 0.75rem; padding: 1.25rem; display: flex; align-items: center; gap: 1rem; transition: all 0.3s ease; text-decoration: none; color: inherit; }
.insight-card:hover { transform: translateY(-5px); box-shadow: 0 12px 30px var(--shadow-color); }
.insight-icon { font-size: 2.5rem; width: 60px; height: 60px; display: flex; align-items: center; justify-content: center; border-radius: 50%; flex-shrink: 0; }
.insight-icon.danger { background-color: var(--danger); color: white; }
.insight-icon.warning { background-color: var(--warning); color: #333; }
.insight-icon.info { background-color: var(--info); color: #073b4c; }
.insight-icon.success { background-color: #198754; color: white; }
.insight-value { font-size: 1.75rem; font-weight: 700; line-height: 1; color: var(--text-primary); }
.insight-label { color: var(--text-secondary); font-size: 0.9rem; }

/* Glass panel for tables/charts/forms */
.panel-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 1rem; box-shadow: 0 8px 32px var(--shadow-color); padding: 1.5rem; margin-bottom: 1.5rem; }

/* --- Flash messages --- */
.flash { margin-bottom: 1rem; }

/* --- Clickable table rows (#74) --- */
/* Rows wired to the `clickable-rows` Stimulus controller navigate on click; the
   pointer cursor signals it (table-hover already provides the row highlight).
   The in-row action link stays the keyboard-accessible path. */
tr.clickable-row { cursor: pointer; }

/* --- Responsive / sidebar collapse (#65) --- */
/* Toggle is available at ALL widths. Its background matches the sidebar, so it
   blends into the rail when open and stands out over the content when collapsed. */
.sidebar-toggle { display: flex; align-items: center; justify-content: center; position: fixed; top: 1rem; left: 1rem; z-index: 1001; background: var(--sidebar-bg); color: white; border: none; border-radius: 8px; width: 45px; height: 45px; font-size: 1.5rem; cursor: pointer; }

/* Tablet & up: sidebar is pinned and visible by DEFAULT (pushes the content);
   collapsing it is opt-in via the toggle, which slides it off and lets the content
   reclaim the width. Breakpoint is the Bootstrap `md` edge (768px) so the menu
   stays open on laptops/tablets rather than starting hidden. */
@media (min-width: 768px) {
  body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
  body.sidebar-collapsed .main-content { margin-left: 0; }
  /* When collapsed the toggle floats over the content top-left — keep the H1 clear. */
  body.sidebar-collapsed .page-header { padding-left: 3.5rem; }
}

/* Phones only: sidebar is an off-canvas overlay (hidden until toggled) that never
   pushes the narrow content. */
@media (max-width: 767.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.is-open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.2); }
  .main-content { margin-left: 0; }
  .page-header { padding-left: 3.5rem; }
}

/* --- GeoGnosis logo placement experiment (#96) ---------------------------- */
/* The footer slot is permanent; the three experimental slots show one-at-a-time
   based on body[data-geognosis-position], cycled by the tiny footer toggle. Once
   a position is chosen, keep that slot and drop the others + the toggle. */
.geognosis-logo { display: inline-block; vertical-align: middle; }
.geognosis-slot--sidebar-top,
.geognosis-slot--sidebar-bottom,
.geognosis-slot--header { display: none; }
body[data-geognosis-position="sidebar-top"] .geognosis-slot--sidebar-top,
body[data-geognosis-position="sidebar-bottom"] .geognosis-slot--sidebar-bottom,
body[data-geognosis-position="header"] .geognosis-slot--header { display: inline-block; }
/* Position 1/2 sit centred under the wordmark / above the sign-out control. */
.geognosis-slot--sidebar-top, .geognosis-slot--sidebar-bottom { display: none; text-align: center; }
body[data-geognosis-position="sidebar-top"] .geognosis-slot--sidebar-top,
body[data-geognosis-position="sidebar-bottom"] .geognosis-slot--sidebar-bottom { display: block; margin-top: 0.75rem; }
/* The served GeoGnosis mark is a colour logo for light backgrounds; on the dark
   sidebar (top/bottom/footer slots) it needs a white chip so it stays legible. */
.geognosis-slot--sidebar-top .geognosis-logo,
.geognosis-slot--sidebar-bottom .geognosis-logo,
.geognosis-slot--footer .geognosis-logo {
  background: #fff;
  border-radius: 6px;
  padding: 5px 9px;
}
/* Position 4: floating at the top-right of the header. */
.page-header { position: relative; }
.geognosis-slot--header { position: absolute; top: 0; right: 0; opacity: 0.9; }
