/* Grundlegende Stile */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    line-height: 1.6;
    background-color: #f5f5f5;
}

header {
    background-color: #ffffff;
    color: #444;
    padding: 0.5rem 1rem;
    box-shadow: none;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 16px;
}

header h1 {
    font-size: 1rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.header-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.header-action-btn {
    background: transparent;
    color: #444;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    padding: 4px 10px;
    font-size: 0.82em;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.header-action-btn:hover {
    background: #f0f0f0;
    border-color: #aaa;
}

/* "Plan exportieren" hervorheben: warme Farben des BETA-Badges, aber gleiche
   eckige Form/Grösse wie die übrigen Header-Buttons (Speichern/Öffnen). */
#exportAnnotatedPdfBtn {
    color: #c04000;
    background: #fff3e0;
    border-color: #f0a060;
}

#exportAnnotatedPdfBtn:hover {
    background: #ffe7c8;
    border-color: #e0883f;
}

/* Header "3-Strich"-Menü (Anleitung & Bug melden) */
.header-menu {
    position: relative;
    display: inline-flex;
}

.header-menu-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 1300;
    min-width: 230px;
    flex-direction: column;
    gap: 2px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    padding: 6px;
}

.header-menu-dropdown.open {
    display: flex;
}

.header-menu-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    box-sizing: border-box; /* Padding in die 100%-Breite einrechnen → kein Überlauf (v.a. beim <label>) */
    background: transparent;
    border: none;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 0.85em;
    color: #444;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
}

.header-menu-item:hover {
    background: #f0f0f0;
}

.header-menu-item svg {
    flex-shrink: 0;
    color: #666;
}

.header-menu-sep {
    height: 1px;
    background: #ececec;
    margin: 4px 2px;
}

.header-menu-toggle {
    cursor: pointer;
}

.header-menu-toggle-text {
    flex: 1 1 auto;
    white-space: normal;
}

.header-menu-toggle input[type="checkbox"] {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    padding: 0;
    margin: 0;
    border: none;
    cursor: pointer;
}

.header-menu-hint {
    display: block;
    padding: 2px 10px 4px 33px;
    font-size: 0.75em;
    color: #FF6B00;
    text-decoration: none;
}

.header-menu-hint:hover {
    text-decoration: underline;
}

h1, h2 {
    margin: 0;
    color: inherit;
}

h2 {
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

/* Professionelles 3-Spalten CSS Grid Layout */
.main-container {
    display: grid;
    grid-template-columns: 350px 1fr 460px;
    grid-template-rows: 1fr;
    width: 100vw;
    height: calc(100vh - 80px);
    padding: 15px;
    box-sizing: border-box;
    gap: 20px;
    overflow: hidden;
}

/* Spalten-Definitionen */
.left-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    background: #ffffff;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    box-shadow: none;
}

.middle-column {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    box-shadow: none;
}

.right-column {
    display: flex;
    flex-direction: column;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    overflow: hidden;
    box-shadow: none;
}

.image-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Wichtig für Flex-Verhalten */
    margin-bottom: 20px;
}

.results-container {
    flex: 0 0 auto; /* Nimmt nur benötigten Platz */
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: 40vh; /* Begrenzt die Höhe der Ergebnisse */
    overflow-y: auto;
}

/* Abschnitte */
.upload-section, .results-section, .results-table-section {
    background: white;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

/* Formular-Elemente */
.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 0.9rem;
}

input, select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

button {
    background: #4a90e2;
    color: white;
    border: none;
    padding: 8px 15px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
}

button:hover {
    background: #357abd;
}


/* Bild-Container und Annotation-Stile */
#imageContainer {
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow: auto !important; /* Scrolling wenn Bild grösser als Container */
    margin-top: 10px;
    border: 1px solid #ddd;
    background: #f9f9f9;
    flex: 1; /* Nimmt den verfügbaren Platz in image-section */
    min-height: 400px; /* Minimum für kleine Bildschirme */
    display: flex;
    justify-content: flex-start; /* Bild startet links-oben statt zentriert */
    align-items: flex-start; /* Bild startet oben */
    padding: 0;
}

