/* ==========================================================================
   Cesra Tabellen – Stylesheet
   Gehört zum Plugin "Cesra Tabellen" und wird automatisch geladen.

   Farben nicht hier ändern, sondern unter
   Einstellungen -> Cesra Tabellen. Die dortigen Werte überschreiben
   die Variablen weiter unten.
   ========================================================================== */

:root {
  --cesra-gruen-dunkel:  #1e4d1e;
  --cesra-gruen:         #2d6e2d;
  --cesra-rahmen:        #e2e2e2;
  --cesra-rahmen-aussen: #d5d5d5;
  --cesra-zebra:         #f6f9f6;
  --cesra-radius:        8px;
  --cesra-text:          #333333;
}

/* --- Scroll-Container ---------------------------------------------------- */
html body .cesra-table-wrap {
  overflow-x: auto !important;
  overflow-y: visible !important;
  -webkit-overflow-scrolling: touch !important;
  border: 1px solid var(--cesra-rahmen-aussen) !important;
  border-radius: var(--cesra-radius, 8px) !important;
  max-width: 100% !important;
  margin: 0 0 1.8em 0 !important;
}

/* --- Grundgerüst --------------------------------------------------------- */
html body .cesra-table {
  border-collapse: collapse !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  background: #ffffff !important;
  table-layout: auto !important;
}

html body .cesra-table th,
html body .cesra-table td {
  padding: 10px 14px !important;
  border: 1px solid var(--cesra-rahmen) !important;
  vertical-align: top !important;
  text-align: left !important;
  box-sizing: border-box !important;
  line-height: 1.5 !important;
  width: auto !important;
  min-width: 150px !important;
}

/* --- Kopfzeile 1 von 2 (Gruppen-Header) ---------------------------------- */
html body .cesra-table thead tr:first-child:not(:only-child) th,
html body .cesra-table thead tr:first-child:not(:only-child) td {
  background: var(--cesra-gruen-dunkel) !important;
  color: #ffffff !important;
  font-weight: 600 !important;
  text-align: center !important;
}

/* --- Kopfzeile 2 von 2 ODER einzige Kopfzeile ---------------------------- */
html body .cesra-table thead tr:nth-child(2) th,
html body .cesra-table thead tr:nth-child(2) td,
html body .cesra-table thead tr:only-child th,
html body .cesra-table thead tr:only-child td {
  background: var(--cesra-gruen) !important;
  color: #ffffff !important;
  font-weight: 600 !important;
  text-align: left !important;
}

html body .cesra-table thead strong,
html body .cesra-table thead b,
html body .cesra-table thead a {
  color: #ffffff !important;
  font-weight: 600 !important;
}

/* --- Rahmen der Kopfzeile ------------------------------------------------ */
html body .cesra-table thead th,
html body .cesra-table thead td {
  border-color: rgba(255, 255, 255, 0.22) !important;
}
html body .cesra-table thead tr:first-child:not(:only-child) th {
  border-top-color: var(--cesra-gruen-dunkel) !important;
}
html body .cesra-table thead tr:first-child:not(:only-child) th:first-child {
  border-left-color: var(--cesra-gruen-dunkel) !important;
}
html body .cesra-table thead tr:first-child:not(:only-child) th:last-child {
  border-right-color: var(--cesra-gruen-dunkel) !important;
}
html body .cesra-table thead tr:nth-child(2) th:first-child,
html body .cesra-table thead tr:only-child th:first-child {
  border-left-color: var(--cesra-gruen) !important;
}
html body .cesra-table thead tr:nth-child(2) th:last-child,
html body .cesra-table thead tr:only-child th:last-child {
  border-right-color: var(--cesra-gruen) !important;
}
html body .cesra-table thead tr:only-child th {
  border-top-color: var(--cesra-gruen) !important;
}
html body .cesra-table thead tr:last-child th,
html body .cesra-table thead tr:last-child td {
  border-bottom-color: var(--cesra-gruen) !important;
}

/* --- Datenzeilen --------------------------------------------------------- */
html body .cesra-table tbody td {
  color: var(--cesra-text) !important;
}
html body .cesra-table tbody tr:nth-child(odd) td {
  background: #ffffff !important;
}
html body .cesra-table tbody tr:nth-child(even) td {
  background: var(--cesra-zebra) !important;
}

