/* ============================================================
   SFFGV – Custom Styles
   ============================================================ */

:root {
  --sidebar-bg: #3a6fa8;
  --sidebar-width: 240px;
  --header-height: 72px;
  --sidebar-hover: rgba(255,255,255,0.15);
  --sidebar-active: rgba(255,255,255,0.25);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 0.9rem;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   TOP HEADER
   ============================================================ */
.app-header {
  background: #ffffff;
  border-bottom: 2px solid #d0dbe8;
  height: var(--header-height);
  flex-shrink: 0;
  z-index: 100;
}

.header-logo-img {
  width: 257px;
  height: 56px;
  display: block;
}

.header-link {
  color: #495057;
  text-decoration: none;
  font-size: 0.85rem;
}
.header-link:hover {
  color: var(--sidebar-bg);
  text-decoration: underline;
}

/* VP indicator in header */
.header-vp {
  flex: 1;
  justify-content: center;
}
.header-vp-label {
  font-size: 0.75rem;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.header-vp-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #212529;
}
.header-vp-location {
  font-weight: 400;
  color: #6c757d;
}
.header-vp-btn {
  background: none;
  border: 1px solid #ced4da;
  border-radius: 4px;
  color: var(--sidebar-bg);
  padding: 2px 7px;
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1.5;
  transition: background 0.15s, border-color 0.15s;
}
.header-vp-btn:hover {
  background: #e9f0f8;
  border-color: var(--sidebar-bg);
}

/* ============================================================
   BODY LAYOUT
   ============================================================ */
.app-body {
  flex: 1;
  overflow: hidden;
  height: calc(100vh - var(--header-height));
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.app-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #fff;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
}

.sidebar-vp-box {
  padding: 12px 14px 10px;
  background: rgba(0,0,0,0.15);
}

.sidebar-vp-label {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.5px;
}

.sidebar-vp-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: #fff;
}

.sidebar-vp-select {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  font-size: 0.85rem;
}
.sidebar-vp-select:focus {
  background: rgba(255,255,255,0.25);
  color: #fff;
  border-color: rgba(255,255,255,0.5);
  box-shadow: none;
}
.sidebar-vp-select option {
  background: var(--sidebar-bg);
  color: #fff;
}

.sidebar-divider {
  border-color: rgba(255,255,255,0.2);
  margin: 6px 14px;
}

.sidebar-section {
  padding: 4px 0;
}

.sidebar-section-label {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.6);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 14px 2px;
}

.sidebar-menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  font-size: 0.88rem;
  transition: background 0.15s;
  white-space: nowrap;
}
.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}
.sidebar-link.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}
.sidebar-link i {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

/* Dev role switcher at bottom */
.sidebar-role-switcher {
  padding: 10px 14px 14px;
  border-top: 1px solid rgba(255,255,255,0.15);
  margin-top: 10px;
}
.sidebar-role-switcher .sidebar-section-label {
  padding: 0 0 4px;
}
.sidebar-role-switcher .form-select {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  font-size: 0.82rem;
}
.sidebar-role-switcher .form-select:focus {
  box-shadow: none;
  border-color: rgba(255,255,255,0.5);
}
.sidebar-role-switcher .form-select option {
  background: #2d5c8e;
  color: #fff;
}

/* ============================================================
   VP MODAL
   ============================================================ */
.vp-modal-list {
  height: 340px;
  overflow-y: auto;
  overflow-x: hidden;
}
.vp-modal-list .list-group-item-action:active,
.vp-modal-list .list-group-item-action:focus {
  background-color: transparent;
  color: inherit;
}

/* ============================================================
   SORTABLE TABLES
   ============================================================ */
table.sortable thead th[data-col] {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
table.sortable thead th[data-col]:hover {
  background: #e2e8f0;
}
table.sortable thead th[data-col]::after {
  content: ' \2195';
  font-size: 1em;
  opacity: 0.4;
}
table.sortable thead th[data-sort-dir='asc']::after  { content: ' \2191'; opacity: 1; }
table.sortable thead th[data-sort-dir='desc']::after { content: ' \2193'; opacity: 1; }

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.app-main {
  overflow-y: auto;
  background: #f8f9fa;
}

/* ============================================================
   FORM HELPERS
   ============================================================ */
.form-label {
  font-weight: 500;
  margin-bottom: 3px;
}

.card-header {
  background: #f0f4f8;
  padding: 8px 16px;
  font-size: 0.9rem;
}

/* ============================================================
   TABLE
   ============================================================ */
.table th {
  font-size: 0.82rem;
  font-weight: 600;
  color: #555;
}

/* ============================================================
   BADGES / STATUS
   ============================================================ */
.text-monospace {
  font-family: 'Consolas', 'Courier New', monospace;
}

/* ============================================================
   SIDEBAR TREE (Schuljahre + sub-menus)
   ============================================================ */

/* Section headers: "Schuljahre", "Kommunikation & Information", etc. */
.sidebar-group-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255,255,255,0.95);
  padding: 8px 14px 3px;
  display: block;
}

/* Collapsible tree toggle button */
.sidebar-tree-node {
  display: flex;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  color: rgba(255,255,255,0.88);
  font-size: 0.85rem;
  padding: 5px 14px 5px 20px;
  cursor: pointer;
  text-align: left;
  line-height: 1.3;
  transition: background 0.15s;
}
.sidebar-tree-node:hover {
  background: var(--sidebar-hover);
  color: #fff;
}
.sidebar-tree-node::before {
  content: '+ ';
  font-weight: 700;
  color: rgba(255,255,255,0.55);
  margin-right: 2px;
  flex-shrink: 0;
}
.sidebar-tree-node[aria-expanded="true"]::before {
  content: '- ';
}
.sidebar-tree-node.laufendes {
  color: rgba(255,255,255,0.98);
  font-weight: 500;
}

/* L1 children: items directly under a year or section */
.sidebar-l1 .sidebar-link {
  padding-left: 36px;
  font-size: 0.85rem;
}

/* L2 children: items under Fördervertrag/Kostenersatz */
.sidebar-l2 .sidebar-link {
  padding-left: 50px;
  font-size: 0.84rem;
}

/* Sub-toggle for Fördervertrag etc. */
.sidebar-subtree-node {
  display: flex;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 0.85rem;
  padding: 5px 14px 5px 36px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.sidebar-subtree-node:hover {
  background: var(--sidebar-hover);
  color: #fff;
}
.sidebar-subtree-node::before {
  content: '+ ';
  font-weight: 700;
  color: rgba(255,255,255,0.45);
  margin-right: 2px;
}
.sidebar-subtree-node[aria-expanded="true"]::before {
  content: '- ';
}

/* Divider between sidebar groups */
.sidebar-group-divider {
  border-color: rgba(255,255,255,0.18);
  margin: 6px 14px;
}

/* ============================================================
   MAP
   ============================================================ */
/* Override Leaflet's grab/crosshair cursor – show default arrow instead */
#map .leaflet-grab,
#map .leaflet-container {
  cursor: default !important;
}
#map .leaflet-dragging .leaflet-grab,
#map .leaflet-dragging .leaflet-container {
  cursor: grabbing !important;
}
