* { box-sizing: border-box; }
body { font-family: Arial, sans-serif; margin: 0; display: flex; height: 100vh; background: #f8f9fa; }
header { background: #004d99; color: white; padding: 10px 20px; position: fixed; width: 100%; z-index: 100; height: 60px; display: flex; align-items: center; gap: 12px; }
header h1 { margin: 0; font-size: 1.5em; flex-shrink: 0; }

/* Search */
#search-wrap { margin-left: auto; display: flex; align-items: center; }
#search-input {
    padding: 7px 16px; border: 1px solid rgba(255,255,255,0.35);
    border-radius: 20px; background: rgba(255,255,255,0.15); color: white;
    font-size: 14px; outline: none; width: 200px;
    transition: width 0.25s, background 0.2s; font-family: inherit;
}
#search-input::placeholder { color: rgba(255,255,255,0.65); }
#search-input:focus { width: 300px; background: rgba(255,255,255,0.25); }
#search-input::-webkit-search-cancel-button { filter: invert(1); cursor: pointer; }

/* Back button */
#back-btn {
    display: none; background: #e9ecef; color: #333; border: 1px solid #ccc;
    padding: 5px 14px; border-radius: 4px; cursor: pointer; font-size: 13px;
    margin-bottom: 12px; align-items: center; gap: 5px;
}
#back-btn:hover { background: #d0d7de; }
.container { display: flex; width: 100%; padding-top: 60px; height: 100vh; }