/* --- Erste Spalte feststehend -------------------------------------------- */
html body .cesra-table--sticky-col th:first-child,
html body .cesra-table--sticky-col td:first-child {
  position: sticky !important;
  left: 0 !important;
  z-index: 2 !important;
  min-width: 92px !important;
  max-width: 130px !important;
  white-space: normal !important;
  font-weight: 600 !important;
  font-size: 0.9em !important;
}
html body .cesra-table--sticky-col tbody tr:nth-child(odd) td:first-child {
  background: #ffffff !important;
  color: #444444 !important;
}
html body .cesra-table--sticky-col tbody tr:nth-child(even) td:first-child {
  background: var(--cesra-zebra) !important;
  color: #444444 !important;
}
html body .cesra-table--sticky-col thead tr:first-child:not(:only-child) th:first-child {
  background: var(--cesra-gruen-dunkel) !important;
  z-index: 3 !important;
}
html body .cesra-table--sticky-col thead tr:nth-child(2) th:first-child,
html body .cesra-table--sticky-col thead tr:only-child th:first-child {
  background: var(--cesra-gruen) !important;
  z-index: 3 !important;
}

/* --- Absätze in Zellen --------------------------------------------------- */
html body .cesra-table td p {
  margin: 0 0 0.4em 0 !important;
}
html body .cesra-table td p:last-child {
  margin-bottom: 0 !important;
}
html body .cesra-table td p:empty {
  display: none !important;
}

/* --- Bausteine für manuell gebaute Tabellen ------------------------------ */
html body .cesra-table .cesra-tag,
html body .cesra-table .ht-tag {
  display: inline-block !important;
  font-size: 0.8em !important;
  padding: 2px 8px !important;
  border-radius: 4px !important;
  font-weight: 500 !important;
  white-space: nowrap !important;
}
html body .cesra-table .cesra-tag--yes,
html body .cesra-table .ht-yes  { background: #e8f5e8 !important; color: #2d6e2d !important; }
html body .cesra-table .cesra-tag--no,
html body .cesra-table .ht-no   { background: #fbe9e9 !important; color: #993535 !important; }
html body .cesra-table .cesra-tag--rare,
html body .cesra-table .ht-rare { background: #fff8e1 !important; color: #7a5a00 !important; }

html body .cesra-table .cesra-img-cell,
html body .cesra-table .ht-img-cell {
  text-align: center !important;
  vertical-align: middle !important;
}
html body .cesra-table .cesra-img-cell img,
html body .cesra-table .ht-img-cell img {
  width: 100% !important;
  max-width: 140px !important;
  height: 110px !important;
  object-fit: cover !important;
  border-radius: 6px !important;
  border: 1px solid #ddd !important;
  display: block !important;
  margin: 0 auto !important;
}
html body .cesra-table .cesra-img-label,
html body .cesra-table .ht-img-label {
  font-size: 0.75em !important;
  color: #777777 !important;
  margin-top: 5px !important;
  display: block !important;
}

/* --- Notfall-Fallback ---------------------------------------------------- */
html body .avia_textblock table:not(.cesra-table):not(.avia-table),
html body .elementor-widget-text-editor table:not(.cesra-table),
html body .elementor-widget-container table:not(.cesra-table),
html body .entry-content table:not(.cesra-table):not(.avia-table),
html body .post-entry table:not(.cesra-table):not(.avia-table) {
  display: block !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  border: 1px solid var(--cesra-rahmen-aussen) !important;
  border-radius: var(--cesra-radius, 8px) !important;
  border-collapse: collapse !important;
}
html body .avia_textblock table:not(.cesra-table):not(.avia-table) th,
html body .avia_textblock table:not(.cesra-table):not(.avia-table) td,
html body .elementor-widget-text-editor table:not(.cesra-table) th,
html body .elementor-widget-text-editor table:not(.cesra-table) td,
html body .entry-content table:not(.cesra-table):not(.avia-table) th,
html body .entry-content table:not(.cesra-table):not(.avia-table) td {
  padding: 10px 14px !important;
  border: 1px solid var(--cesra-rahmen) !important;
  width: auto !important;
}

/* --- Mobil --------------------------------------------------------------- */
@media only screen and (max-width: 767px) {
  html body .cesra-table th,
  html body .cesra-table td {
    padding: 8px 10px !important;
    font-size: 0.9em !important;
    min-width: 140px !important;
  }
  html body .cesra-table--sticky-col th:first-child,
  html body .cesra-table--sticky-col td:first-child {
    min-width: 86px !important;
    max-width: 112px !important;
  }
}

/* --- Druck --------------------------------------------------------------- */
@media print {
  html body .cesra-table-wrap {
    overflow: visible !important;
    border: none !important;
  }
  html body .cesra-table th,
  html body .cesra-table td {
    min-width: 0 !important;
  }
  html body .cesra-table--sticky-col th:first-child,
  html body .cesra-table--sticky-col td:first-child {
    position: static !important;
  }
  html body .cesra-table thead th {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}
