/* ============================================================
   Intranet – Design System
   Farbpalette: Sand + Sage
   ============================================================ */

:root {
  /* Sand */
  --sand-50:  #FAF7F2;
  --sand-100: #F5EDE0;
  --sand-200: #EAD9C4;
  --sand-300: #D4C4A8;
  --sand-400: #BCA888;

  /* Sage */
  --sage-100: #D0DEC8;
  --sage-200: #AECBA0;
  --sage-300: #87A87A;   /* Primär */
  --sage-400: #6B9070;
  --sage-500: #4E7055;   /* Dunkel / Navbar */
  --sage-600: #3A5540;

  /* Rosé (Logo-Akzent) */
  --rose-100: #F2C0CC;
  --rose-300: #CF8096;
  --rose-500: #B86478;

  /* Neutral / Text */
  --warm-900: #2E2420;
  --warm-700: #4A3C34;
  --warm-500: #7A6A60;
  --warm-300: #B0A090;
  --warm-100: #EAE0D8;

  /* Abstraktionen */
  --color-bg:        var(--sand-50);
  --color-surface:   #FFFFFF;
  --color-sidebar-bg: var(--sand-100);
  --color-navbar-bg:  var(--sage-500);
  --color-primary:    var(--sage-300);
  --color-primary-dk: var(--sage-500);
  --color-text:       var(--warm-900);
  --color-text-muted: var(--warm-500);
  --color-border:     var(--sand-200);

  --sidebar-width: 240px;
  --navbar-height: 56px;
  --border-radius: 0.5rem;
}

/* ============================================================
   Reset / Base
   ============================================================ */

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

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.95rem;
}

/* ============================================================
   Top Navbar
   ============================================================ */

.navbar-top {
  background: var(--color-navbar-bg);
  height: var(--navbar-height);
  padding: 0 1rem;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1040;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 2px solid var(--sage-600);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.navbar-top .brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.01em;
  flex: 1;
}

.navbar-top .brand img {
  height: 36px;
  width: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  padding: 2px;
}

.navbar-top .brand span {
  color: #fff;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-user .btn-icon {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  border-radius: var(--border-radius);
  padding: 0.35rem 0.6rem;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s;
}

.nav-user .btn-icon:hover {
  background: rgba(255,255,255,0.22);
}

.sidebar-toggle {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  border-radius: var(--border-radius);
  padding: 0.35rem 0.6rem;
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.15s;
  line-height: 1;
}

.sidebar-toggle:hover {
  background: rgba(255,255,255,0.22);
}

/* ============================================================
   Layout: Sidebar + Content
   ============================================================ */

.layout-body {
  display: flex;
  min-height: calc(100vh - var(--navbar-height));
  margin-top: var(--navbar-height);
}

/* ============================================================
   Sidebar
   ============================================================ */

.sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  border-right: 1px solid var(--color-border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

/* offcanvas-lg: sidebar ist Schublade auf Mobile, statisch auf Desktop */
@media (min-width: 992px) {
  .sidebar.offcanvas-lg {
    position: sticky;
    top: var(--navbar-height);
    height: calc(100vh - var(--navbar-height));
    overflow-y: auto;
    transform: none !important;
    visibility: visible !important;
  }
}

.sidebar .offcanvas-header {
  background: var(--color-sidebar-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem 1rem;
}

.sidebar .offcanvas-body {
  padding: 0;
  overflow-y: auto;
}

/* Sidebar Navigation */
.sidebar-nav {
  padding: 0.75rem 0;
}

.sidebar-section {
  margin-bottom: 0.25rem;
}

.sidebar-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--warm-300);
  padding: 0.75rem 1.1rem 0.25rem;
  display: block;
}

/* Einklappbare Sidebar-Sektionen */
.sidebar-section-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--warm-300);
  padding: 0.75rem 1.1rem 0.25rem;
  cursor: pointer;
  text-align: left;
  transition: color 0.12s;
  line-height: 1.4;
}
.sidebar-section-toggle:hover {
  color: var(--warm-600);
}
.sidebar-section-toggle.section-active {
  color: var(--sage-600);
}
.sidebar-section-icon {
  font-size: 0.85rem;
  opacity: 0.65;
  line-height: 1;
}
.sidebar-section-toggle .sidebar-chevron {
  margin-left: auto;
  font-size: 0.65rem;
  transition: transform 0.2s;
  opacity: 0.5;
  flex-shrink: 0;
}
.sidebar-section-toggle[aria-expanded="true"] .sidebar-chevron {
  transform: rotate(180deg);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1.1rem;
  color: var(--warm-700);
  text-decoration: none;
  border-radius: 0;
  font-size: 0.9rem;
  transition: background 0.12s, color 0.12s;
  position: relative;
}

.sidebar-link:hover {
  background: var(--sand-200);
  color: var(--warm-900);
}

