/* ================================================================
   fabricso Loop — global.css
   Übergreifendes Layout-System: wirkt auf ALLE Seiten automatisch.
   Geladen in layout_top.php nach components.css.

   Inhalt:
   1. Container & Page-Wrapper
   2. Section-System (Abschnitte mit Spacing)
   3. Utility-Klassen
   4. Karten-System (übergreifend)
   5. Inserat-Karten (Marktplatz)
   6. Dashboard-Layout Verbesserungen
   7. Formulare (übergreifend)
   8. Tabellen (übergreifend)
   9. Badges & Tags
  10. Leerseiten (Empty States)
  11. Responsive (global)
================================================================ */

/* ── 1. Container & Page-Wrapper ───────────────────────────── */

/* Standard-Container (volle Breite mit max-width) */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--sp-6);
}

/* Breiterer Container für Marktplatz / Content-Seiten */
.container--wide {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--sp-6);
}

/* Schmaler Container für Auth / Formulare */
.container--narrow {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 var(--sp-4);
}

/* Page-Padding (Standard für alle Nicht-Dashboard-Seiten) */
.page-body {
  padding: var(--sp-8) 0 var(--sp-16);
}

/* ── 2. Section-System ──────────────────────────────────────── */

.section {
  padding: var(--sp-16) 0;
}
.section--sm  { padding: var(--sp-8) 0; }
.section--lg  { padding: var(--sp-20) 0; }
.section--xl  { padding: var(--sp-24) 0; }

.section--bg-light { background: var(--surface); }
.section--bg-green {
  background: linear-gradient(135deg, var(--green-800), var(--green-600));
  color: var(--white);
}
.section--bg-dark { background: var(--ink); color: var(--white); }

.section__header {
  text-align: center;
  max-width: 640px;
  margin: 0 auto var(--sp-10);
}
.section__eyebrow {
  display: inline-block;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: var(--sp-2);
}
.section--bg-green .section__eyebrow { color: rgba(255,255,255,.7); }
.section__title {
  font-family: var(--font-head);
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: var(--sp-3);
}
.section__sub {
  font-size: 1rem;
  color: var(--muted);
  line-height: 1.7;
}
.section--bg-green .section__sub { color: rgba(255,255,255,.75); }

/* ── 3. Utility-Klassen ─────────────────────────────────────── */

/* Flexbox */
.flex        { display: flex; }
.flex-col    { display: flex; flex-direction: column; }
.items-center{ align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

/* Spacing */
.mt-2  { margin-top: var(--sp-2); }
.mt-4  { margin-top: var(--sp-4); }
.mt-6  { margin-top: var(--sp-6); }
.mt-8  { margin-top: var(--sp-8); }
.mb-2  { margin-bottom: var(--sp-2); }
.mb-4  { margin-bottom: var(--sp-4); }
.mb-6  { margin-bottom: var(--sp-6); }
.mb-8  { margin-bottom: var(--sp-8); }

/* Text */
.text-center { text-align: center; }
.text-muted  { color: var(--muted); }
.text-primary{ color: var(--primary); }
.text-success{ color: var(--success); }
.text-danger { color: var(--danger); }
.text-sm     { font-size: .875rem; }
.text-xs     { font-size: .75rem; }
.font-bold   { font-weight: 700; }
.font-head   { font-family: var(--font-head); }

/* Sichtbarkeit */
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── 4. Karten-System ───────────────────────────────────────── */

/* Basis-Karte */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
}
.card--hover {
  transition: transform .2s, box-shadow .2s, border-color .2s;
  cursor: pointer;
}
.card--hover:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(15,23,42,.1);
  border-color: var(--border-2);
}
.card__body    { padding: var(--sp-5); }
.card__header  { padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); }
.card__footer  { padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); background: var(--surface); }

/* ── 5. Inserat-Karten (global, überarbeitet) ───────────────── */

/* Ersetzt .inserate-grid aus layout.css mit besserem Grid */
.inserate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-5);
}

/* Inserat-Karte */
.inserat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.inserat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(15,23,42,.09);
  border-color: var(--border-2);
}
.inserat-card.stock-type {
  border-color: rgba(5,150,105,.25);
}

