/* /css/geo.css
 * Styles aus der ursprünglichen Ein-Datei-Version.
 * (Canvas + Layout + Accordion + kleine UI-Elemente)
 */

:root{
  --border: #ddd;
  --border-soft: #e6e6e6;
  --bg: #fff;
  --text: #111;
  --muted: #666;
  --btn-bg: #f7f7f7;
  --btn-border: #ccc;
  --primary-bg: #e9f2ff;
  --primary-border: #b9d3ff;
}

#geoRoot{
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  margin: 16px;
  color: var(--text);
}


/* Layout */
.geo-main { grid-row: 1; }
.geo-side { grid-row: 1; }

/* Standard: Canvas + Einstellungen nebeneinander */
.wrap{
  display:grid;
  grid-template-columns: 1fr 360px;
  gap:16px;
  align-items:start;
}
.geo-main{ grid-column: 1; min-width: 0; }
.geo-side{ grid-column: 2; min-width: 0; }

/* Linkshänder: Spalten tauschen */
#geoRoot.geo-lefty .wrap{ grid-template-columns: 360px 1fr; }
#geoRoot.geo-lefty .geo-side{ grid-column: 1; }
#geoRoot.geo-lefty .geo-main{ grid-column: 2; }

/* Toggle-Button: nur auf schmal sichtbar */
.geo-side-toggle{
  display: none;
}