/* Empty-State: zentrierter Hinweis im leeren Canvas (bis erster Plan geladen) */
#canvasEmptyState {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    padding: 24px;
    pointer-events: none; /* blockiert keinerlei Interaktion */
    user-select: none;
}

#canvasEmptyState .empty-icon {
    color: #c2cdd8;
    margin-bottom: 4px;
}

#canvasEmptyState .empty-title {
    font-size: 1rem;
    font-weight: 600;
    color: #6b7682;
}

#canvasEmptyState .empty-hint {
    font-size: 0.85rem;
    line-height: 1.45;
    color: #9aa3ad;
    max-width: 320px;
}

/* Allgemeine Tabellenstile für andere Tabellen (nicht Ergebnistabelle) */
#labelTable {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.9rem;
}

#labelTable th, #labelTable td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

#labelTable th {
    background-color: #f2f2f2;
    position: sticky;
    top: 0;
}


.results-table-section {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Keine eigene Karte: die .right-column ist bereits eine weisse, gepolsterte
       Box. Hintergrund/Padding/Schatten hier zurücksetzen, damit Legende und
       Tabelle den Platz direkt nutzen (kein doppelt verschachteltes Feld). */
    background: transparent;
    padding: 0;
    box-shadow: none;
    border-radius: 0;
}

.results-table-section h2 {
    /* Gleicher dezenter Stil wie der "LABELS"-Titel in der linken Spalte
       (.project-title): klein, grau, Grossbuchstaben. */
    margin: 0 0 10px 0;
    color: #999;
    font-size: 0.72em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    text-align: left;
}

.results-table-section .summary {
    margin-bottom: 20px;
    padding: 12px 15px;
    background: #f8f8f8;
    border-radius: 8px;
    font-size: 0.82rem;  /* gleich gross wie die Tabelle */
    border-left: 3px solid #888;
}

.summary-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    border-bottom: 1px solid #eee;
}
.summary-row:last-child { border-bottom: none; }

.summary-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}
.summary-name {
    flex: 1;
    color: #444;
}
.summary-count {
    color: #555;
    min-width: 24px;
    text-align: right;
}
.summary-area {
    color: #777;
    font-size: 0.85em;
    min-width: 70px;
    text-align: right;
}

/* Scrollbarer Wrapper um die Tabelle. Ersetzt den fragilen display:block-tbody-
   Hack (thead/tr als getrennte display:table-Kontexte), der in Safari die Spalten
   gegeneinander verschob. Hier scrollt der Wrapper, die Tabelle bleibt eine
   normale Tabelle mit table-layout:fixed → Spalten in allen Browsern konsistent. */
.results-table-scroll {
    flex: 1;
    min-height: 0;   /* lässt das Flex-Kind schrumpfen → scrollt statt zu überlaufen */
    overflow-y: auto;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.results-table-section table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 0.82rem;
    background: white;
}

.results-table-section thead th {
    /* Kopfzeile bleibt beim Scrollen oben sichtbar (sticky statt des alten Hacks). */
    position: sticky;
    top: 0;
    background: #ffffff;
    color: #999;
    border-bottom: 1px solid #e8e8e8;
    z-index: 1;
}