/* Bild-Bereich */
.inserat-img {
  position: relative;
  aspect-ratio: 16/10;
  overflow: hidden;
  background: var(--surface);
}
.inserat-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s;
  display: block;
}
.inserat-card:hover .inserat-img img { transform: scale(1.04); }

.img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--subtle);
  background: var(--surface);
}

/* Karten-Body */
.inserat-body {
  padding: var(--sp-3) var(--sp-4) var(--sp-2);
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Kategorie-Label */
.inserat-cat {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: var(--sp-1);
}

/* Titel */
.inserat-title {
  font-family: var(--font-head);
  font-size: .9375rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
  margin: 0 0 var(--sp-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.inserat-title a { color: inherit; text-decoration: none; }
.inserat-title a:hover { color: var(--primary); }

/* Spec-Chips */
.inserat-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: var(--sp-2);
}
.inserat-spec {
  font-size: .7rem;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 2px 7px;
  white-space: nowrap;
}

/* CO₂ Hinweis */
.inserat-co2-hint {
  font-size: .75rem;
  color: var(--success);
  font-weight: 600;
  margin-bottom: var(--sp-2);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Anbieter */
.inserat-vendor {
  font-size: .75rem;
  color: var(--muted);
  margin-top: auto;
  padding-top: var(--sp-1);
}

/* Karten-Footer */
.inserat-footer {
  padding: var(--sp-2) var(--sp-4) var(--sp-3);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  background: var(--surface);
}

/* Preis */
.inserat-price {
  font-family: var(--font-head);
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--ink);
}
.inserat-price-unit {
  font-size: .75rem;
  color: var(--muted);
  font-weight: 500;
}
.inserat-price-lock {
  font-size: .8rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Badges auf Bild */
.card-featured-badge,
.card-stock-badge {
  position: absolute;
  top: 10px; left: 10px;
  background: linear-gradient(135deg, var(--green-700), var(--green-500));
  color: var(--white);
  font-size: .625rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--r-full);
  letter-spacing: .05em;
  z-index: 2;
}
.inserat-tons-badge {
  position: absolute;
  bottom: 8px; right: 8px;
  background: rgba(6,95,70,.85);
  color: var(--white);
  font-size: .7rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--r-full);
  backdrop-filter: blur(4px);
  z-index: 2;
}

/* ── 6. Dashboard-Layout (übergreifend verbessert) ──────────── */

/* Dashboard-Grid: Sidebar + Main */
.dashboard-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - var(--nav-h));
}

/* Dash-Hauptbereich */
.dash-main {
  padding: var(--sp-6);
  overflow-x: hidden;
  max-width: 100%;
}

/* Dash-Topbar */
.dash-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-6);
  gap: var(--sp-4);
  flex-wrap: wrap;
}
.dash-topbar h1 {
  font-family: var(--font-head);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ink);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* Stat-Grid */
.stat-grid {
  display: grid;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}
.stat-grid-2 { grid-template-columns: repeat(2, 1fr); }
.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat-grid-4 { grid-template-columns: repeat(4, 1fr); }

.stat-box {
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  background: var(--white);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
.stat-box:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  border-radius: var(--r-xs) 0 0 var(--r-xs);
}
.stat-box.green::before  { background: var(--primary); }
.stat-box.blue::before   { background: var(--info); }
.stat-box.gold::before   { background: var(--warning); }
.stat-box.teal::before   { background: var(--teal, #0d9488); }
.stat-box.red::before    { background: var(--danger); }
.stat-box.purple::before { background: #7c3aed; }

.stat-icon {
  font-size: 1.25rem;
  margin-bottom: var(--sp-1);
}
.stat-val {
  font-family: var(--font-head);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1;
}
.stat-lbl {
  font-size: .8rem;
  color: var(--muted);
  font-weight: 500;
}

/* Dash-Karte */
.dash-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  margin-bottom: var(--sp-5);
  overflow: hidden;
}
.dash-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.dash-card-head h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  font-family: var(--font-head);
}
.dash-card-body { padding: var(--sp-5); }

/* ── 7. Formulare (übergreifend) ────────────────────────────── */

/* Fieldset-ähnliche Sektion */
.form-section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  margin-bottom: var(--sp-4);
  overflow: hidden;
}
.form-section-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.form-section-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  font-size: .8125rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--font-head);
}
.form-section-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}
.form-section > .form-group,
.form-section > .form-row {
  padding: 0 var(--sp-5);
}
.form-section > .form-group:last-child,
.form-section > .form-row:last-child {
  padding-bottom: var(--sp-5);
}