/* Schmal (Hochformat / < 900px): untereinander */
@media (max-width: 900px){
  .wrap{ grid-template-columns: 1fr; }

  .geo-side-toggle{
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px;
    background: var(--primary-bg);
    border: 1px solid var(--primary-border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
  }
  .geo-side-toggle:hover{
    background: #d8e8ff;
  }

  /* Inhalt standardmäßig eingeklappt */
  .geo-side-content{
    display: none;
  }
  /* Aufgeklappt durch JS-Klasse */
  .geo-side--open .geo-side-content{
    display: block;
  }
}

/* Cards */
.card{
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: var(--bg);
}

/* Canvas */
canvas{
  border: 1px solid #bbb;
  border-radius: 10px;
  background: #fff;
  width: 100%;
  max-width: 100%;
  height: auto;
  touch-action: none;
  display: block;
  height: calc(100vh - 140px);
}

/* Kleine UI-Teile */
.geo-rowBtn{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

button{
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  cursor: pointer;
}

button.primary{
  background: var(--primary-bg);
  border-color: var(--primary-border);
}

code{
  background: #f3f3f3;
  padding: 2px 6px;
  border-radius: 6px;
}

table{
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 14px;
}

th, td{
  border-bottom: 1px solid #eee;
  padding: 8px 6px;
  text-align: left;
  vertical-align: top;
}

.ok{ color: #126b2a; font-weight: 600; }
.no{ color: #8b1a1a; font-weight: 600; }
.muted{ color: var(--muted); }
.hint{ font-size: 13px; color: #555; margin-top: 6px; }

.pill{
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f2f2f2;
}

/* ========== GEO Accordion (rechte Seitenleiste) ========== */
.geo-accordion details{
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 0;
  background: #fff;
  margin: 10px 0;
  overflow: hidden;
}

.geo-accordion summary{
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 650;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.geo-accordion summary::-webkit-details-marker{
  display: none;
}

.geo-accordion summary::after{
  content: "▾";
  opacity: 0.7;
  font-size: 14px;
  transform: rotate(0deg);
  transition: transform .15s ease;
}

.geo-accordion details[open] summary::after{
  transform: rotate(180deg);
}

.geo-accordion .geo-content{
  border-top: 1px solid #eee;
  padding: 12px;
  color: var(--muted);
  font-size: 14px;
  min-height: 40px;
}

/* Form UI */
.geo-form{ display: flex; flex-direction: column; gap: 10px; }

.geo-presets{ display: flex; gap: 8px; flex-wrap: wrap; }

.geo-btn{
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #d8d8d8;
  background: #f7f7f7;
  cursor: pointer;
  font-size: 13px;
}


.geo-btn:hover{ background: #f1f1f1; }

.geo-grid{ display: grid; gap: 10px; }

.geo-field{
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 10px;
}

.geo-label{ font-weight: 650; margin-bottom: 6px; }

.geo-inline{ display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.geo-mini{ font-size: 12px; color: var(--muted); }

.geo-input{
  width: 90px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #d8d8d8;
  background: #fff;
  font-size: 14px;
}

.geo-hint{ font-size: 13px; }


/* Canvas-Overlay für Tools (Zoom + später Stifte) */
.geo-canvasWrap{
  position: relative;
}

.geo-tools{
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 20;
  background: rgba(255,255,255,0.86);
  border: 1px solid #e6e6e6;
  border-radius: 12px;
  padding: 8px 10px;
  backdrop-filter: blur(4px);
}

.geo-toolsCol{
  display: flex;
  flex-direction: column;
  align-items: flex-end;      /* rechtsbündig */
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.92);
  border: 1px solid #e6e6e6;
  box-shadow: 0 8px 22px rgba(0,0,0,0.08);
  backdrop-filter: blur(6px);
}

.geo-zoom{
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #333;
  user-select: none;
}

.geo-zoomLabel{
  font-weight: 650;
}

#geoZoom{
  width: 140px;
}


/* zum zoomen */
/* Buttons allgemein */
.geo-toolBtn{
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid #d8d8d8;
  background: #f7f7f7;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

/* Zoom-Zeile */
.geo-zoomRow{
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  width: 150px;
}

.geo-zoomLabel{
  font-weight: 600;
}

#geoZoom{
  width: 100px;
}
.geo-toolBtn:hover{ background:#f1f1f1; }

/* Stift-Buttons untereinander */
.geo-toolStack{
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
}


/* CSS-Vollbild: position:fixed statt native Fullscreen API,
   verhindert iPad-Wischgeste beim Zeichnen */
.geo-canvasWrap.is-fullscreen{
  position: fixed;
  inset: 0;
  z-index: 9999;
  width: 100vw;
  height: 100vh;
  background: #fff;
}

.geo-canvasWrap.is-fullscreen canvas{
  width: 100%;
  height: 100%;
}


/* Funktionsfeld bewusst kleiner */
#funcList .geo-f-expr{
  width: 220px;       /* ggf. 180..260 anpassen */
  max-width: 220px;
}

/* "Löschen" bleibt rechts sichtbar */
#funcList .geo-del{
  margin-left: auto;
  margin-left: 0;
}


.geo-drawSection{ display:flex; flex-direction:column; gap:10px; }
.geo-drawHeader{ display:flex; align-items:center; justify-content:space-between; gap:10px; }

.geo-sep{ border:none; border-top:1px solid #eee; margin:12px 0; }

.geo-drawList{ display:flex; flex-direction:column; gap:8px; }

/* Vollbild-Icon kleiner */
.geo-toolBtn--icon{
  padding: 6px 10px;
  font-size: 16px;
}

/* Einklappbare Toolbar */
.geo-toolsToggle {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 2px 4px;
  text-align: right;
  color: #555;
  line-height: 1;
}
.geo-toolsToggle:hover { color: #000; }
.geo-tools.is-collapsed .geo-toolsCol { display: none; }
.geo-tools.is-collapsed { padding: 4px 6px; }

/* aktiver Stift */
.geo-toolBtn--active{
  background:#e8f0ff;
  border-color:#4c7cff;
}

.geo-item{
  border:1px solid #eee;
  border-radius:10px;
  padding:10px;
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
  background:#fff;
}

.geo-item label{ font-size:12px; color:#666; margin-right:4px; }
.geo-item input{
  width:90px;
  padding:8px 10px;
  border-radius:10px;
  border:1px solid #d8d8d8;
  background:#fff;
  font-size:14px;
}

.geo-item .geo-wide{ width:220px; }
.geo-item .geo-del{
  margin-left:auto;
  padding:8px 10px;
  border-radius:10px;
  border:1px solid #d8d8d8;
  background:#f7f7f7;
  cursor:pointer;
  font-size:13px;
}
.geo-item .geo-del:hover{ background:#f1f1f1; }


/* Punktzeile kompakt */
.geo-ptLabel{
  width: 40px !important;
  padding: 6px 8px !important;
  text-transform: uppercase;
  text-align: center;
}

.geo-ptNum{
  width: 30px !important;
  padding: 6px 8px !important;
  text-align: center;
}

.geo-ptFmt{
  margin: 0 4px;
}

.geo-item{
  align-items: center;
  flex-wrap: nowrap;          /* alles in einer Zeile */
  gap: 6px;
}

.geo-item .geo-del{
  margin-left: auto;
}


/* zuz prüfen Text */
.geo-checkNote{
  margin: 6px 0 10px;
}

.geo-checkNote textarea{
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;grid-column: 1 / -1;
  resize: vertical;
  padding: 8px 10px;
  border: 1px solid #d8d8d8;
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height: 1.4; 
}

/* Funktionsbuttons */
/* ===============================
   Funktionen – kompakte Zeile
   =============================== */

.geo-f-row{
  display: flex;
  align-items: center;
  gap: 6px;                 /* ENGE Abstände */
}

/* Checkbox sehr nah an f(x) */
.geo-f-enabled{
  margin: 0;
}

/* f(x)= ohne unnötigen Abstand */
.geo-f-label{
  margin: 0 4px 0 2px;
  font-weight: 600;
}

/* Funktionsfeld: DEUTLICH kleiner */
.geo-f-expr{
  width: 140px;             /* <- ca. Hälfte */
  max-width: 140px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #d8d8d8;
  font-size: 14px;
}

/* Löschen immer sichtbar rechts */
.geo-del{
  margin-left: auto;
}



/* ===============================
   Funktionen – ENGE Spezialregel
   =============================== */

/* Überschreibt das allgemeine .geo-item */
#funcList .geo-item{
  padding: 6px 8px;          /* deutlich weniger */
  gap: 4px;
}

/* Funktions-Zeile */
#funcList .geo-f-row{
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
}

/* Checkbox: KEIN extra Platz */
#funcList .geo-f-enabled{
  margin: 0;
  padding: 0;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  transform: scale(0.95);
}

/* f(x)= ganz nah an Checkbox */
#funcList .geo-f-label{
  margin: 0 2px 0 2px;
  white-space: nowrap;
  font-weight: 600;
}

/* 🔥 Funktionsfeld: JETZT WIRKLICH KLEIN */
#funcList .geo-f-expr{
  width: 110px;              /* <- DEUTLICH kleiner */
  max-width: 110px;
  min-width: 110px;
  padding: 6px 8px;
  font-size: 14px;
}

/* Löschen rechts festnageln */
#funcList .geo-del{
  margin-left: auto;
}


/* ===============================
   Punkte – Checkbox sichtbar
   =============================== */

.geo-pt-row{
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.geo-pt-enabled{
  margin: 0;
  width: 16px;
  height: 16px;
}

.geo-pt-row .geo-del{
  margin-left: auto;
}


/* ===============================
   Objektliste
   =============================== */



.geo-subHead{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-top:12px;
  margin-bottom:8px;
}

.geo-obj-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.geo-obj-title{
  font-weight:600;
}

/* Basis für ALLE Listen-Zeilen */
.geo-row{
  display:flex;
  align-items:center;
  gap:1px;              /* <- HIER stellst du den Abstand ein */
}

/* Checkbox überall gleich “eng” */
.geo-row input[type="checkbox"]{
  margin:0 4px 0 0;
  flex:0 0 auto;
}

/* Kleine Labels nicht aufblasen */
.geo-row .geo-mini,
.geo-row label{
  margin:0;
  white-space:nowrap;
}



/* =========================================================
   FINAL: Einheitliches Listen-Layout (immer zuletzt!)
   ========================================================= */

.geo-item{
  display:block;              /* wichtig: wir layouten in der inneren row */
  padding:10px;
  border:1px solid #eee;
  border-radius:10px;
  background:#fff;
}

/* DIE eine Zeile, die alles ausrichtet */
.geo-row{
  display:flex;
  align-items:center;
  gap:6px;                    /* <-- HIER steuerst du global den Abstand */
  width:100%;
}

/* Checkbox: kein linker "Geister-Abstand" */
.geo-row input[type="checkbox"]{
  margin:0;                   /* <-- killt Browser-default */
  padding:0;
  width:16px;
  height:16px;
  flex:0 0 auto;
}

/* Labels: keine Extra-Margins */
.geo-row label,
.geo-row .geo-mini{
  margin:0;
  white-space:nowrap;
}

/* Löschen immer rechts */
.geo-row .geo-del{
  margin-left:auto;
}


/* ===============================
   Abhängige Objekte – 2 Zeilen
   =============================== */

.geo-obj-card{
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

/* Zeile 1: Checkbox + Typ + Löschen */
.geo-obj-head{
  width: 100%;
}

/* Zeile 2: Optionen */
.geo-obj-body{
  width: 100%;
}

/* Optionen in Zeile 2 links ausrichten */
.geo-obj-fields{
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;      /* falls es eng wird */
  width: 100%;
}

/* Checkbox in Zeile 1 nicht zu “luftig” */
.geo-obj-enabled{
  margin: 0;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

/* Selects etwas kompakter */
.geo-obj-type,
.geo-obj-fields select{
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid #d8d8d8;
  background: #fff;
  font-size: 14px;
}

/* Löschen rechts */
.geo-obj-head .geo-del{
  margin-left: auto;
}




.geo-nameShort{
  width: 44px !important;
  padding: 6px 8px !important;
  border-radius: 10px;
  border: 1px solid #d8d8d8;
  text-align: center;
  font-weight: 600;
}

.geo-obj-type--small{
  max-width: 210px;
  padding: 6px 8px;
  font-size: 13px;
}

.geo-nameShort--pt{
  width: 34px !important;
  min-width: 34px !important;
  padding: 4px 6px !important;
  font-size: 13px !important;
  text-align: center;
  font-weight: 600;
}

.geo-nameShort--line{
  width: 34px !important;
  min-width: 34px !important;
  padding: 4px 6px !important;
  font-size: 13px !important;
  text-align: center;
  font-weight: 600;
}

.geo-numTiny{
  width: 34px !important;
  min-width: 34px !important;
  padding: 4px 6px !important;
  font-size: 13px !important;
  text-align: center;
}

.geo-accordion, 
.geo-accordion .geo-content,
.geo-form{
  text-align: left;
}

/* Grundeinstellungen: Checkboxen sauber (auch wenn global alles zentriert ist) */
/* Grundeinstellungen: Checkboxen */
.geo-accordion, 
.geo-accordion .geo-content,
.geo-form{
  text-align: left;
}

.geo-checkRow{
  display:flex;
  gap:18px;
  align-items:center;
}

.geo-check{
  display:inline-flex;
  align-items:center;
  gap:6px;
}

.geo-check input{
  margin:0;
}



/* ===== FINAL: Grundeinstellungen-Checkboxen (stabil im include) ===== */

#geoRoot .geo-checkRow{
  display:flex;
  align-items:center;
  gap:18px;
  flex-wrap:wrap;         /* oder nowrap, wenn immer nebeneinander */
}

#geoRoot .geo-check{
  display:inline-flex;
  align-items:center;
  gap:6px;                /* Abstand Checkbox -> Text */
  margin:0;
  padding:0;
  width:auto;
}

#geoRoot .geo-check input{
  margin:0;
}
#geoRoot .geo-check span{
  margin:0;
  padding:0;
}


#funcList .geo-del{
  margin-left: auto;
  margin-left: 0;
}


/* FINAL: Checkboxtext nicht nach rechts drücken */
#geoRoot label.geo-check{
  display: inline-flex !important;
  width: auto !important;
  justify-content: flex-start !important;
}