.results-table-section th,
.results-table-section td {
    padding: 5px 5px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
    /* Verhindert, dass langer Text die fixen Spalten sprengt und (v.a. in Safari)
       in die Nachbarspalte überläuft. */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Explizite Spaltenbreiten: thead und jede tbody-Zeile sind beim scrollbaren-tbody-
   Hack getrennte display:table-Kontexte – ohne feste Breiten berechnet Safari sie
   unterschiedlich → Versatz/Überlappung. Prozente halten beide konsistent. */
.results-table-section th:nth-child(1),
.results-table-section td:nth-child(1) { width: 8%; }   /* Nr. */
.results-table-section th:nth-child(2),
.results-table-section td:nth-child(2) { width: 32%; }  /* Label (Name) */
.results-table-section th:nth-child(3),
.results-table-section td:nth-child(3) { width: 8%; }   /* Typ (nur Icon → wenig Platz nötig) */
.results-table-section th:nth-child(4),
.results-table-section td:nth-child(4) { width: 17%; }  /* Breite */
.results-table-section th:nth-child(5),
.results-table-section td:nth-child(5) { width: 17%; }  /* Höhe */
.results-table-section th:nth-child(6),
.results-table-section td:nth-child(6) { width: 18%; }  /* Messwert */

/* Platzhalter-/Leerzeilen (colspan) dürfen umbrechen und volle Breite nutzen –
   nicht von den festen Spaltenbreiten/Ellipsis oben abgeschnitten werden. */
.results-table-section td[colspan] {
    width: auto;
    white-space: normal;
    overflow: visible;
}

.results-table-section th {
    /* Gleicher Header-Stil wie die Label-Tabelle (#labelTable th): klein, grau. */
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.04em;
}

.results-table-section tbody tr:hover {
    background-color: #f8f9fa;
}


/* Lade-Animation */
.loader {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 2s linear infinite;
    margin: 20px auto;
    display: none; /* Initially hidden */
    z-index: 1000; /* Ensure it's above other elements */
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#errorMessage {
    color: red;
    margin-top: 10px;
    display: none;
}

/* Steuerelemente für Annotationen */
.annotation-controls {
    display: flex;
    flex-wrap: nowrap;
    gap: 2px;
    align-items: center;
    padding: 5px 8px;
    border-bottom: 1px solid #e8e8e8;
    margin-bottom: 0;
}

#resultsSection {
    padding: 0;
    box-shadow: none;
    border-radius: 0;
    background: transparent;
}

.toggle-button {
    background: #e9ecef;
    color: #444;
    border: none;
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 4px;
    flex: 1;
    min-width: 80px;
    max-width: 120px;
}

.toggle-button.active {
    background: #4a90e2;
    color: white;
}

.tool-button {
    background: transparent;
    color: #666;
    border: none;
    padding: 0;
    cursor: pointer;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    transition: background 0.1s, color 0.1s;
    flex-shrink: 0;
}

.tool-button:hover {
    background: #ebebeb;
    color: #444;
}

/* Deaktiviert (z. B. Trash ohne Auswahl): ausgegraut, kein Hover/Klick */
.tool-button:disabled {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

.tool-button.active,
.tool-button.flash-active {
    background: #444;
    color: #fff;
    /* Voll deckend, auch wenn der Button gerade disabled ist (Lösch-Flash des
       Trash-Icons direkt nach dem Löschen, wenn die Auswahl schon weg ist). */
    opacity: 1;
}

/* Eigene Zustandsklasse für Toggle-Buttons (setTool() räumt .active ab) */
.tool-button.toggled {
    background: #444;
    color: #fff;
}

/* Legende */
.save-button {
    background-color: #444;
    color: #fff;
    border: 1px solid #444;
    transition: background 0.12s;
}

.save-button:hover {
    background-color: #444;
    border-color: #444;
}

.cancel-button {
    background-color: #fff;
    color: #555;
    border: 1px solid #d0d0d0;
    transition: background 0.12s, border-color 0.12s;
}

.cancel-button:hover {
    background-color: #f0f0f0;
    border-color: #999;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


.object-type-select {
    flex: 0 0 120px;
}

/* Right panel collapse */
.toolbar-spacer {
    flex: 1;
}

.main-container.right-collapsed {
    grid-template-columns: 350px 1fr;
}

.main-container.right-collapsed .right-column {
    display: none;
}

/* Responsive Design für verschiedene Bildschirmgrössen */
@media (max-width: 1600px) {
    .main-container {
        grid-template-columns: 350px 1fr 400px;
    }
}

@media (max-width: 1400px) {
    .main-container {
        grid-template-columns: 320px 1fr 280px;
        gap: 15px;
        padding: 10px;
    }
    .main-container.right-collapsed {
        grid-template-columns: 320px 1fr;
    }
}

@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 280px 1fr 250px;
        gap: 10px;
        padding: 8px;
    }
    .main-container.right-collapsed {
        grid-template-columns: 280px 1fr;
    }
    
    .left-column,
    .right-column {
        padding: 15px;
    }
}