/* ── 8. Tabellen (übergreifend) ─────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.data-table th {
  background: var(--surface);
  color: var(--muted);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  color: var(--ink-3);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface); }
.data-table tbody tr { transition: background .1s; }

/* ── 9. Badges & Tags ───────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-success  { background: var(--success-l); color: var(--success); }
.badge-warning  { background: var(--warning-l); color: var(--warning); }
.badge-danger   { background: var(--danger-l);  color: var(--danger); }
.badge-info     { background: var(--info-l);    color: var(--info); }
.badge-muted    { background: var(--surface);   color: var(--muted); border: 1px solid var(--border); }
.badge-primary  { background: var(--primary-l); color: var(--primary); }
.badge-warning  { background: var(--warning-l); color: var(--warning); }

/* Status-Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-active   { background: #dcfce7; color: #166534; }
.status-inactive { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.status-draft    { background: #fffbeb; color: #92400e; }
.status-pending  { background: #eff6ff; color: #1d4ed8; }
.status-sold     { background: #f5f3ff; color: #5b21b6; }
.status-active::before   { content: '●'; font-size: .5rem; color: #16a34a; }
.status-inactive::before { content: '●'; font-size: .5rem; color: var(--muted); }
.status-draft::before    { content: '●'; font-size: .5rem; color: #d97706; }
.status-pending::before  { content: '●'; font-size: .5rem; color: #2563eb; }
.status-sold::before     { content: '●'; font-size: .5rem; color: #7c3aed; }

/* ── 10. Empty States ───────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--sp-16) var(--sp-8);
}
.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--sp-4);
  opacity: .5;
}
.empty-state p {
  color: var(--muted);
  font-size: .9375rem;
  margin-bottom: var(--sp-4);
  max-width: 320px;
}

/* ── 11. Listing-Seite (global) ─────────────────────────────── */

/* Horizontale Filter-Leiste (übergreifend nutzbar) */
.filterbar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: calc(var(--nav-h) + 8px);
  z-index: 100;
  margin-bottom: var(--sp-4);
}

/* Kategorie-Pills (horizontal scroll) */
.cat-pills {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
  flex-wrap: nowrap;
  margin-bottom: var(--sp-4);
}
.cat-pills::-webkit-scrollbar { display: none; }

.cat-pill {
  flex-shrink: 0;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-size: .8125rem;
  font-weight: 500;
  color: var(--ink-3);
  text-decoration: none;
  background: var(--white);
  transition: all .15s;
  white-space: nowrap;
}
.cat-pill:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.cat-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
  font-weight: 600;
}

/* ── 12. Responsive (global) ────────────────────────────────── */

@media (max-width: 1280px) {
  .stat-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .inserate-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}

@media (max-width: 1024px) {
  .dashboard-layout { grid-template-columns: 200px 1fr; }
  .stat-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .container, .container--wide { padding: 0 var(--sp-4); }
}

@media (max-width: 768px) {
  /* Dashboard: Sidebar oben, Main unten */
  .dashboard-layout {
    grid-template-columns: 1fr;
  }
  .dash-main { padding: var(--sp-4); }
  .dash-topbar { gap: var(--sp-3); }
  .dash-topbar h1 { font-size: 1.25rem; }

  /* Stats */
  .stat-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .stat-grid-4 { grid-template-columns: repeat(2, 1fr); }

  /* Inserate */
  .inserate-grid { grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }

  /* Tabellen */
  .data-table th { padding: var(--sp-2) var(--sp-3); }
  .data-table td { padding: var(--sp-2) var(--sp-3); }

  /* Container */
  .container, .container--wide { padding: 0 var(--sp-3); }

  /* Filterbar */
  .filterbar { position: static; border-radius: var(--r-lg); }

  /* Buttons volle Breite auf Mobile */
  .btn-full-mobile { width: 100%; }
}

@media (max-width: 480px) {
  .stat-grid-2, .stat-grid-3, .stat-grid-4 { grid-template-columns: 1fr; }
  .inserate-grid { grid-template-columns: 1fr; }
  .dash-main { padding: var(--sp-3); }
}