#geoRoot label.geo-check span{
  margin-left: 0 !important;
}

#geoRoot label.geo-check *{
  margin-left: 0 !important;
}

/* falls ein Parent die Labels in 2 Spalten verteilt */
#geoRoot .geo-form > label.geo-check{
  justify-self: start !important;
  align-self: start !important;
}


#geoRoot .geo-form{
  display: block !important;
}


#geoTitle{
  width: 100%;
}


.geo-modal{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.geo-modalBox{
  background: #fff;
  padding: 20px;
  border-radius: 12px;
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}

.geo-modalButtons{
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

#geoSaveModal{
  position: fixed;
  inset: 0;
  display: none;              /* default: aus */
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0,0,0,.45);
  z-index: 9999;
}

#geoSaveModal.is-open{
  display: flex;
}

body.modal-open{
  overflow: hidden;
}

.geo-modal-card{
  width: min(520px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}


.modal-overlay{
  position: fixed;
  inset: 0;
  display: none;              /* default: aus */
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0,0,0,.45);
  z-index: 9999;
}

.modal-overlay.is-open{
  display: flex;
}

.modal-card{
  width: min(520px, 100%);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  padding: 18px;
}

.modal-actions{
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

.modal-card input{
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #ddd;
  outline: none;
}

body.modal-open{
  overflow: hidden;
}


/* Overlay über dem kompletten Viewport */
#geoSaveModal{
  position: fixed;
  left: 0; top: 0; right: 0; bottom: 0; /* inset:0 geht auch */
  display: none;               /* du schaltest per JS auf flex */
  align-items: center;         /* vertikal mittig */
  justify-content: center;     /* horizontal mittig */
  background: rgba(0,0,0,.45); /* dunkler Hintergrund */
  z-index: 999999;             /* über ALLEM */
  padding: 16px;
}