@media (max-width: 900px) {
    .main-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        height: auto;
        gap: 15px;
    }
    
    .left-column {
        order: 1;
        max-height: 300px;
        overflow-y: auto;
    }
    
    .middle-column {
        order: 2;
        min-height: 400px;
    }
    
    .right-column {
        order: 3;
        max-height: 350px;
        overflow-y: auto;
    }
    
    .results-table-scroll {
        max-height: 200px;
    }
}

/* CSS für Projektbereich */
.project-section {
    /* Keine eigene Karte: die .left-column ist bereits eine weisse, gepolsterte
       Box. Hintergrund/Schatten/Radius erzeugten sonst eine feine Rahmenlinie
       rund um das Label-Feld (gleiche Verschachtelung wie zuvor rechts). */
    background: transparent;
    padding: 20px;
    margin-top: 20px;
}

.project-title {
    margin-bottom: 15px;
    font-size: 1.2rem;
    font-weight: bold;
}

.project-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.project-button {
    flex: 1 0 calc(50% - 10px);
    background-color: #ffffff;
    color: #444;
    padding: 10px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    cursor: pointer;
    min-width: 150px;
    text-align: center;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 7px;
}

.project-button:hover {
    background-color: #f0f0f0;
    border-color: #999;
}

/* Spezielle Stile für PDF-Export-Buttons */
#exportPdfBtn {
    background-color: #4CAF50;
}

#exportPdfBtn:hover {
    background-color: #3d8b40;
}

#exportAnnotatedPdfBtn {
    background-color: #fff4ec;
}

#exportAnnotatedPdfBtn:hover {
    background-color: #FF6B00;
}

/* Modal für Label-Manager */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 85%;
    max-width: 1200px;
    max-height: 85vh;
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    overflow-y: auto;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
}

/* Label-Manager Styles */
.label-manager-container {
    margin-top: 16px;
}

.label-list {
    max-height: 60vh;
    overflow-y: auto;
    margin-bottom: 12px;
}

#labelTable {
    width: 100%;
    border-collapse: collapse;
}

#labelTable th {
    padding: 4px 8px 8px;
    text-align: left;
    background: none;
    color: #999;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #e8e8e8;
}

#labelTable th svg {
    display: block;
    margin: 0 auto;
    color: #888;
}

input[type="checkbox"] {
    accent-color: #444;
}

#labelTable td {
    padding: 5px 8px;
    vertical-align: middle;
    border: none;
}

#labelTable tbody tr {
    border-bottom: 1px solid #f3f3f3;
}

#labelTable tbody tr:hover {
    background: #fafafa;
}

/* Layer move buttons */
.layer-move-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 5px;
    color: #bbb;
    font-size: 11px;
    line-height: 1;
    border-radius: 3px;
    display: inline-block;
}

.layer-move-btn:hover:not(:disabled) {
    color: #555;
    background: #eee;
}

.layer-move-btn:disabled {
    color: #e0e0e0;
    cursor: default;
}

/* Inline text edit */
input[type="text"].inline-edit {
    border: none;
    border-bottom: 1px solid transparent;
    background: transparent;
    padding: 2px 4px;
    font-size: 13px;
    width: 100%;
    border-radius: 0;
}

input[type="text"].inline-edit:hover {
    border-bottom-color: #ccc;
}

input[type="text"].inline-edit:focus {
    border-bottom-color: #555;
    outline: none;
}

