/* ==========================================================================
   Sägeblatt-Datenbank BS25 – Stylesheet
   Gliederung:
     1. Grundlagen (Reset, Variablen, Body)
     2. Links
     3. Header
     4. Layout (Sidebar, Panels, Main)
     5. Überschriften
     6. Tabelle
     7. Reset-Kreuz
   ========================================================================== */


/* ==========================================================================
   1. Grundlagen
   ========================================================================== */

* { box-sizing: border-box; }

:root {
  /* Farbpalette */
  --anthrazit:    #2f3136; /* 2f3136; */
  --col_dunkel:   #333; /* 7e5eb3; */
  --col_mittel:   #999; /* 9b86bd; */
  --col_hell:     #aaa; /* c9bbdf; */
  --col_ganzhell: #dcdcdc; /* e9defa; */
  --weiss:        #fff;
  --text:         #000;
  --text_selected: #800;
  --col_select:		  #54a645;
  --col_select_schwach:	#8ea68a;
}

body {
  margin: 0;
  padding: 10px;
  font-family: sans-serif;
  font-size: 10pt;
  background: var(--weiss);
  color: var(--text);
}


/* ==========================================================================
   2. Links
   Farbe bleibt in allen Zuständen schwarz, nur beim Hover Lavendel
   ========================================================================== */

a, a:link, a:visited, a:active, a:focus {
  color: var(--text);
  font-weight: bold;
  text-decoration: none;
  cursor: default;
}

a:hover {
  color: var(--text_selected);
}




/* ==========================================================================
   3. Header: Logo links, Titel mittig, Logo rechts
   ========================================================================== */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  margin-bottom: 5px;
  background: var(--col_ganzhell);
  border-radius: 3px;
}

header img {
  height: 30px;
  object-fit: contain;
}

.titel {
  flex: 1;
  text-align: center;
}

.titel h1 {
  margin: 0;
  font-size: 14pt;
  font-weight: bold;
  text-align: center;
  color: #000;
}

.titel h2 {
  margin: 0;
  font-size: 13pt;
  font-weight: bold;
  text-align: center;
  color: var(--col_mittel);
}


/* ==========================================================================
   4. Layout: Sidebar (Navigation + Filter-Panel) und Hauptbereich
   ========================================================================== */