/* Die eigentliche Dialogbox */
#geoSaveModal .geo-modal-card{
  width: min(560px, 100%);
  background: #fff;
  border-radius: 18px;
  padding: 18px 18px 16px;
  box-shadow: 0 20px 70px rgba(0,0,0,.35);
}

/* Layout innen */
#geoSaveModal h2{ margin: 0 0 12px; text-align: center; }

#geoSaveModal .geo-modal-row{
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

#geoSaveModal input{
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #cfcfcf;
  outline: none;
}

#geoSaveModal .geo-modal-actions{
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}

/* Optional: Scroll sperren wenn offen */
body.geo-modal-open{ overflow: hidden; }



/* ===== MODAL FINAL (ganz ans Ende) ===== */
#geoSaveModal{
  position: fixed !important;
  inset: 0 !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 16px !important;
  background: rgba(0,0,0,0.45) !important; /* <-- FIX */
  z-index: 2147483647 !important;         /* über allem */
}

#geoSaveModal.is-open{
  display: flex !important;
}

body.modal-open{
  overflow: hidden;
}

#geoSaveModal .geo-modal-card{
  width: min(560px, 100%);
  background: #fff;
  border-radius: 18px;
  padding: 18px 18px 16px;
  box-shadow: 0 20px 70px rgba(0,0,0,0.35); /* <-- FIX */
}