/* Color picker cell */
.color-cell {
    display: flex;
    align-items: center;
    gap: 0;
}

input[type="color"].inline-edit {
    width: 28px;
    height: 28px;
    padding: 1px 2px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    background: none;
}

.color-preview {
    display: none;
}

/* Opacity slider */
.opacity-slider {
    width: 70px;
    vertical-align: middle;
    accent-color: #444;
}

.opacity-value {
    font-size: 11px;
    color: #aaa;
    margin-left: 4px;
}

/* Delete button */
.label-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.label-form {
    background-color: #f9f9f9;
    padding: 14px;
    border-radius: 5px;
    margin-top: 12px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    justify-content: flex-end;
}

/* Label tabs styling */
.label-tabs {
    display: flex;
    margin-bottom: 15px;
    border-bottom: 1px solid #ddd;
}

.label-tab {
    padding: 8px 15px;
    background: #f2f2f2;
    border: none;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    margin-right: 5px;
}

.label-tab.active {
    background: #444;
    color: #fff;
}

/* Line type dropdown */
#lineTypeSelect {
    flex: 0 0 120px;
    background-color: #fff8f0; /* Light orange background to distinguish from area type */
}

/* Label-Manager = editor */
/* Editor button styling */
.editor-button {
    background-color: #ffffff;
    color: #444;
    border: 1px solid #d0d0d0;
    padding: 7px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin: 2px;
    transition: background 0.12s, border-color 0.12s;
}

.editor-button:hover {
    background-color: #f0f0f0;
    border-color: #999;
}

/* Delete button in label table */
.delete-label-btn,
.copy-label-btn {
    background: none;
    border: none;
    color: #ccc;
    cursor: pointer;
    font-size: 16px;
    padding: 1px 5px;
    border-radius: 3px;
    line-height: 1;
}

.delete-label-btn:hover {
    color: #e74c3c;
    background: #fff0f0;
}

.copy-label-btn:hover {
    color: #444;
    background: #ebebeb;
}


.stroke-width-input {
    width: 48px;
    padding: 2px 4px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 13px;
    text-align: center;
}

/* Label Quick List (left column) */
#labelQuickList {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 45vh;
    overflow-y: auto;
}

.label-quick-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 7px;
    border-radius: 6px;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: background 0.12s, border-color 0.12s;
    user-select: none;
    font-size: 0.85em;
    color: #444;
}

.label-quick-item:hover {
    background: #f0f2f5;
}

.label-quick-item.active {
    background: #ebebeb;
    color: #444;
    font-weight: 600;
}

.label-quick-item.inactive-tool {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

.label-quick-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1.5px solid rgba(0,0,0,0.15);
}

.label-quick-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.label-quick-key {
    font-size: 0.75em;
    color: #aaa;
    background: #f0f0f0;
    border-radius: 3px;
    padding: 0 4px;
    line-height: 1.6;
    flex-shrink: 0;
}

.label-quick-item.active .label-quick-key {
    background: #d8d8d8;
    color: #444;
}

.label-quick-disabled-hint {
    font-size: 0.75em;
    color: #bbb;
    padding: 4px 7px;
    font-style: italic;
}

.save-label-btn {
    background: #27ae60;
    border: 1px solid #219a52;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 4px;
    line-height: 1.4;
    white-space: nowrap;
}

.save-label-btn:hover {
    background: #219a52;
    color: #fff;
}

/* Vereinfachte Label-Auswahl im Editor */
.label-selection-group {
    display: flex;
    align-items: center;
    margin-left: 15px;
    padding: 6px;
    background-color: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #dee2e6;
}

.universal-label-select {
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 13px;
    background-color: white;
    min-width: 120px;
    cursor: pointer;
}

.universal-label-select:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.universal-label-select.no-selection {
    color: #aaa;
    background-color: #f5f5f5;
    border-color: #ddd;
    cursor: default;
}

