/**
 * Bauherrenportal — Wiederverwendbare Komponenten-Klassen
 *
 * Ersetzt die haeufigsten Inline-Style-Muster in Admin/Portal-Views.
 *
 * Laden nach admin.css / portal.css:
 *   <link rel="stylesheet" href="/css/admin.css?v=41">
 *   <link rel="stylesheet" href="/css/bp-components.css?v=1">
 *
 * Tokens (aus admin.css/portal.css): --fs-*, --space-*, --r-*, --bp-*, --status-*
 */

/* ========== Layout & Container ========== */

.bp-card {
  background: var(--bp-surface);
  border: 1px solid var(--bp-border);
  border-radius: var(--r-md);
  padding: var(--space-4);
}

.bp-card-tight  { padding: var(--space-3) var(--space-4); }
.bp-card-loose  { padding: var(--space-5) var(--space-6); }
.bp-card-mb     { margin-bottom: var(--space-4); }

/* Farbig markierte Karten (linker Akzent-Border) */
.bp-card-accent-info { border-left: 3px solid var(--status-info); }
.bp-card-accent-ok   { border-left: 3px solid var(--status-ok); }
.bp-card-accent-warn { border-left: 3px solid var(--status-warn); }
.bp-card-accent-err  { border-left: 3px solid var(--status-err); }

/* ========== Flex-Utilities ========== */

.bp-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.bp-row-sm    { gap: var(--space-1); }
.bp-row-md    { gap: var(--space-3); }
.bp-row-lg    { gap: var(--space-4); }
.bp-row-wrap  { flex-wrap: wrap; }

.bp-row-between { justify-content: space-between; }
.bp-row-end     { justify-content: flex-end; }
.bp-row-center  { justify-content: center; }
.bp-row-start   { justify-content: flex-start; }

.bp-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.bp-col-sm { gap: var(--space-1); }
.bp-col-md { gap: var(--space-3); }
.bp-col-lg { gap: var(--space-4); }

.bp-flex-1 { flex: 1; }
.bp-flex-auto { flex: 0 1 auto; }

/* ========== Grid ========== */

.bp-grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}
.bp-grid-cards-sm { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.bp-grid-cards-lg { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.bp-grid-cards-xl { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.bp-grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.bp-grid-3col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-3); }

/* ========== Spacing-Utilities ========== */

.bp-mb-0  { margin-bottom: 0; }
.bp-mb-xs { margin-bottom: var(--space-1); }
.bp-mb-sm { margin-bottom: var(--space-2); }
.bp-mb-md { margin-bottom: var(--space-3); }
.bp-mb-lg { margin-bottom: var(--space-4); }
.bp-mb-xl { margin-bottom: var(--space-5); }

.bp-mt-0  { margin-top: 0; }
.bp-mt-xs { margin-top: var(--space-1); }
.bp-mt-sm { margin-top: var(--space-2); }
.bp-mt-md { margin-top: var(--space-3); }
.bp-mt-lg { margin-top: var(--space-4); }
.bp-mt-xl { margin-top: var(--space-5); }

.bp-m-0 { margin: 0; }
.bp-p-0 { padding: 0; }

/* ========== Text & Typografie ========== */

.bp-text-xs   { font-size: var(--fs-xs); }
.bp-text-sm   { font-size: var(--fs-sm); }
.bp-text-md   { font-size: var(--fs-md); }
.bp-text-base { font-size: var(--fs-base); }
.bp-text-lg   { font-size: var(--fs-lg); }
.bp-text-xl   { font-size: var(--fs-xl); }
.bp-text-2xl  { font-size: var(--fs-2xl); }

.bp-text-bold { font-weight: 700; }
.bp-text-semibold { font-weight: 600; }
.bp-text-normal { font-weight: 400; }

.bp-text-center { text-align: center; }
.bp-text-right  { text-align: right; }
.bp-text-left   { text-align: left; }

.bp-muted         { color: var(--bp-text-muted); }
.bp-text-accent   { color: var(--bp-orange); }
.bp-text-ok       { color: var(--status-ok); }
.bp-text-warn     { color: var(--status-warn); }
.bp-text-err      { color: var(--status-err); }
.bp-text-info     { color: var(--status-info); }

.bp-section-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--bp-text-muted);
  margin: 0 0 var(--space-2);
  font-weight: 700;
}

/* ========== Pills / Badges ========== */