.layout {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

/* Linke Spalte: Panels untereinander */
.sidebar {
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Navigation / Panel */
.panel {
  padding: 10px;
  display: flex;
  margin-bottom: 5px;
  /*flex-direction: column;*/
  gap: 8px;
  background: var(--col_select_schwach);
  border-radius: 3px;
}

/* Filter-Panel: gleicher Hintergrund wie .panel,
   der Inhalt wird aber nicht als Flex-Stapel angeordnet */
.panel_filter {
  display: block;
}

.panel_filter select {
  width: 100%;
  margin-bottom: 6px;
}

/* Hauptbereich */
main {
  flex: 1;
  min-width: 0;            /* verhindert, dass breite Tabellen das Layout sprengen */
  padding: 10px;
  background: var(--col_ganzhell);
  border-radius: 3px;
}

main b {
  font-size: 13pt;
  font-weight: bold;
  background: var(--col_hell);
}

/* ==========================================================================
   5. Überschriften im Hauptbereich
   ========================================================================== */

h1 {
  margin: 0;
  font-size: 16pt;
  font-weight: bold;
  text-align: center;
  color: #000;
  flex: 1;
}


/* ==========================================================================
   6. Tabelle
   ========================================================================== */

table {
  border-collapse: collapse;       /* verhindert doppelte Linien */
  border: 1px solid black;
}

th, td {
  border: 1px solid black;
  padding: 3px;
}

/* --- Kopfzeile 1: Logos / Überschriften --- */
thead th {
  background: var(--weiss);
}

thead th a {
  display: inline-block;
}

thead th a img {
  display: block;
  margin: 0 auto;
}

/* --- Kopfzeile 2: Filter (etwas heller abgesetzt) --- */
thead tr.filterzeile th {
  background: var(--col_hell);
  padding: 4px;
}

thead tr.filterzeile select {
  width: 125px;
}

/* --- Zeilen im Tabellenkörper: abwechselnd hell/weiß --- */
tbody tr:nth-child(odd)  { background: var(--col_ganzhell); }
tbody tr:nth-child(even) { background: var(--weiss); }

/* --- Ausgegraute Zeilen (z. B. beim Schärfen) --- */
tr.ausgegraut td {
  color: var(--anthrazit);
  opacity: 0.4;
}
tr.ausgegraut .grundriss-popup {
    opacity: 1;
    filter: none;
    color: initial;
}

tr.headline td{
	background: var(--col_dunkel);
	color:  #fff;
}


/* --- Erste Spalte (Reset-Kreuz): so schmal wie möglich --- */
thead th:first-child,
tbody td:first-child {
  width: 1%;
  text-align: center;
  white-space: nowrap;
}


/* ==========================================================================
   7. Reset-Kreuz (Filter zurücksetzen) mit sofort sichtbarem Hover-Text
   ========================================================================== */

a.reset {
  position: relative;
  display: inline-block;
  width: 24px;
  height: 24px;
  line-height: 24px;
  text-align: center;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}

/* Hover: rot hinterlegt, weißes Kreuz, leicht vergrößert */
a.reset:hover {
  background: #c0392b;
  color: #fff;
  transform: scale(1.2);
}

/* Hover-Text "Zurücksetzen" (Text kommt aus data-hinweis im HTML) */
a.reset::after {
  /*content: attr(data-hinweis);*/
  position: absolute;
  left: 50%;
  top: 100%;
  margin-top: 6px;
  transform: translateX(-50%);
  background: var(--anthrazit);
  color: #fff;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10pt;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 10;
}

a.reset:hover::after {
  opacity: 1;
}

/* Link als hinterlegte Fläche über die ganze Breite*/
a.background {
  display: block;                 /* nimmt die volle Breite, Padding wirkt auf alle Seiten */
  padding: .72rem;                /* Innenabstand, damit der Hintergrund eine Fläche bildet */
  background: var(--col_select);
  text-decoration: none;          /* keine Unterstreichung */
  font-weight: 700;
}

/* ==========================================================================
   Zeilenlink (ganze Tabellenzeile klickbar) und Detailseite
   ========================================================================== */

/* Link füllt die komplette Zelle, damit die ganze Zeile klickbar wirkt */
td a.zeilenlink {
  display: block;
  padding: 3px;
  margin: -3px;            /* hebt das td-Padding auf, Link deckt die ganze Zelle ab */
  font-weight: normal;
  color: inherit;
}

/* Hover: ganze Zeile hervorheben */
tbody tr:hover {
  background: var(--col_select);
}

/* Detail-Tabelle */
/* Detail-Tabelle: keine abwechselnden Zeilenfarben */
table.detail {
  width: 100%; 
  min-width: 850px; 
  table-layout: fixed;
}
table.detail tbody tr:nth-child(odd),
table.detail tbody tr:nth-child(even) {
  background: var(--weiss);
}

/* Hover in der Detail-Tabelle nicht hervorheben (nicht klickbar) */
table.detail tbody tr:hover {
  background: var(--weiss);
}

table.detail th {
  background: var(--col_ganzhell);
  text-align: left;
  white-space: nowrap;
}

/* Abschnittsüberschriften (Hersteller-Angaben, Parameter, ...) */
table.detail th.abschnitt {
  background: var(--col_dunkel);
  color: var(--weiss);
}


.grundriss-wrap { 
	display: inline; 
	font-weight: bold;
}

/* Checkbox verstecken, bleibt aber funktional */
.grundriss-toggle {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.grundriss-trigger {
    cursor: pointer;
    margin-left: .5em;
    user-select: none;
}

/* Grafik: mittig auf der Seite, standardmäßig unsichtbar */
.grundriss-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    display: none;
    cursor: pointer;
    padding: 8px;
    background: #fff;
    border: 1px solid #888;
    box-shadow: 0 0 0 100vmax rgba(0,0,0,.4), 0 10px 40px rgba(0,0,0,.5);
}
.grundriss-popup img {
    display: block;
    max-width: 90vw;
    max-height: 90vh;
}

/* Hover auf den Trigger -> anzeigen (Popup selbst hat pointer-events: none, solange nur gehovert wird) */
.grundriss-trigger:hover + .grundriss-popup {
    display: block;
    pointer-events: none;
}

/* Angeklickt -> bleibt stehen und ist klickbar zum Schließen */
.grundriss-toggle:checked ~ .grundriss-popup {
    display: block;
    pointer-events: auto;
}


/* Wrapper um Bild + Marker: so groß wie das Bild, Bezugspunkt für den Kreis */
.grundriss-bild {
    position: relative;
    display: block;
}

.grundriss-marker {
    position: absolute;
    width: 30px;
    height: 30px;
    transform: translate(-50%, -50%);   /* Mittelpunkt statt linke obere Ecke */
    border: 4px solid red;
    border-radius: 50%;
    background: rgba(255, 0, 0, .2);
    box-shadow: 0 0 0 2px #fff;
    pointer-events: none;
    animation: marker-puls 1.4s ease-out infinite;
}

@keyframes marker-puls {
    0%   { box-shadow: 0 0 0 2px #fff, 0 0 0 0 rgba(255,0,0,.6); }
    100% { box-shadow: 0 0 0 2px #fff, 0 0 0 20px rgba(255,0,0,0); }
}
/* ANPASSEN: projektspezifische Layoutregeln */

/* ANPASSEN: responsive Kopfzeile und Verwaltungsansichten des modularen Neuaufbaus. */
.iconzeile th { height: 82px; text-align: center; vertical-align: middle; }
.kopf-icon { max-width: 76px; max-height: 76px; object-fit: contain; }
.verwendung-icon { max-width: 76px; max-height: 76px; object-fit: contain; vertical-align: middle; }
.icon-fallback { font-size: .82rem; font-weight: 700; }
.table-scroll { max-width: 100%; overflow-x: auto; }
.editor-layout, .crud-layout { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(300px, 2fr); gap: 12px; align-items: start; }
.crud-layout { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); }
.crud-list { overflow-x: auto; }
.crud-form, .editor-layout form, .crud-form label, .form-grid label { display: grid; gap: 1px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(120px,1fr)); gap: 2px; }
.new-entry, .neuer-eintrag td { text-align: center; background: var(--col_select_schwach); font-weight: bold; }
.meldung { padding: 9px; background: #fff4cc; border-left: 4px solid #a87900; }
.planbild, .position-image { position: relative; width: min(100%, 1100px); margin: 10px auto; }
.planbild img, .position-image img { display: block; width: 100%; height: auto; }
.plan-fehlt { min-height: 140px; display: grid; place-items: center; padding: 20px; border: 2px dashed #777; background: #eee; text-align: center; }
.ort-marker { position: absolute; transform: translate(-50%,-50%); display: block; width: 20px; height: 20px; border: 3px solid #a00; border-radius: 50%; background: #ff444477; z-index: 2; cursor: pointer; }
.ort-marker > span:first-child { position: absolute; left: 17px; top: -5px; white-space: nowrap; padding: 2px 5px; background: #fff; border: 1px solid #777; border-radius: 3px; }
.ort-popup { display: none; position: absolute; left: 20px; top: 18px; z-index: 5; width: 220px; padding: 9px; background: #fff; border: 1px solid #777; box-shadow: 0 4px 15px #3336; color: #111; }
.ort-popup img { max-width: 100%; max-height: 130px; object-fit: contain; }
.ort-marker:hover .ort-popup, .ort-marker:focus .ort-popup { display: grid; gap: 5px; }
.ort-marker-back { position: absolute; transform: translate(-50%,-50%); width: 18px; height: 18px; border: 2px solid #b00; background: #f004; border-radius: 50%; pointer-events: none; }
.ort-marker-back.selected { width: 28px; height: 28px; border: 4px solid #05a; background: #08f5; }
.position-image { cursor: crosshair; }
@media(max-width:750px) { .editor-layout,.crud-layout { grid-template-columns: 1fr; } }

/* Suchliste: identische Spaltenbreiten, Icons sind direkt die Sortierknöpfe. */
.such-tabelle { width: 100%; min-width: 850px; table-layout: fixed; }
.such-tabelle col { width: calc(100% / 13); }
.such-tabelle thead th, .such-tabelle tbody td { box-sizing: border-box; overflow-wrap: anywhere; }
.such-tabelle .iconzeile th { height: 88px; padding: 4px; text-align: center; vertical-align: middle; }
.such-tabelle .sort-button { position: relative; display: flex; width: 100%; min-height: 74px; align-items: center; justify-content: center; color: inherit; text-decoration: none; }
/*.such-tabelle .sort-button:hover, .such-tabelle .sort-button:focus-visible { outline: 2px solid #176b87; outline-offset: -2px; }*/
.such-tabelle .kopf-icon { max-width: 70px; max-height: 70px; }
.such-tabelle .sort-arrow { position: absolute; right: 2px; bottom: 0; font-size: .72rem; font-weight: 700; }
.such-tabelle tr.filterzeile th { height: 38px; padding: 3px; text-align: center; }
.such-tabelle tr.filterzeile select, .such-tabelle tr.filterzeile input { width: 100%; min-width: 0; box-sizing: border-box; }
.such-tabelle .filterzeile .reset { font-size: 1.15rem; color: #8b1e1e; text-decoration: none; }
.such-tabelle tbody td.rechts { text-align: right; }
.such-tabelle tbody td.zentriert { text-align: center; }
.such-tabelle tbody td:first-child, .such-tabelle thead th:first-child { display: table-cell; position: static; }
.maschine-hover { position: relative; cursor: help; border-bottom: 1px dotted currentColor; }
.maschine-popup { display: none; position: relative; left: 0; top: 1.35em; z-index: 20; width: 230px; padding: 8px; background: #fff; border: 1px solid #71828b; box-shadow: 0 4px 14px #0003; text-align: left; }
.maschine-popup img { display: block; max-width: 210px; max-height: 130px; object-fit: contain; }
.maschine-hover:hover .maschine-popup, .maschine-hover:focus .maschine-popup { display: grid; gap: 4px; }



.such-tabelle th:first-child,
.such-tabelle td:first-child {
    width: 40px !important;
    min-width: 40px;
    max-width: 100px;
    padding-left: 0;
    padding-right: 0;
    overflow: hidden;
    box-sizing: border-box;
}
/* Backend-Eingabe: an Frontend-Detailgruppen angelehnt. */
.editor-layout .form-section { min-width: 0; margin: 0 0 1rem; padding: .35rem; border: 2px solid var(---col_dunkel); border-radius: .5rem; }
.editor-layout .form-section legend { padding: 0 0rem; font-weight: 700; }
.editor-layout .checkbox-field { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: .5rem; }
.editor-layout .checkbox-field input { width: auto; }
.saw-photo-preview { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.saw-photo-preview img { width: 5rem; height: 5rem; object-fit: cover; border-radius: .25rem; }

.editor-layout .field input[type="checkbox"] { width: auto; justify-self: start; }

/* Spaltenkommentare in der Suchen-Liste: separate Kopfzeile zwischen Icons und Filtern. */
.kommentarzeile th{font-size:.72rem;font-weight:400;color:#555;line-height:1.2;padding:.2rem .3rem}

/* Sägeblatt-Eingabe erhält bewusst nur die halbe Inhaltsbreite; Liste bleibt kompakt. */
.editor-layout { width: 100%; grid-template-columns: minmax(90px, .7fr) minmax(0, 3fr); }
.editor-layout > div { min-width: 0; overflow-x: auto; }
.editor-layout .record-list { width: 100%; table-layout: fixed; }
.editor-layout .record-list td { overflow-wrap: anywhere; padding: .25rem; }

/* Feedbacklisten nebeneinander, ohne Formular- oder Bearbeitungsaktionen. */
.feedback-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.feedback-list { min-width: 0; }
.feedback-list table { width: 100%; }

@media(max-width:750px) { .editor-layout { width: 100%; } .feedback-columns { grid-template-columns: 1fr; } }

/* Direktlink aus der Detailansicht zum vorausgewählten Feedbackformular. */
.feedback-link { display: inline-block; padding: .6rem .9rem; background: #54a645; color: #000; font-weight: 700; text-decoration: none; border-radius: .2rem; }
.feedback-abschnitt { margin: 1rem 0; padding: .5rem; border: 1px solid #aaa; }



button {
  display: inline-block; padding: .6rem .9rem; background: #54a645; color: #000; font-weight: 700; text-decoration: none; border-radius: .2rem;
}

/* Sägeblatt-Eingabe: linke Spalte = Liste, rechte Spalte = Formular */
.editor-layout {
  display: grid;                  /* ohne das wirkt grid-template-columns nicht */
  width: 100%;
  gap: 1rem;
  /* Liste braucht genug Platz für 3 Spalten: Mindestbreite erhöhen */
  grid-template-columns: minmax(220px, .9fr) minmax(0, 3fr);
}
.editor-layout > div { min-width: 0; overflow-x: auto; }

.editor-layout .record-list { width: 100%; table-layout: fixed; }
.editor-layout .record-list td {
  padding: .25rem;
  overflow: hidden;
  text-overflow: ellipsis;        /* zu langer Text wird mit "…" gekürzt statt zu überlappen */
  white-space: nowrap;
}

/* Spaltenbreiten der Liste (Summe = 100 %) */
.record-list .col-wzid  { width: 10%; }
.record-list .col-herst { width: 50%; }
.record-list .col-d     { width: 20%; }

/* Alle Eingabeelemente: Padding/Border zählen zur Breite (verhindert Überlappen) */
.form-section input,
.form-section select,
.form-section textarea {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;                  /* erlaubt Schrumpfen innerhalb des Grids */
}

/* Felder-Raster: so viele Spalten wie Platz ist, jede mind. 180px breit.
   auto-fit sorgt dafür, dass bei wenig Platz automatisch umgebrochen wird,
   statt dass Felder sich überlappen. */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .2rem 1rem;
}

/* Jedes Feld (Label + Input) darf im Grid schrumpfen */
.form-grid > * {
  min-width: 0;
}

/* Fieldset-Eigenheit: hat standardmäßig min-width: min-content und sprengt Layouts */
.form-section {
  min-width: 0;
  border: 1px solid var(--col_select_schwach);
  margin: 0 0 0rem;
  padding: .2rem;
}


/* Abschnitts-Überschrift: farbig hinterlegt über die volle Breite */
.form-section-title {
  float: left;                    /* Trick: legend wird dadurch zu einem normalen Block */
  width: 100%;
  box-sizing: border-box;
  padding: .1rem .2rem;
  margin-bottom: .0rem;
  background: var(--col_select);
  font-weight: 700;
}

/* Das erste Element nach der Legend muss das Float "aufheben" */
.form-section-title + * {
  clear: both;
}