/* Fabric.js Canvas Styles */
#annotationCanvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: all;
    z-index: 10;
  }
  
/* Add a style for the active editor button */
.editor-button.active {
background-color: #2a70c2;
}
  
/* Basis-Stil für Canvas-Container */
.canvas-container {
    position: absolute !important;
    top: 0;
    left: 0;
    z-index: 5;  /* Standardwert zwischen 2 und 10 */
    overflow: hidden !important;
    pointer-events: auto !important;  /* Immer aktiviert für Interaktionen */
}

/* Spezifischer Stil für den Bearbeitungsmodus */
.editing-mode .canvas-container {
    z-index: 10 !important;  /* Höherer z-index im Bearbeitungsmodus */
}
  
  /* Editor-Werkzeuge */
  .editor-controls {
    padding: 10px 0;
    margin-bottom: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid #ddd;
  }

/* Save Status Indicator */
.save-status {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 5px;
    z-index: 10000;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: opacity 0.3s ease;
}

/* Project buttons styling enhancement */
.project-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.project-button {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
    font-size: 0.9rem;
    padding: 0.75rem 1rem;
}

/* Upload-Modal Styles */
.upload-modal {
    z-index: 10000;
    background-color: rgba(0, 0, 0, 0.8);
}

.upload-modal.active {
    display: flex !important;
}

.upload-modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.upload-modal-header {
    padding: 2rem 2rem 1rem;
    text-align: center;
    border-bottom: 1px solid #e9ecef;
}

.upload-modal-header h2 {
    color: #444;
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
}

.upload-modal-header p {
    color: #666;
    margin: 0;
    font-size: 0.95rem;
}

.upload-modal-body {
    padding: 2rem;
}

/* Upload Drop Zone */
.upload-drop-zone {
    border: 3px dashed #4a90e2;
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    background: #f8f9ff;
    transition: all 0.3s ease;
    cursor: pointer;
    margin-bottom: 2rem;
}

.upload-drop-zone:hover {
    border-color: #357abd;
    background: #f0f5ff;
}

