/* Header */
#main-header{position:fixed;top:0;left:0;right:0;height:40px;background:#fff;box-shadow:0 2px 4px rgba(0,0,0,0.1);display:flex;align-items:center;padding:0 16px;z-index:10000}
.header-brand-container{flex:0 0 350px;display:flex;align-items:center;gap:0;white-space:nowrap}
.brand-map{font-weight:700;font-size:1.1em;color:rgb(43,43,104)}
.brand-lite{font-weight:700;font-size:1.1em;color:orange}
.header-slogan{font-size:.9em;color:#666}

.header-tabs{flex:1;display:flex;gap:16px;justify-content:flex-start;margin-left:16px}
.header-tabs .tab-word{background:none;border:1px solid transparent;padding:2px 6px;font-size:.9em;cursor:pointer;color:#333;outline:none;border-radius:4px;transition:background-color .15s,border-color .15s,color .15s}
.header-tabs .tab-word:hover{background:#f4f6fb}
#tab-btn-support:hover:not(.active){background:rgba(255,165,0,0.18);border-color:orange}
.header-tabs .tab-word.active{border:1px solid #007bff;background:#fff}

/* Mobile Header Actions (Hamburger/Tabs-Dropdown) */
.header-actions{display:none;margin-left:auto;position:relative}
.hamburger{background:rgb(43,43,104);color:#fff;border:0;width:28px;height:28px;border-radius:4px;font-size:18px;line-height:28px;text-align:center;cursor:pointer}
.mobile-tabs-menu{position:absolute;right:0;top:36px;background:#fff;border:1px solid #ddd;box-shadow:0 6px 16px rgba(0,0,0,0.15);border-radius:8px;padding:6px;display:none;z-index:10001}
.mobile-tabs-menu.open{display:block}
.mobile-tabs-menu button{display:block;width:180px;text-align:left;border:none;background:none;padding:8px 10px;cursor:pointer;border-radius:6px;font-size:.95em}
.mobile-tabs-menu button:hover{background:#f4f6fb}

/* Global */
*{box-sizing:border-box}
html,body{margin:0;padding:0;height:100%;font-family:'Roboto',sans-serif;background:#5d6469;color:#2c3e50}

/* Tabs Content + Info-Fontgröße */
#info{font-size:.8em}
.tab-content{display:none;padding:0 8px}
.tab-content.active{display:block}
#tab-info p{color:#555;margin-bottom:12px}
#tab-info p.hint{font-size:.6em;color:#555;margin-bottom:12px}
#tab-info ul{margin:0 0 12px 20px;color:#555}
#tab-info ul li{margin-bottom:6px}

/* Layout */
#container{position:absolute;top:40px;bottom:40px;left:0;right:0;display:flex;flex-direction:row;padding-right:0}
#info{flex:0 0 350px;overflow-y:auto;background:#ffffff;box-shadow:-2px 0 5px rgba(0,0,0,0.05)}
#map{flex:1;position:relative}
#map { min-width: 0; }

/* Sektionen */
.section-creation,.section-import{margin:8px;border-bottom:1px solid #ddd}
.section-creation,.section-import,.section-list{margin:8px}
.create-buttons,.import-buttons{display:flex;gap:8px;margin:4px}
.empty-list{color:#666;font-style:italic;text-align:center;margin:16px 0 0 0}
#tab-drawings section h4{margin:4px 0;padding:0}
#tab-drawings>h3,#tab-drawings h3{margin:8px 0}

/* Buttons */
button.action{background:rgb(43,43,104);color:#fff;padding:8px 12px;border:none;border-radius:4px;cursor:pointer}
button.action:hover{background:#545ca0}

/* Koordinaten-Karten */
.coord{position:relative;background:rgb(239,237,237);border-radius:8px;padding:12px;margin:12px}
.coord .copy-btn{position:absolute;top:12px;right:12px;background:none;border:none;cursor:pointer;font-size:1.2em;line-height:1;z-index:10}
.coord .copy-btn:hover{color:#004c9c}
.coord .value-text{font-weight:normal!important}
.coord span{display:block;font-weight:600;margin-bottom:4px;color:#34495e}

/* Historie & Listen */
#history-container .history-item{background:#f1f8ff;padding:6px;border-radius:4px;margin-bottom:6px;cursor:pointer}
#history-container .history-item:hover{background:#d6eaf8}
#drawing-list .history-item{background:#f9f9f9;padding:8px;border-radius:4px;margin-bottom:6px}
#drawing-list .history-item:hover{background:#efefef}

/* Form Controls */
.opacity-control{margin-top:4px}
input[type=color]{border:none;padding:0;cursor:pointer;width:32px;height:32px}
select,input[type=file]{width:100%;margin-bottom:8px}

/* Toolbar + Suche */
.toolbar,#search-container{position:absolute;z-index:1000;display:flex;background:white;border-radius:8px;box-shadow:0 2px 8px rgba(0,0,0,0.15);padding:6px}
.toolbar{top:16px;right:16px;gap:6px}
.icon-btn{width:36px;height:36px;min-width:36px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;padding:0;color:#fff;background:rgb(43,43,104);border:none}
/* SVG-Icons wirklich größer erzwingen */
.toolbar .icon-btn>svg,.icon-btn>svg{display:block;width:32px!important;height:32px!important;min-width:32px!important;min-height:32px!important;max-width:32px!important;max-height:32px!important;flex:0 0 32px!important}

#search-container{align-items:center;top:60px;right:16px;background:white;border-radius:8px;box-shadow:0 2px 8px rgba(0,0,0,0.15);padding:6px;z-index:1100;display:none}
#search-input{border:1px solid #ccc;border-radius:8px 0 0 8px;padding:2px 8px;width:220px;font-size:13px;height:32px;outline:none;margin-top:0}
#search-button{border-radius:0 8px 8px 0;padding:0 12px;height:32px;font-size:13px;border:none}

/* Leaflet Draw Edit Marker */
.leaflet-div-icon.leaflet-editing-icon{background:rgb(70,185,223)!important;border:2px solid rgb(60,60,224)!important;border-radius:50%!important;width:10px!important;height:10px!important;margin-left:-5px!important;margin-top:-5px!important}

/* Legende & Controls */
.legend-container{position:absolute!important;top:0!important;right:0!important;margin:0!important;padding:4px!important;background:white!important;z-index:1000!important}
.leaflet-control-container .leaflet-top.leaflet-right{padding:0!important}

/* Leaflet.draw in eigener UI */
.leaflet-control-draw,.leaflet-draw-toolbar,.leaflet-draw-draw-toolbar,.leaflet-draw-edit-toolbar,.leaflet-draw-section{display:none!important}

/* CSV-Popup */
#csv-popup{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.5);display:flex;align-items:center;justify-content:center;z-index:2000}
#csv-popup .popup-content{background:white;padding:20px;border-radius:8px;width:320px;box-shadow:0 2px 10px rgba(0,0,0,0.3)}
#csv-popup .popup-content h3{margin-top:0}
#csv-popup .form-group{margin-bottom:12px}
#csv-popup label{display:block;font-weight:600;margin-bottom:4px}
#csv-popup select,#csv-popup input[type="file"]{width:100%;padding:6px;border:1px solid #ccc;border-radius:4px}
#csv-popup .buttons{display:flex;justify-content:flex-end;gap:8px;margin-top:16px}
#csv-popup .buttons button{padding:6px 12px;border:none;border-radius:4px;cursor:pointer}
button.action.cancel{background:#ccc;color:#ffffff}
button.action.cancel:hover{background:#e67e22}

/* Popups */
.map-text-label{pointer-events:none;white-space:nowrap}
.map-text-label span{display:inline-block;padding:2px 4px;border-radius:2px}
.cursor-hint{position:absolute;pointer-events:none;background:rgba(255,255,255,0.9);padding:4px 8px;border-radius:4px;font-size:12px;border:1px solid #ccc;z-index:10000;white-space:nowrap}

#tab-tools .tool-section{border-bottom:1px solid #ddd;margin-bottom:16px;padding-bottom:16px}
#tab-tools .tool-section:last-child{border-bottom:none}
#tab-tools .tool-section h4{margin-top:0;margin-bottom:8px;color:#2c3e50}
#tab-tools .tool-section p{margin:0 0 12px;color:#555}

/* Attributtabelle */
#attribute-table{position:absolute;bottom:0;left:0;width:100%;height:250px;overflow:hidden;background:rgba(255,255,255,0.95);border-top:1px solid #ccc;box-shadow:0 -2px 6px rgba(0,0,0,0.15);z-index:600;display:none}
#attr-table-header{display:flex;justify-content:space-between;align-items:center;height:38px;padding:0 12px;background:rgb(43,43,104);color:#fff;box-sizing:border-box;border-bottom:1px solid #333;font-size:14px;position:relative;z-index:2}
#attr-table-title{font-weight:500}
#attr-table-close{border:none;background:transparent;font-size:16px;color:#fff;cursor:pointer}
#attr-table-content{position:relative;height:calc(100% - 38px);overflow-y:auto;padding:8px;box-sizing:border-box;background:#fafafa}
#attribute-table table{width:100%;table-layout:fixed;border-collapse:collapse}
#attribute-table th,#attribute-table td{text-align:left;padding:6px 8px;border-bottom:1px solid #ddd;box-sizing:border-box}
#attribute-table th{position:relative;background:rgb(43,43,104);color:#fff;font-weight:normal!important;cursor:pointer;user-select:none;padding-right:24px}
#attribute-table th .resizer{position:absolute;top:0;right:0;width:6px;height:100%;cursor:col-resize;user-select:none;background:orange}
#attribute-table th::after{content:'⇅';position:absolute;right:12px;top:50%;transform:translateY(-50%);font-size:14px;opacity:.6}
#attribute-table th.is-asc::after{content:'▲';opacity:1}
#attribute-table th.is-desc::after{content:'▼';opacity:1}
#attribute-table tbody tr:hover{background-color:rgba(255,165,0,0.4);transition:background-color .15s}
#attr-table-content table thead{display:table-header-group}
#attr-table-content table thead th{position:sticky;top:0;z-index:1}

/* Leaflet-Popup (MapLite-Style) */
.ml-popup .leaflet-popup-content-wrapper{background:transparent;border:none;box-shadow:none;padding:0}
.ml-popup .leaflet-popup-content{margin:0;padding:0;background:transparent}
.ml-popup .leaflet-popup-tip-container,.ml-popup .leaflet-popup-tip{display:none}
.ml-popup .leaflet-popup-close-button{position:absolute;top:6px;right:8px;width:20px;height:20px;line-height:20px;text-align:center;font-size:18px;color:#ffffff!important;background:white;border:none;cursor:pointer;z-index:10}
.ml-popup-header{background:rgb(43,43,104);color:#fff;padding:8px 36px 8px 12px;border-bottom:1px solid #185c82;font-size:16px;position:relative;border-top-left-radius:4px;border-top-right-radius:4px}
.ml-popup-body{max-height:240px;overflow-y:auto;background:#fafafa;padding:8px}
.ml-popup-table{width:100%;border-collapse:collapse}
.ml-popup-table th,.ml-popup-table td{padding:6px 8px;border-bottom:1px solid #ddd}
.ml-popup-table th{background:rgb(43,43,104);color:white;font-weight:500}
.ml-popup-table tr:nth-child(odd){background:#fff}.ml-popup-table tr:nth-child(even){background:#f5faff}

/* Footer */
#site-footer{position:fixed;bottom:0;left:0;width:100%;height:40px;background:#fff;border-top:1px solid #ddd;display:flex;align-items:center;justify-content:center;padding:0 16px;box-sizing:border-box;z-index:10000}
#site-footer .footer-content{display:flex;align-items:center;gap:24px}
#site-footer .footer-copy{color:#666;font-size:.85em}
#site-footer .footer-nav{display:flex;gap:12px}
#site-footer .footer-nav a{color:#666;text-decoration:none;font-size:.85em}
#site-footer .footer-nav a:hover{text-decoration:underline}

/* Video */
.video-wrapper{position:relative;width:100%;padding-bottom:56.25%;height:0;overflow:hidden;background:#000;border-radius:8px}
.video-wrapper iframe{position:absolute;inset:0;width:100%;height:100%;border:0}

/* ------- Mobile Features ------- */

/* Buttonzeile im Info-Tab */
.mobile-toggle-bar{width:100%;display:flex;justify-content:center;align-items:center;padding:8px 0;margin-bottom:8px}

/* Off-Canvas Sidebar */
body.mobile-active .header-tabs{display:none}
body.mobile-active .header-actions{display:flex}

body.mobile-active #info{position:absolute;top:40px;bottom:40px;left:0;width:350px;transform:translateX(-100%);transition:transform .25s ease;border-right:1px solid #eee;z-index:1000}
body.mobile-active.sidebar-open #info{transform:translateX(0)}

/* Interne Close-Buttons ausblenden */
.mobile-sidebar-close{display:none!important}

/* Externer Close-Button (mobil), rechts oberhalb der oberen Kante */
#mobile-sidebar-exit{display:none;position:absolute;top:38px;left:328px;transform:translate(8px,-14px);width:22px;height:22px;line-height:22px;font-size:16px;color:#000;background:transparent;border:none;border-radius:50%;cursor:pointer;z-index:1001}
body.mobile-active.sidebar-open #mobile-sidebar-exit{display:block}

/* Suche mobil links neben Toolbar */
body.mobile-active #search-container{display:none;top:56px;right:calc(12px + 56px);max-width:min(420px,calc(100vw - 56px - 24px));z-index:1100}
body.mobile-active.search-open #search-container{display:flex}

/* ===== Mobile Toolbar vertikal ===== */
body.mobile-active .toolbar{top:56px;right:12px;flex-direction:column;align-items:center;gap:8px;padding:8px 6px;max-height:calc(100vh - 120px);overflow:visible}

/* Menü-Wrapper & Menüs */
.menu-wrapper{position:relative;display:inline-block}
.action-menu{position:absolute;top:calc(100% + 6px);right:0;left:auto;background:#fff;border:1px solid #ccc;box-shadow:0 2px 6px rgba(0,0,0,0.15);padding:8px;border-radius:8px;min-width:200px;width:min(320px,calc(100vw - 24px));max-height:60vh;overflow:auto;z-index:1200;display:none}
.menu-wrapper.open>.action-menu{display:block}
.action-menu label{display:block;margin-bottom:6px;cursor:pointer}

body.mobile-active .toolbar .menu-wrapper.open>.action-menu,
body.mobile-active .toolbar .action-menu{top:0;right:calc(100% + 8px);left:auto;width:min(320px,calc(100vw - 24px - 56px));max-height:60vh}

body.mobile-active .leaflet-control-container .leaflet-top.leaflet-left{top:auto!important;left:auto!important;right:12px!important;bottom:40px!important}
body.mobile-active .leaflet-control-zoom a{width:28px;height:28px;line-height:28px;font-size:18px;border-radius:4px}
body.mobile-active.attr-open .leaflet-control-container .leaflet-top.leaflet-left{bottom:calc(40px + 200px)!important}

@media (max-width:640px){
  #search-container{right:12px;top:56px}
}

body.mobile-active .icon-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
}

body.mobile-active .toolbar .icon-btn > img,
body.mobile-active .toolbar .icon-btn > svg {
  width: 22px !important;
  height: 22px !important;
  min-width: 22px !important;
  min-height: 22px !important;
  max-width: 22px !important;
  max-height: 22px !important;
}

body.mobile-active #site-footer { display: none; }
body.mobile-active #container  { bottom: 0; }

body.mobile-active .leaflet-control-container .leaflet-top.leaflet-left {
  right: 12px !important;
  bottom: 12px !important; 
}
body.mobile-active.attr-open .leaflet-control-container .leaflet-top.leaflet-left {
  bottom: 200px !important; 
}