.bp-pill {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  background: color-mix(in srgb, var(--bp-orange) 15%, transparent);
  color: var(--bp-orange);
  line-height: 1.4;
}
.bp-pill-ok      { background: color-mix(in srgb, var(--status-ok)   15%, transparent); color: var(--status-ok); }
.bp-pill-warn    { background: color-mix(in srgb, var(--status-warn) 15%, transparent); color: var(--status-warn); }
.bp-pill-err     { background: color-mix(in srgb, var(--status-err)  15%, transparent); color: var(--status-err); }
.bp-pill-info    { background: color-mix(in srgb, var(--status-info) 15%, transparent); color: var(--status-info); }
.bp-pill-neutral { background: color-mix(in srgb, var(--bp-text-muted) 15%, transparent); color: var(--bp-text-muted); }

/* ========== Display-Utilities ========== */

.bp-hidden   { display: none !important; }
.bp-block    { display: block; }
.bp-inline   { display: inline-block; }
.bp-flex     { display: flex; }
.bp-full-w   { width: 100%; }
.bp-full-h   { height: 100%; }

/* ========== Tabs ========== */

.bp-tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--bp-border);
  margin-bottom: var(--space-4);
  overflow-x: auto;
  scrollbar-width: none;
}
.bp-tabs::-webkit-scrollbar { display: none; }

.bp-tab {
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--bp-text-muted);
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: border-color var(--bp-transition), color var(--bp-transition);
}
.bp-tab.active {
  color: var(--bp-orange);
  border-bottom-color: var(--bp-orange);
}
.bp-tab:hover { color: var(--bp-text); }
.bp-tab:focus-visible {
  outline: 2px solid var(--bp-orange);
  outline-offset: 2px;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}

/* ========== Dashboard-Quick-Buttons (Light-Weight) ========== */

.dash-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--bp-surface);
  border: 1px solid var(--bp-border);
  border-radius: var(--r-md);
  color: var(--bp-text);
  text-decoration: none;
  font-size: var(--fs-sm);
  font-weight: 600;
  transition: border-color var(--bp-transition), background var(--bp-transition);
}
.dash-quick-btn:hover {
  border-color: var(--bp-orange);
  background: var(--bp-surface-2);
}
.dash-quick-btn .dash-quick-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--bp-orange);
}

/* ========== Icon-Container (fuer PR 3 SVG-Migration) ========== */

.bp-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}
.bp-icon-sm { width: 16px; height: 16px; }
.bp-icon-md { width: 20px; height: 20px; }
.bp-icon-lg { width: 24px; height: 24px; }
.bp-icon-xl { width: 32px; height: 32px; }
.bp-icon svg { width: 100%; height: 100%; }

/* ========== Skeleton-Screens (PR 4) ========== */

.bp-skel-card {
  padding: var(--space-4);
  background: var(--bp-surface);
  border: 1px solid var(--bp-border);
  border-radius: var(--r-md);
}

.bp-skel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}

.bp-skel-table-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--bp-border);
}

.bp-skel-square {
  aspect-ratio: 1/1;
  background: linear-gradient(90deg, var(--bp-surface-2), var(--bp-surface), var(--bp-surface-2));
  background-size: 200% 100%;
  animation: bp-skel-pulse 1.5s ease-in-out infinite;
  border-radius: var(--r-md);
}

/* ========== Seiten-Skelett (A.1: drei Ebenen pro Admin-Seite) ========== */

.bp-page-header {
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--bp-border);
}
.bp-page-breadcrumb {
  font-size: var(--fs-xs);
  color: var(--bp-text-muted);
  margin-bottom: var(--space-2);
}
.bp-page-breadcrumb a { color: inherit; text-decoration: none; }
.bp-page-breadcrumb a:hover { color: var(--bp-orange); text-decoration: underline; }
.bp-page-breadcrumb-sep { margin: 0 var(--space-1); opacity: .5; }

.bp-page-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}
.bp-page-meta {
  font-size: var(--fs-sm);
  color: var(--bp-text-muted);
  margin-top: var(--space-1);
}

.bp-page-toolbar {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.bp-page-toolbar-search { flex: 1; min-width: 200px; max-width: 320px; }
.bp-page-toolbar-spacer { flex: 1; }
.bp-page-toolbar-primary { margin-left: auto; }

/* ========== Button-Loading-Spinner (A.7.2) ========== */

.bp-btn-spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: bp-btn-spin .6s linear infinite;
  margin-right: var(--space-1);
  vertical-align: -2px;
}
@keyframes bp-btn-spin { to { transform: rotate(360deg); } }

/* ========== Empty-States (A.8.4) ========== */

