/* =========================
   MeteoFact - Modern UI
   ========================= */

/* ---------- Design tokens ---------- */
:root {
  --app-bg: #f6f7fb;
  --app-surface: rgba(255, 255, 255, 0.92);
  --app-surface-solid: #ffffff;

  --app-sidebar-w: 288px;
  --app-radius: 14px;

  --app-text: #0f172a;
  --app-muted: #64748b;

  --app-border: rgba(15, 23, 42, 0.10);
  --app-hover: rgba(15, 23, 42, 0.05);

  /* Active state: subtle + modern */
  --app-active-bg: rgba(13, 110, 253, 0.06);
  --app-active-border: rgba(13, 110, 253, 0.22);
  --app-active-accent: #0b5ed7;

  --app-topbar-h: 56px;

  /* Shadows */
  --shadow-1: 0 6px 18px rgba(15, 23, 42, 0.06);
  --shadow-2: 0 14px 40px rgba(15, 23, 42, 0.10);
}

/* ---------- Base ---------- */
html,
body {
  height: 100%;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--app-text);
}

.app-bg {
  background: var(--app-bg);
}

/* Optional: nicer selection */
::selection {
  background: rgba(13, 110, 253, 0.18);
}

/* ---------- Topbar ---------- */
.app-topbar {
  height: var(--app-topbar-h);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 1020;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--app-border);
}

/* ---------- App shell ---------- */
.app-shell {
  display: flex;
  min-height: calc(100vh - var(--app-topbar-h));
}

/* ---------- Sidebar ---------- */
.app-sidebar {
  width: var(--app-sidebar-w);
  border-right: 1px solid var(--app-border);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(10px);
}

@media (min-width: 992px) {
  .app-sidebar {
    position: sticky;
    top: var(--app-topbar-h);
    height: calc(100vh - var(--app-topbar-h));
    overflow-y: auto;
  }
}

/* Sidebar scroll aesthetics */
.app-sidebar::-webkit-scrollbar {
  width: 10px;
}

.app-sidebar::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.14);
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.0);
  background-clip: padding-box;
}

.app-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- Main content ---------- */
.app-main {
  flex: 1;
  min-height: calc(100vh - var(--app-topbar-h));
}

/* ---------- Cards ---------- */
.card {
  border-radius: var(--app-radius);
  border: 1px solid var(--app-border);
  background: var(--app-surface);
  box-shadow: var(--shadow-1);
}

.shadow-sm {
  box-shadow: var(--shadow-1) !important;
}

/* ---------- Sidebar titles ---------- */
.app-sidebar .text-uppercase {
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--app-muted) !important;
}

/* ---------- Navigation ---------- */
.app-navlink {
  position: relative;
  border-radius: 12px;
  padding: 0.62rem 0.75rem;
  color: var(--app-text);
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;

  /* keep it clean */
  border: 1px solid transparent;

  /* micro interaction */
  transition:
    background 140ms ease,
    border-color 140ms ease,
    transform 140ms ease,
    color 140ms ease;
}

.app-navlink i {
  opacity: 0.9;
  transition: opacity 140ms ease, transform 140ms ease;
}

.app-navlink:hover {
  background: var(--app-hover);
  transform: translateX(1px);
  color: var(--app-text);
  text-decoration: none;
}

.app-navlink:hover i {
  opacity: 1;
}

/* Active: subtle bg + border + left accent */
.app-navlink.active {
  background: var(--app-active-bg);
  border-color: var(--app-active-border);
  font-weight: 600;
  color: var(--app-active-accent);
}

.app-navlink.active i {
  opacity: 1;
  transform: translateX(0.5px);
}

.app-navlink.active::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 18px;
  border-radius: 999px;
  background: var(--app-active-accent);
}

/* Ensure the accent doesn't collide with text */
.app-navlink {
  padding-left: 1.05rem;
}

.app-navlink.active {
  padding-left: 1.45rem;
}

/* Focus visible for accessibility */
.app-navlink:focus-visible {
  outline: 3px solid rgba(13, 110, 253, 0.25);
  outline-offset: 2px;
}

/* ---------- Navbar logo ---------- */
.app-navbar-logo {
  height: 72px;
  width: auto;
  display: block;
}

/* ---------- Auth pages ---------- */
.auth-logo {
  max-width: 300px;
  width: 100%;
  height: auto;
}

/* ---------- Home background ---------- */
.home-page {
  min-height: calc(100vh - var(--app-topbar-h));
  background-image: url("/static/images/icebergs.jpg");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  position: relative;
}

/* éclaircissement image */
.home-page::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.40);
  z-index: 0;
}

/* contenu au-dessus */
.home-page>* {
  position: relative;
  z-index: 1;
}

/* zone respirable dashboard */
.home-content {
  max-width: 1600px;
  margin: auto;
}

/* espacement vertical doux */
.home-content .row {
  margin-bottom: .5rem;
}

/* cartes alignées */
.home-content .card {
  height: 100%;
}

/* ---------- Optional: tables look nicer ---------- */
.table {
  color: var(--app-text);
}

.table thead th {
  color: var(--app-muted);
  font-weight: 600;
  border-bottom-color: var(--app-border);
}

.table td,
.table th {
  border-top-color: var(--app-border);
}

/* --- Fix sidebar "mangée" par le contenu --- */

/* Empêche le contenu principal de pousser la sidebar (flexbox) */
.app-sidebar {
  flex: 0 0 var(--app-sidebar-w);
  position: relative;
  z-index: 2;
}

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  /* IMPORTANT en flex: permet au main de rétrécir */
  overflow-x: hidden;
  /* évite que du contenu large déborde sur la sidebar */
  position: relative;
  z-index: 1;
}

/* Si une table est large, elle doit scroller dans sa zone, pas déborder */
.table-responsive {
  overflow-x: auto;
}

/* Sécurité : évite les éléments qui dépassent la largeur de leur conteneur */
img,
table,
pre,
code {
  max-width: 100%;
}