.sidebar-link.active {
  background: var(--sage-100);
  color: var(--sage-600);
  font-weight: 600;
}

.sidebar-link.active::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--color-primary);
  border-radius: 0 2px 2px 0;
}

.sidebar-link i {
  font-size: 1rem;
  width: 1.2rem;
  text-align: center;
  opacity: 0.8;
}

.sidebar-link.active i {
  opacity: 1;
}

.sidebar-link.disabled {
  color: var(--warm-300);
  pointer-events: none;
  cursor: default;
}

.sidebar-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0.5rem 0.8rem;
}

/* Sidebar Sub-Links (Einzug) */
.sidebar-link.sub {
  padding-left: 2.5rem;
  font-size: 0.875rem;
}

/* Einklappbare Untergruppen in der Sidebar */
.sidebar-sub-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  padding: 0.35rem 1.1rem 0.2rem 1.5rem;
  color: var(--warm-400);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
  text-align: left;
  transition: color 0.12s;
}
.sidebar-sub-toggle:hover {
  color: var(--warm-700);
}
.sidebar-sub-toggle.section-active {
  color: var(--sage-600);
}
.sidebar-sub-toggle .sidebar-chevron {
  margin-left: auto;
  font-size: 0.6rem;
  transition: transform 0.2s;
  opacity: 0.45;
  flex-shrink: 0;
}
.sidebar-sub-toggle[aria-expanded="true"] .sidebar-chevron {
  transform: rotate(180deg);
}

/* Einrückung 3. Ebene */
.sidebar-link.sub.sub-2 {
  padding-left: 3.5rem;
  font-size: 0.825rem;
}

/* ============================================================
   Projekt-Subnav
   ============================================================ */

.proj-subnav {
  background: var(--sand-100, #f8f6f2);
  border-bottom: 1px solid var(--color-border);
  padding: 0 1.1rem;
}

.proj-subnav-row {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  min-height: 2.2rem;
}
.proj-subnav-row::-webkit-scrollbar { display: none; }

.proj-subnav-row-sub {
  border-top: 1px solid var(--color-border);
  padding-left: 0.5rem;
  background: var(--sand-50, #fdfcfa);
}

.proj-subnav-indent-icon {
  font-size: 0.75rem;
  color: var(--warm-300);
  margin-right: 0.2rem;
  flex-shrink: 0;
}

.proj-subnav-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.5rem;
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--warm-600);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.proj-subnav-item:hover {
  background: var(--sand-200);
  color: var(--warm-900);
}
.proj-subnav-item.active {
  background: var(--sage-100);
  color: var(--sage-700);
  font-weight: 600;
}
.proj-subnav-item i {
  font-size: 0.82rem;
  opacity: 0.7;
}
.proj-subnav-item.active i { opacity: 1; }

.proj-subnav-label {
  font-weight: 600;
  color: var(--warm-800);
}
.proj-subnav-label.active { color: var(--sage-700); }

.proj-subnav-sep {
  color: var(--warm-300);
  font-size: 0.75rem;
  padding: 0 0.1rem;
  user-select: none;
  flex-shrink: 0;
}

/* ============================================================
   Haupt-Content
   ============================================================ */

.main-content {
  flex: 1;
  min-width: 0;
  padding: 1.5rem 1.25rem;
  overflow-x: hidden;
}

@media (min-width: 992px) {
  .main-content {
    padding: 2rem 2rem;
  }
}

/* ============================================================
   Page Header
   ============================================================ */

.page-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.page-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0;
  color: var(--warm-900);
}

.page-header .text-muted {
  color: var(--warm-500) !important;
  font-size: 0.875rem;
}

/* ============================================================
   Cards
   ============================================================ */

.card {
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  background: var(--color-surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--warm-900);
}

/* Stat-Card */
.stat-card {
  border-left: 4px solid var(--color-primary);
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--warm-900);
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ============================================================
   Buttons
   ============================================================ */

.btn-primary {
  background: var(--sage-300);
  border-color: var(--sage-400);
  color: #fff;
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--sage-400);
  border-color: var(--sage-500);
  color: #fff;
}

.btn-outline-primary {
  color: var(--sage-500);
  border-color: var(--sage-300);
}

.btn-outline-primary:hover {
  background: var(--sage-300);
  border-color: var(--sage-400);
  color: #fff;
}

/* ============================================================
   Badges & Tags
   ============================================================ */

.badge-sage {
  background: var(--sage-100);
  color: var(--sage-600);
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.25em 0.6em;
  border-radius: 999px;
}

.badge-sand {
  background: var(--sand-200);
  color: var(--warm-700);
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.25em 0.6em;
  border-radius: 999px;
}

/* ============================================================
   Rollen-Badge
   ============================================================ */

.role-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2em 0.55em;
  border-radius: 999px;
  letter-spacing: 0.04em;
}