.bp-empty {
  text-align: center;
  padding: var(--space-7) var(--space-4);
  color: var(--bp-text-muted);
}
.bp-empty-icon {
  width: 48px; height: 48px;
  margin: 0 auto var(--space-3);
  opacity: .4;
}
.bp-empty-title {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--bp-text);
  margin: 0 0 var(--space-2);
}
.bp-empty-text {
  font-size: var(--fs-sm);
  margin: 0 0 var(--space-4);
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

/* ========== Toast-Container (A.7.1) ========== */

#bp-toast-container {
  position: fixed;
  bottom: var(--space-4);
  right: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 10000;
  max-width: calc(100vw - var(--space-6));
}
@media (max-width: 640px) {
  #bp-toast-container {
    left: var(--space-4);
    right: var(--space-4);
    bottom: var(--space-4);
  }
}
.bp-toast {
  background: var(--bp-surface);
  border: 1px solid var(--bp-border);
  border-radius: var(--r-md);
  padding: var(--space-3) var(--space-4);
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
  min-width: 260px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-sm);
  animation: bp-toast-in .25s ease-out;
}
.bp-toast-ok   { border-left: 4px solid var(--status-ok); }
.bp-toast-warn { border-left: 4px solid var(--status-warn); }
.bp-toast-err  { border-left: 4px solid var(--status-err); }
.bp-toast-info { border-left: 4px solid var(--status-info); }
.bp-toast-close {
  background: none; border: none; color: var(--bp-text-muted);
  cursor: pointer; padding: 0 var(--space-1); font-size: 18px;
  margin-left: auto;
}
.bp-toast-close:hover { color: var(--bp-text); }
@keyframes bp-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ========== Confirm-Dialog (A.7.1) ========== */

.bp-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: bp-toast-in .18s ease-out;
}
.bp-confirm-dialog {
  background: var(--bp-surface);
  border: 1px solid var(--bp-border);
  border-radius: var(--r-lg);
  max-width: 440px;
  width: 100%;
  padding: var(--space-5);
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.bp-confirm-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  margin: 0 0 var(--space-2);
}
.bp-confirm-msg {
  font-size: var(--fs-sm);
  color: var(--bp-text-muted);
  margin: 0 0 var(--space-4);
  line-height: 1.5;
}
.bp-confirm-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}

/* ========== Details/Summary Accordion (A.3.1 Mobile) ========== */

.bp-accordion summary {
  cursor: pointer;
  list-style: none;
  padding: var(--space-3) var(--space-4);
  background: var(--bp-surface);
  border: 1px solid var(--bp-border);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: var(--fs-md);
  margin-bottom: var(--space-2);
  transition: border-color var(--bp-transition);
}
.bp-accordion summary::-webkit-details-marker { display: none; }
.bp-accordion summary::after {
  content: '▸';
  color: var(--bp-text-muted);
  font-size: var(--fs-sm);
  transition: transform var(--bp-transition);
}
.bp-accordion[open] summary::after { transform: rotate(90deg); }
.bp-accordion summary:hover { border-color: var(--bp-orange); }
.bp-accordion > div { padding: var(--space-2) 0 var(--space-4); }

/* ========== Sortable Table-Headers (Sprint K) ========== */

th[data-sort] {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: calc(var(--space-4) + 14px) !important;
}
th[data-sort]:hover {
  color: var(--bp-orange);
}
th[data-sort]::after {
  content: '';
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: .25;
}
th[data-sort][aria-sort="ascending"]::after {
  border-top: none;
  border-bottom: 5px solid var(--bp-orange);
  opacity: 1;
}
th[data-sort][aria-sort="descending"]::after {
  border-bottom: none;
  border-top: 5px solid var(--bp-orange);
  opacity: 1;
}

/* ========== Settings-Sidebar-Nav (Sprint A) ========== */

.bp-settings-nav {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--bp-border);
  margin-bottom: var(--space-4);
  overflow-x: auto;
  scrollbar-width: none;
}
.bp-settings-nav::-webkit-scrollbar { display: none; }
.bp-settings-nav-link {
  padding: var(--space-3) var(--space-4);
  color: var(--bp-text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: border-color var(--bp-transition), color var(--bp-transition);
}
.bp-settings-nav-link.active {
  color: var(--bp-orange);
  border-bottom-color: var(--bp-orange);
}
.bp-settings-nav-link:hover { color: var(--bp-text); }
.bp-settings-nav-link:focus-visible {
  outline: 2px solid var(--bp-orange);
  outline-offset: 2px;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}

@media (min-width: 1024px) {
  /* Desktop: horizontale Tab-Leiste, alle Sections sichtbar, Scroll-Spy highlightet */
  .bp-settings-nav {
    position: sticky;
    top: 64px;
    background: var(--bp-bg);
    z-index: 10;
  }
}