.upload-drop-zone.drag-over {
    border-color: #28a745;
    background: #f0fff4;
    transform: scale(1.02);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.drop-zone-icon {
    font-size: 3rem;
    color: #4a90e2;
}

.drop-zone-text {
    color: #444;
}

.drop-zone-text p {
    margin: 0.25rem 0;
}

.drop-zone-text p:first-child {
    font-size: 1.1rem;
}

.drop-zone-text p:last-child {
    font-size: 0.9rem;
    color: #666;
}

.upload-browse-btn {
    background: #4a90e2;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.upload-browse-btn:hover {
    background: #357abd;
}

/* Uploaded File Info */
.uploaded-file-info {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.file-info-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.file-icon {
    font-size: 1.5rem;
}

.file-name {
    font-weight: 500;
    color: #444;
    flex: 1;
}

.file-size {
    color: #666;
    font-size: 0.9rem;
}

/* Pages Table */
.pages-table {
    margin-bottom: 2rem;
}

.pages-table h3 {
    color: #444;
    margin: 0 0 1rem;
    font-size: 1.2rem;
}

.pages-table-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.control-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.control-btn:hover {
    background: #545b62;
}

.pages-table-container {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 6px;
}

.pages-selection-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.pages-selection-table th {
    background: #f8f9fa;
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
    font-weight: 500;
    position: sticky;
    top: 0;
}

.pages-selection-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #f1f3f4;
}

.pages-selection-table tr:hover {
    background: #f8f9fa;
}

.page-checkbox {
    transform: scale(1.2);
    cursor: pointer;
}

.page-preview {
    width: 60px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #dee2e6;
}

/* Analysis Parameters */
.analysis-parameters {
    border-top: 1px solid #e9ecef;
    padding-top: 2rem;
}

.analysis-parameters h3 {
    color: #444;
    margin: 0 0 1.5rem;
    font-size: 1.2rem;
}

.parameter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.parameter-grid .form-group {
    display: flex;
    flex-direction: column;
}

.parameter-grid label {
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #444;
}

.parameter-grid input,
.parameter-grid select {
    padding: 0.5rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* Modal Footer */
.upload-modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.modal-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-btn.secondary {
    background: #6c757d;
    color: white;
}

.modal-btn.secondary:hover {
    background: #545b62;
}

.modal-btn.primary {
    background: #28a745;
    color: white;
}

.modal-btn.primary:hover {
    background: #218838;
}

.modal-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading Overlay für Modal */
.modal-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    z-index: 10001;
}

.modal-loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.modal-loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4a90e2;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

.modal-loading-text {
    color: #444;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* New Upload Section Styles */
.upload-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    text-align: center;
}

.upload-button {
    background: linear-gradient(135deg, #4a90e2, #357abd);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
    min-width: 200px;
}

.upload-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 144, 226, 0.4);
    background: linear-gradient(135deg, #357abd, #2968a3);
}

.upload-description {
    color: #666;
    font-size: 0.9rem;
    margin: 0;
    max-width: 280px;
    line-height: 1.4;
}

.toggle-legacy-btn {
    background: transparent;
    color: #6c757d;
    border: 1px solid #6c757d;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-legacy-btn:hover {
    background: #6c757d;
    color: white;
}

.legacy-upload {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
}

.legacy-toggle {
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #ffc107;
}

/* =============================================
   Onboarding / Einführungs-Modal
   ============================================= */
.onboarding-content {
    max-width: 560px;
    margin: 6vh auto;
    padding: 22px 24px 20px;
    /* Feste Höhe → Dots/Buttons springen beim Durchklicken nicht mehr.
       Die Medienzone (flex:1) fängt die Höhenunterschiede ab. */
    display: flex;
    flex-direction: column;
    height: 660px;
    max-height: 90vh;
}

.onboarding-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.onboarding-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.onboarding-header h3 .brand-accent {
    color: #FF6B00;
}

.onboarding-counter {
    flex-shrink: 0;
    font-size: 0.78rem;
    color: #888;
    background: #f1f3f5;
    padding: 2px 9px;
    border-radius: 999px;
    white-space: nowrap;
}

/* Medienzone füllt den freien Platz im fest hohen Modal (flex:1) und reserviert
   ihn auch, wenn kein Medium da ist – so springt das Layout nicht. Rahmen/
   Hintergrund nur bei vorhandenem Medium (.has-media, per JS gesetzt). Das
   Bild wird vollständig eingepasst (object-fit: contain, kein Crop). */
.onboarding-media {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    box-sizing: border-box; /* Rahmen in die 100%-Breite einrechnen → kein 2px-Überlauf */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 16px;
}

.onboarding-media.has-media {
    background: #eef4fc;
    border: 1px solid #dce6f2;
}

.onboarding-media img,
.onboarding-media video {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.onboarding-title {
    margin: 0 0 6px;
    font-size: 1.05rem;
    color: #222;
}

.onboarding-body {
    margin: 0 0 18px;
    font-size: 0.92rem;
    line-height: 1.5;
    color: #555;
    min-height: 3em;
    flex-shrink: 0; /* Body nie unter seinen Text schrumpfen → kein Überlauf in die Dots */
    white-space: pre-line; /* \n im Onboarding-Text wird als Zeilenumbruch gerendert */
}

.onboarding-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 18px;
}

.onboarding-dot {
    width: 9px;
    height: 9px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #d3dae2;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.onboarding-dot:hover {
    background: #aebccb;
}

.onboarding-dot.active {
    background: #FF6B00;
    transform: scale(1.25);
}

.onboarding-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.onboarding-skip {
    background: none;
    border: none;
    color: #999;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 6px 4px;
}

.onboarding-skip:hover {
    color: #555;
    text-decoration: underline;
}

.onboarding-nav {
    display: flex;
    gap: 8px;
}