.role-eltern {
  background: var(--sage-100);
  color: var(--sage-600);
}

.role-kind {
  background: var(--rose-100);
  color: var(--rose-500);
}

.role-admin {
  background: var(--sand-200);
  color: var(--warm-700);
}

/* ============================================================
   Flash Messages
   ============================================================ */

.flash-container {
  margin-bottom: 1rem;
}

/* ============================================================
   Footer
   ============================================================ */

.app-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--warm-300);
  padding: 1rem;
  border-top: 1px solid var(--color-border);
  margin-top: auto;
  background: var(--sand-50);
}

/* ============================================================
   Mobile Anpassungen
   ============================================================ */

@media (max-width: 575px) {
  .main-content {
    padding: 1rem 0.875rem;
  }

  .page-header h1 {
    font-size: 1.2rem;
  }
}

/* ============================================================
   Mobile Bottom Navigation
   ============================================================ */

.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1030;
  background: var(--color-surface);
  border-top: 2px solid var(--color-border);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Untere Zeile: Module */
.mobile-modnav {
  display: flex;
  justify-content: space-around;
  padding: 6px 0 4px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.mobile-modnav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  color: var(--warm-400);
  text-decoration: none;
  font-size: 0.62rem;
  font-weight: 500;
  flex: 1;
  padding: 4px 2px;
  transition: color 0.12s;
}

.mobile-modnav-item i {
  font-size: 1.35rem;
  line-height: 1;
}

.mobile-modnav-item.active {
  color: var(--sage-500);
}

.mobile-modnav-item.active i {
  font-variation-settings: 'FILL' 1;
}

/* Obere Zeile: Unterbereiche */
.mobile-subnav {
  display: flex;
  justify-content: space-around;
  background: var(--sand-100);
  padding: 5px 0 4px;
}

.mobile-subnav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  color: var(--warm-500);
  text-decoration: none;
  font-size: 0.6rem;
  font-weight: 500;
  flex: 1;
  padding: 3px 2px;
  transition: color 0.12s;
}

.mobile-subnav-item i {
  font-size: 1.1rem;
  line-height: 1;
}

.mobile-subnav-item.active {
  color: var(--sage-500);
  font-weight: 700;
}

/* Content-Padding damit nichts hinter Nav verschwindet */
@media (max-width: 991px) {
  .main-content {
    padding-bottom: 7.5rem;
  }
}

/* ============================================================
   Offcanvas Sidebar auf Mobile
   ============================================================ */

.offcanvas.sidebar {
  width: var(--sidebar-width) !important;
  background: var(--color-sidebar-bg);
}

/* ============================================================
   Scrollbar (Desktop)
   ============================================================ */

.sidebar::-webkit-scrollbar {
  width: 4px;
}

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

.sidebar::-webkit-scrollbar-thumb {
  background: var(--sand-300);
  border-radius: 2px;
}

/* ============================================================
   Utility
   ============================================================ */

.btn-sage {
  background: var(--sage-500);
  border: none;
  color: #fff;
  font-weight: 600;
}
.btn-sage:hover { background: var(--sage-600); color: #fff; }

.text-sage { color: var(--sage-500) !important; }

.bg-sage { background-color: var(--sage-500) !important; }

/* Custom tooth icon via CSS mask (Bootstrap Icons hat kein bi-tooth) */
.bi-tooth {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M5.5 0a3.5 3.5 0 0 0-3.5 3.5c0 .836.245 1.87.516 2.929C2.747 7.48 3 8.556 3 9.5c0 1.333.306 2.176.5 2.5l.5 1c.1.5.5 3 1.5 3s1-1.5 1.5-2.5.5-2 1-2 .5 1 1 2 .5 2.5 1.5 2.5 1.4-2.5 1.5-3l.5-1c.194-.324.5-1.167.5-2.5 0-.944.253-2.02.484-3.071C13.255 5.37 13.5 4.336 13.5 3.5A3.5 3.5 0 0 0 10.5 0C9.65 0 8.836.37 8 .851 7.164.37 6.35 0 5.5 0z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M5.5 0a3.5 3.5 0 0 0-3.5 3.5c0 .836.245 1.87.516 2.929C2.747 7.48 3 8.556 3 9.5c0 1.333.306 2.176.5 2.5l.5 1c.1.5.5 3 1.5 3s1-1.5 1.5-2.5.5-2 1-2 .5 1 1 2 .5 2.5 1.5 2.5 1.4-2.5 1.5-3l.5-1c.194-.324.5-1.167.5-2.5 0-.944.253-2.02.484-3.071C13.255 5.37 13.5 4.336 13.5 3.5A3.5 3.5 0 0 0 10.5 0C9.65 0 8.836.37 8 .851 7.164.37 6.35 0 5.5 0z'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
}