aside { width: 280px; min-width: 280px; background: white; border-right: 1px solid #ddd; overflow-y: auto; overflow-x: hidden; padding: 15px; transition: width 0.25s, min-width 0.25s, padding 0.25s; flex-shrink: 0; }
aside.collapsed { width: 0 !important; min-width: 0 !important; padding: 0 !important; }
main { flex: 1; padding: 30px; overflow-y: auto; display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }

/* Sidebar Toggle Button */
.sidebar-toggle-btn {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    left: 280px;
    z-index: 150;
    background: #004d99;
    color: white;
    border: none;
    border-radius: 0 6px 6px 0;
    width: 18px;
    height: 50px;
    cursor: pointer;
    font-size: 10px;
    padding: 0;
    transition: left 0.25s, background 0.15s;
    box-shadow: 2px 0 6px rgba(0,0,0,0.25);
    line-height: 1;
    display: flex; align-items: center; justify-content: center;
}
.sidebar-toggle-btn:hover { background: #0061c3; opacity: 1; }

/* Page title row (title + PDF link) */
#page-title-row { display: flex; align-items: center; width: 100%; max-width: 900px; gap: 14px; flex-wrap: wrap; }
#page-title-row h2 { margin: 0; flex: 1; min-width: 0; }
#pdf-portal-link { flex-shrink: 0; }

/* Navigation Tree – div-based accordion (iPad-safe, no details/summary) */
.nav-tree { padding: 0; margin: 0; }
.nav-group { margin-bottom: 4px; }
.nav-haupt-div {
    display: flex; align-items: center; gap: 2px;
    padding: 6px 8px; font-weight: bold;
    user-select: none; border-radius: 4px; color: #222;
}
.nav-haupt-div:hover { background: #f0f5ff; }
.nav-group-body { }
.nav-subgroup { }
.nav-thema-div {
    display: flex; align-items: center; gap: 2px;
    padding: 5px 8px; font-weight: 600;
    margin-left: 8px; color: #333; border-bottom: 1px solid #eee;
    font-size: 0.92em; user-select: none; border-radius: 4px;
}
.nav-thema-div:hover { background: #f0f5ff; }
/* Klapp-Pfeil links */
.nav-toggle {
    flex-shrink: 0; width: 16px; text-align: center;
    font-size: 9px; color: #aaa; cursor: pointer;
    border-radius: 3px; padding: 2px 0; line-height: 1;
    user-select: none; transition: color 0.15s;
}
.nav-toggle:hover { color: #004d99; }
.nav-label { flex: 1; cursor: pointer; }
.nav-subgroup-body.closed { display: none; }
.nav-group-body.closed { display: none; }
.nav-tree ul { list-style: none; padding-left: 26px; margin: 4px 0 10px 0; }
.nav-tree li { cursor: pointer; padding: 5px 8px; border-radius: 4px; font-size: 0.88em; color: #333; border-left: 2px solid transparent; position: relative; display: flex; align-items: center; }
.nav-tree li:hover, .nav-tree li.active { background: #e9ecef; color: #004d99; border-left: 2px solid #004d99; font-weight: bold; }
.nav-item-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-trash { opacity: 0; flex-shrink: 0; cursor: pointer; font-size: 13px; color: #dc3545; padding: 1px 4px; border-radius: 3px; margin-left: 4px; line-height: 1; transition: opacity 0.15s, background 0.1s; }
.nav-tree li:hover .nav-trash { opacity: 0.7; }
.nav-trash:hover { opacity: 1 !important; background: #f8d7da; }

/* Link-Path Tooltip (full path on hover) */
#link-path-tooltip { position: fixed; background: rgba(0,0,0,0.82); color: white; padding: 5px 10px; border-radius: 4px; font-size: 11px; z-index: 9999; pointer-events: none; max-width: 320px; line-height: 1.5; white-space: normal; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }

/* Bild-Container & Vorschau */
#media-container, #preview-wrap { 
    position: relative; 
    display: inline-block; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.1); 
    background: #fff;
    max-width: 100%;
    margin-top: 15px;
}
#media-container img:not(.frontend-overlay), #preview-wrap img:not(.frontend-overlay) { 
    display: block; max-width: 100%; height: auto; 
}

/* Hotspot / Pfeil Tooltip */
.hs-tooltip {
    position: absolute;
    background: #fff;
    color: #333;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    max-width: 240px;
    min-width: 120px;
    pointer-events: none;
    z-index: 50;
    box-shadow: 0 6px 20px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,77,153,0.12);
    border-top: 3px solid #004d99;
    transform: translate(-50%, calc(-100% - 14px));
    white-space: normal;
    line-height: 1.4;
}
.hs-tooltip::after {
    content: '';
    position: absolute;
    bottom: -9px; left: 50%;
    transform: translateX(-50%);
    border: 9px solid transparent;
    border-top-color: #fff;
    border-bottom: none;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.08));
}
/* Blase unterhalb des HotSpots – Pfeil zeigt nach oben */
.hs-tooltip.tooltip-below {
    transform: translate(-50%, 14px);
    border-top: none;
    border-bottom: 3px solid #004d99;
}
.hs-tooltip.tooltip-below::after {
    bottom: auto;
    top: -9px;
    border: 9px solid transparent;
    border-top: none;
    border-bottom-color: #fff;
    filter: drop-shadow(0 -1px 2px rgba(0,0,0,0.08));
}
.hs-tooltip .tt-title { font-weight: bold; font-size: 13px; color: #004d99; margin-bottom: 5px; }
.hs-tooltip .tt-desc { font-size: 12px; color: #555; margin: 0; line-height: 1.5; }
.hs-tooltip .tt-type { font-size: 11px; color: #999; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 3px; }

/* Hotspot + Pfeil-Liste am Seitenende – horizontal, bricht um */
#hotspot-list { width: 100%; }
.hs-list-grid {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
    width: 100%;
}
.hs-card {
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    flex: 0 0 160px;
    width: 160px;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.hs-card:hover { border-color: #004d99; background: #f0f5ff; box-shadow: 0 2px 8px rgba(0,77,153,0.15); }
.hs-card.active { border-color: #004d99; background: #dce8ff; box-shadow: 0 2px 8px rgba(0,77,153,0.2); }
.hs-card-badge {
    display: inline-flex; align-items: center; justify-content: center;
    background: #e63946; color: white; border-radius: 50%;
    width: 26px; height: 26px; font-weight: bold; font-size: 13px;
    margin-bottom: 6px;
}
.hs-card-badge.pfeil-badge { background: #004d99; border-radius: 4px; font-size: 15px; }
.hs-card-title { font-weight: bold; font-size: 13px; color: #333; margin-bottom: 3px; }
.hs-card-desc { font-size: 12px; color: #666; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.4; }

/* Editor Hotspot-Liste (Tab 3) */
.editor-hs-list {
    background: white; border-radius: 8px; padding: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.07); max-width: 900px; width: 100%; margin-top: 16px;
}
.editor-hs-list h4 { margin: 0 0 12px; color: #004d99; font-size: 14px; border-bottom: 1px solid #eee; padding-bottom: 8px; }
.editor-hs-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 6px; border: 1px solid #eee;
    margin-bottom: 8px; background: #fafafa; transition: background 0.1s;
}
.editor-hs-row:hover { background: #f0f5ff; }
.editor-hs-row .hs-card-badge { margin-bottom: 0; flex-shrink: 0; }
.editor-hs-row .hs-row-info { flex: 1; min-width: 0; }
.editor-hs-row .hs-row-title { font-weight: bold; font-size: 13px; color: #333; }
.editor-hs-row .hs-row-desc { font-size: 12px; color: #666; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.editor-hs-row .hs-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-hs-edit { background: #004d99 !important; padding: 5px 10px !important; font-size: 12px !important; }
.btn-hs-delete { background: #dc3545 !important; padding: 5px 10px !important; font-size: 12px !important; }

/* Teaser Panel (Portal) */
#teaser-panel {
    background: white; border-left: 4px solid #004d99;
    border-radius: 0 8px 8px 0; padding: 18px 20px;
    max-width: 900px; width: 100%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07); margin-top: 10px;
}
#teaser-panel h3 { margin: 0 0 14px; color: #004d99; font-size: 15px; }

/* Thumbnail-Karten im Teaser */
.teaser-grid { display: flex; flex-wrap: wrap; gap: 14px; }
.teaser-thumb-card {
    background: white; border-radius: 8px; overflow: hidden;
    border: 2px solid #e0e0e0; cursor: pointer; width: 160px; flex-shrink: 0;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}
.teaser-thumb-card:hover {
    border-color: #004d99; box-shadow: 0 4px 14px rgba(0,77,153,0.22);
    transform: translateY(-2px);
}
.thumb-img-wrap {
    width: 100%; height: 100px; background: #eef2ff; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}
.thumb-img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-placeholder { font-size: 28px; opacity: 0.35; }
.thumb-title { padding: 8px 10px 10px; font-size: 12px; font-weight: bold; color: #333; line-height: 1.3; }

/* Teaser-Liste (Hauptthema → Unterthemen) */
.teaser-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-bottom: 1px solid #f0f0f0;
    cursor: pointer; border-radius: 5px; color: #333;
    font-size: 14px; transition: background 0.1s;
}
.teaser-item:hover { background: #f0f5ff; color: #004d99; }
.teaser-item:last-child { border-bottom: none; }
.teaser-sub { font-size: 12px; color: #888; margin-left: auto; }

/* Hotspots */
.hotspot-num, .edit-hs-num {
    position: absolute; 
    background: #e63946; color: white; 
    border-radius: 50%; 
    width: 26px; height: 26px; 
    text-align: center; line-height: 24px; 
    font-weight: bold; font-size: 13px;
    transform: translate(-50%, -50%); 
    cursor: pointer; 
    border: 2px solid white; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    z-index: 10;
    transition: transform 0.1s;
}
.hotspot-num:hover, .hotspot-num.active, .edit-hs-num:hover { 
    background: #004d99; 
    transform: translate(-50%, -50%) scale(1.15); 
}

/* SVG Pfeile */
.arrow-svg-layer {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 6; overflow: visible;
}

/* Formulare & Editor */
.editor-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.05);}
.form-group { display: flex; flex-direction: column; margin-bottom: 5px; }
.form-group label { font-size: 0.85em; font-weight: bold; color: #555; margin-bottom: 5px; }
.form-group input, .form-group textarea { padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-family: inherit; width: 100%; }
.editor-panel { background: white; padding: 15px; border-radius: 8px; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }

button { padding: 8px 15px; border: none; border-radius: 4px; cursor: pointer; color: white; font-family: inherit; }
button:hover { opacity: 0.8; }
.tool-btn { background: #ccc; color: #333; margin-right: 5px; }
.tool-btn.active { background: #004d99; color: white; font-weight: bold; }
.hint { font-size: 0.85em; color: gray; }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid #004d99; margin-bottom: 20px; width: 100%; }
.tab-btn { background: #e9ecef; color: #333; border: none; padding: 12px 20px; cursor: pointer; font-size: 15px; border-radius: 6px 6px 0 0; margin-right: 5px; }
.tab-btn:hover { background: #d0d7de; }
.tab-btn.active { background: #004d99; color: white; font-weight: bold; }
.tab-content { display: none; width: 100%; }
.tab-content.active { display: block; }

/* --- OVERLAYS --- */
.overlay-wrapper { position: absolute; cursor: move; z-index: 2; border: 1px dashed transparent; }
.overlay-wrapper img { width: 100%; height: auto; display: block; pointer-events: none; box-shadow: 0 4px 10px rgba(0,0,0,0.4); } 
.frontend-overlay { position: absolute; z-index: 2; pointer-events: none; box-shadow: 0 4px 10px rgba(0,0,0,0.4); }

/* Papierkorb Overlay */
.overlay-trash {
    position: absolute; top: -10px; right: -10px;
    background: #dc3545; color: white; width: 22px; height: 22px;
    border-radius: 50%; text-align: center; line-height: 22px; font-size: 12px;
    cursor: pointer; opacity: 0; transition: opacity 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.3); z-index: 10;
}
.overlay-wrapper:hover .overlay-trash { opacity: 1; }

.overlay-resizer { position: absolute; bottom: -5px; right: -5px; width: 12px; height: 12px; background: #004d99; border-radius: 50%; cursor: nwse-resize; opacity: 0; transition: opacity 0.2s; }
.overlay-wrapper:hover .overlay-resizer { opacity: 1; }

/* --- MODAL --- */
.modal-backdrop { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-content { background: white; padding: 25px; border-radius: 8px; width: 450px; max-width: 90%; box-shadow: 0 5px 25px rgba(0,0,0,0.3); }
.modal-content h3 { margin-top: 0; color: #004d99; border-bottom: 1px solid #eee; padding-bottom: 10px; }
.modal-actions { display: flex; margin-top: 20px; gap: 10px; }

/* Drop Zone (Tab 2 Uploads) */
.drop-zone {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px; border: 2px dashed #adb5bd; border-radius: 10px;
    padding: 30px 20px; cursor: pointer; background: #f8f9fa;
    transition: border-color 0.2s, background 0.2s; text-align: center; width: 100%;
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: #004d99; background: #e8f0ff;
}
.drop-zone.uploading { border-color: #ffc107; background: #fffbe6; cursor: wait; }
.drop-zone input[type=file] { display: none; }
.dz-icon { font-size: 36px; line-height: 1; }
.dz-text { font-weight: bold; font-size: 14px; color: #333; }
.dz-hint { font-size: 12px; color: #888; }

/* Beschreibung Text Frontend */
#description-box { margin-top: 30px; padding: 20px; background: white; border-left: 5px solid #004d99; box-shadow: 0 2px 10px rgba(0,0,0,0.05); width: 100%; max-width: 800px; }
.page-text { font-size: 1.05em; color: #444; margin-bottom: 15px; max-width: 800px; line-height: 1.5; }

/* --- Alle öffnen / schliessen Buttons --- */
.nav-all-controls {
    display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap;
}
.nav-all-btn {
    flex: 1; background: #e9ecef; color: #333; border: 1px solid #ccc;
    border-radius: 4px; padding: 4px 6px; font-size: 11px; cursor: pointer;
    white-space: nowrap; font-family: inherit;
}
.nav-all-btn:hover { background: #d0d7de; color: #004d99; }

/* --- Blur-Werkzeug Panel --- */
#blur-apply-panel {
    display: flex; align-items: center; gap: 10px;
    margin-top: 12px; padding: 10px 14px;
    background: #fff3cd; border: 1px solid #ffc107; border-radius: 6px;
    font-size: 13px; flex-wrap: wrap;
}
#blur-panel-info { flex: 1; color: #856404; font-weight: bold; }

/* --- Blur-Canvas-Overlay (auf dem Vorschau-Bild) --- */
#blur-draw-canvas {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    cursor: crosshair; z-index: 60;
    touch-action: none;
}

/* Blur-Button aktiv-Zustand */
#btn-blur.blur-active { background: #5a2d91 !important; box-shadow: 0 0 0 3px rgba(111,66,193,0.4); }