/* =============================================================================
   ENERGIE SCHNEE - HAUPTSTYLESHEET
   =============================================================================
   Inhalt:
   1. Tailwind Direktiven
   2. Grundstile
   3. Formulare & Inputs
   4. Buttons
   5. Cards & Results
   6. Details/Summary Komponente
   7. Toasts & Notifications
   8. Modal System
   9. Tab Navigation
   10. Select2 Dropdown
   11. Leaflet & Geosearch
   12. Loader/Spinner
   13. Modul: Dachfläche
   14. Modul: Photovoltaik
   15. Modul: Tesla
   16. Modul: Gebäude-Editor
   17. Modul: Gerätekatalog
   18. Modul: Tickets
   19. Responsive Styles
   20. Print Styles
   ============================================================================= */


/* =============================================================================
   1. TAILWIND DIREKTIVEN
   ============================================================================= */

@tailwind base;
@tailwind components;
@tailwind utilities;


/* =============================================================================
   2. GRUNDSTILE
   ============================================================================= */

html {
    /* Minimum-Zoom 100% - verhindert zu kleine Darstellung auf großen Bildschirmen */
    zoom: 1;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #f1f5f9; /* slate-100 */
}

.card {
    background-color: white;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.hidden {
    display: none !important;
}

.sub-headline {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1e293b;
    border-top: 1px solid #e5e7eb;
    padding-top: 1rem;
    margin-top: 1rem;
}

/* Utility Classes */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Global Header Buttons (Chat, Fehler melden) - nur auf XL-Bildschirmen */
.global-header-btn {
    display: none !important;
}

@media (min-width: 1280px) {
    .global-header-btn {
        display: flex !important;
    }
}


/* =============================================================================
   3. FORMULARE & INPUTS
   ============================================================================= */

.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: flex;
    align-items: center;
    color: #4b5563; /* gray-600 */
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.input-group label svg {
    width: 1rem;
    height: 1rem;
    margin-right: 0.5rem;
    color: #6b7280; /* gray-500 */
}

.input-group input,
.input-group select,
.input-group textarea {
    width: 100%;
    border: 1px solid #d1d5db; /* gray-300 */
    border-radius: 0.5rem !important;
    padding: 0.75rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

/* Override Bootstrap input-group that makes left corners square */
.input-group > :not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback) {
    margin-left: 0 !important;
    border-top-left-radius: 0.5rem !important;
    border-bottom-left-radius: 0.5rem !important;
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
    outline: none;
    border-color: #3b82f6; /* blue-500 */
    box-shadow: 0 0 0 3px rgb(59 130 246 / 0.2);
}

.edit-input {
    width: 80px;
    text-align: right;
    padding: 0.25rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
}

/* Tailwind @apply Klassen für Inputs */
.input-text {
    @apply block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6 p-2;
}

.cost-input {
    @apply p-1 w-24 border rounded-md;
}

/* Settings Input Styling */
.settings-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: center;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #f3f4f6; /* gray-100 */
}

.settings-row:last-child {
    border-bottom: none;
}

.settings-label {
    font-size: 0.875rem;
    color: #374151; /* gray-700 */
}

.settings-input-group {
    display: flex;
    align-items: center;
}

.settings-input {
    width: 100px;
    text-align: right;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    padding: 0.25rem 0.5rem;
}

.settings-unit {
    margin-left: 0.5rem;
    font-size: 0.875rem;
    color: #6b7280; /* gray-500 */
    width: 80px;
    white-space: nowrap;
}

.settings-info {
    grid-column: 2 / -1;
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: -0.5rem;
}

.module-settings {
    background-color: #f9fafb;
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
}

/* Slider Styling */
.distortion-slider {
    -webkit-appearance: none;
    appearance: none;
    background: #e5e7eb;
    outline: none;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.distortion-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #3b82f6;
    cursor: pointer;
    border-radius: 50%;
}

.distortion-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #3b82f6;
    cursor: pointer;
    border-radius: 50%;
}


/* =============================================================================
   4. BUTTONS
   ============================================================================= */

.edit-btn {
    background: none;
    border: none;
    cursor: pointer;
    margin-left: 0.5rem;
    color: #9ca3af;
    transition: color 0.2s;
    line-height: 1;
}

.edit-btn:hover {
    color: #3b82f6;
}

.reset-btn {
    background-color: #ef4444;
    color: white;
    border-radius: 50%;
    width: 1.25rem;
    height: 1.25rem;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s;
    margin-left: 0;
    margin-right: 0.5rem;
}

.reset-btn:hover {
    transform: rotate(360deg);
}

.settings-btn {
    color: #6b7280;
    transition: all 0.2s ease-in-out;
}

.settings-btn:hover {
    color: #1d4ed8;
    transform: rotate(45deg);
}

/* Tab Buttons */
.tab-link {
    @apply py-4 px-1 border-b-2 font-medium text-sm text-gray-500 hover:text-gray-700 hover:border-gray-300;
}

.active-tab {
    @apply border-blue-500 text-blue-600;
}

.tab-button {
    @apply w-full text-center px-4 py-2 rounded-lg font-semibold text-gray-600 transition-colors duration-200;
}

.tab-button.active {
    @apply bg-gray-800 text-white shadow-md;
    border-color: #4f46e5;
    background-color: #eef2ff;
    color: #4f46e5;
    font-weight: 600;
}

.tab-button:not(.active):hover {
    @apply bg-gray-300;
}

/* Long-term Simulation Buttons */
.long-term-sim-btn {
    background-color: transparent;
    color: #4b5563; /* gray-600 */
    transition: all 0.2s;
}

.long-term-sim-btn.active {
    background-color: white;
    color: #111827; /* gray-900 */
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

/* Control Buttons (Tesla-Modul) */
.control-group {
    @apply p-4 border border-gray-200 rounded-lg;
}

.control-group h4 {
    @apply text-lg font-bold mb-3;
}

.control-item {
    @apply flex justify-between items-center py-2;
}

.control-item button {
    @apply px-4 py-1.5 bg-sky-500 text-white rounded-md font-semibold hover:bg-sky-600;
}


/* =============================================================================
   5. CARDS & RESULTS
   ============================================================================= */

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e5e7eb; /* gray-200 */
}

.result-item:last-child {
    border-bottom: none;
}

.result-label {
    color: #4b5563; /* gray-600 */
    display: flex;
    align-items: center;
}

.result-label svg {
    width: 1rem;
    height: 1rem;
    margin-right: 0.75rem;
    color: #3b82f6;
}

.result-value {
    color: #111827; /* gray-900 */
    font-weight: 600;
    font-size: 1.125rem;
    text-align: right;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.result-value .unit,
.sub-text {
    font-size: 0.875rem;
    font-weight: 400;
    color: #6b7280; /* gray-500 */
    margin-left: 0.25rem;
}

.sub-text {
    width: 100%;
    text-align: right;
    font-size: 0.75rem;
}

/* Delta Boxes */
.delta-box {
    font-size: 0.7rem;
    font-weight: 700;
    color: white;
    padding: 0.1rem 0.3rem;
    border-radius: 0.25rem;
    margin-right: 0.5rem;
}

.delta-box .unit {
    color: white;
}

.delta-green {
    background-color: #22c55e;
}

.delta-red {
    background-color: #ef4444;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}


/* =============================================================================
   6. DETAILS/SUMMARY KOMPONENTE
   ============================================================================= */

details.result-item {
    padding: 0;
    flex-wrap: wrap;
    border-bottom: 1px solid #e5e7eb;
}

details.result-item:last-child {
    border-bottom: none;
}

details.result-item > summary {
    list-style: none;
    padding: 0.75rem 0;
    width: 100%;
    cursor: pointer;
}

details.result-item > summary::-webkit-details-marker {
    display: none;
}

details.result-item[open] > summary .arrow-icon {
    transform: rotate(90deg);
}

.arrow-icon {
    transition: transform 0.2s;
    color: #3b82f6;
}

.details-content {
    width: 100%;
    padding: 0.75rem 1rem;
    margin-top: 0;
    font-size: 0.875rem;
    color: #4b5563;
    background-color: #f9fafb;
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
}

.details-content > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.375rem 0;
    border-bottom: 1px solid #e5e7eb;
}

.details-content > div:last-child {
    border-bottom: none;
}

.details-content > div > span:first-child {
    color: #6b7280;
}

.details-content > div > span:last-child {
    font-weight: 500;
    color: #374151;
}

.details-content hr {
    border: none;
    border-top: 1px solid #d1d5db;
    margin: 0.5rem 0;
}

/* Akkordeon Summary Styling (Gerätekatalog) */
details summary {
    list-style: none;
    user-select: none;
}

details summary::-webkit-details-marker {
    display: none;
}

details summary::before {
    content: '\25B6';
    display: inline-block;
    margin-right: 8px;
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

details[open] summary::before {
    transform: rotate(90deg);
}


/* =============================================================================
   7. TOASTS & NOTIFICATIONS
   WICHTIG: Kein @apply verwenden - wir nutzen Tailwind CDN!
   ============================================================================= */

.toast {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    color: white;
    font-weight: 600;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    z-index: 10000;
    max-width: 400px;
}

.toast.info {
    background-color: #3b82f6; /* blue-500 */
}

.toast.success {
    background-color: #22c55e; /* green-500 */
}

.toast.error {
    background-color: #ef4444; /* red-500 */
}


/* =============================================================================
   8. MODAL SYSTEM
   ============================================================================= */

/* Global modal positioning - OVER module header and tabs, but UNDER nav (sticky z-50) */
.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 49 !important;
    background-color: rgba(31, 41, 55, 0.75) !important; /* bg-gray-800 with 75% opacity */
    padding-top: 4rem !important; /* 64px - Platz für Nav-Header (h-16) */
}

/* Full-screen modal variant (covers everything including nav) */
.modal-overlay-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
}


/* =============================================================================
   8b. GLOBAL TASK MANAGER
   ============================================================================= */

#global-task-container {
    z-index: 100001;
}

#task-dropdown {
    animation: taskDropdownFadeIn 0.15s ease-out;
}

@keyframes taskDropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#task-dropdown::-webkit-scrollbar {
    width: 6px;
}

#task-dropdown::-webkit-scrollbar-track {
    background: #f1f5f9;
}

#task-dropdown::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}


/* =============================================================================
   9. TAB NAVIGATION
   ============================================================================= */

/* Tab Navigation Buttons - Clean, professional style */
.tab-nav-button {
    border: none;
    background-color: #f3f4f6;
    color: #4b5563;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.tab-nav-button.active {
    color: #ffffff;
    background-color: #2563eb;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.2);
}

.tab-nav-button:not(.active):hover:not(.disabled) {
    color: #1f2937;
    background-color: #e5e7eb;
}

.tab-nav-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    color: #9ca3af;
}

/* Photovoltaik Container */
#photovoltaik-container {
    min-height: 100vh;
    background-color: #f1f5f9;
}

/* Tab Panes - Simple show/hide */
.tab-pane {
    display: none;
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
}

.tab-pane.active {
    display: block;
}


/* =============================================================================
   10. SELECT2 DROPDOWN
   ============================================================================= */

.select2-container--default .select2-results__option {
    font-size: 0.75rem !important;
    padding: 0.5rem 0.75rem !important;
    line-height: 1.5 !important;
}

.select2-container--default .select2-selection--single {
    font-size: 0.75rem !important;
    height: auto !important;
    padding: 0.5rem 0.75rem !important;
    margin-top: 0 !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    font-size: 0.75rem !important;
    line-height: 1.5 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 100% !important;
    right: 0.75rem !important;
}

/* z-index für Select2 */
.select2-container {
    z-index: 1 !important;
}

/* WICHTIG: Das geöffnete Dropdown muss ÜBER den sticky Headern sein (z-40, z-50) */
.select2-dropdown {
    z-index: 100000 !important;
}

.select2-container--open {
    z-index: 100000 !important;
}

/* FOUC-Prevention für Project-Select */
/* Das native Select komplett verstecken bis Select2 initialisiert ist */
/* Verhindert dass Benutzer das native Dropdown sieht/anklickt */
#project-select:not(.select2-hidden-accessible) {
    /* Unsichtbar aber nimmt Platz ein für korrektes Layout */
    opacity: 0 !important;
    pointer-events: none !important;
    height: 38px !important;
    width: 320px !important;
}

/* Der Select2-Container soll die Breite vom Original-Select erben */
#project-select + .select2-container {
    width: 320px !important;
    min-width: 320px !important;
    position: relative !important;
    z-index: 1 !important;
}

/* Das Projekt-Label muss über dem Select2-Container bleiben */
#project-select ~ .select2-container,
.relative > label.absolute {
    /* Label ist bereits z-10, daher sollte es über dem Select2 sein */
}

/* Sicherstellen dass das Label nicht abgeschnitten wird */
.relative:has(#project-select) {
    overflow: visible !important;
}

/* Für EAB-Modul: w-72 (288px) */
#project-select.sm\:w-72 + .select2-container {
    width: 288px !important;
    min-width: 288px !important;
}


/* =============================================================================
   11. LEAFLET & GEOSEARCH
   GeoSearch Styles sind jetzt in geosearch-custom.css (lokal)
   ============================================================================= */

/* Leaflet Editing Icons */
.leaflet-div-icon.leaflet-editing-icon {
    background: #4f46e5 !important;
    border-radius: 50% !important;
    border: 2px solid white !important;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.7) !important;
    width: 12px !important;
    height: 12px !important;
    margin-left: -7px !important;
    margin-top: -7px !important;
}

/* Leaflet Layer Control - mehrzeilig mit Scroll */
.leaflet-control-layers-expanded {
    max-height: 300px;
    overflow-y: auto;
}

.leaflet-control-layers-expanded .leaflet-control-layers-list {
    display: block;
}

.leaflet-control-layers-base label,
.leaflet-control-layers-overlays label {
    display: block;
    padding: 4px 0;
    white-space: nowrap;
}


/* =============================================================================
   12. LOADER/SPINNER
   ============================================================================= */

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.area-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(59, 130, 246, 0.3);
    border-radius: 50%;
    border-top-color: #3b82f6;
    animation: spin 1s ease-in-out infinite;
}

.loader-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

#loader-overlay {
    backdrop-filter: blur(4px);
}


/* =============================================================================
   13. MODUL: DACHFLÄCHE
   ============================================================================= */

/* Global Actions Container */
#global-actions-container {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Edge Select Icon */
.edge-select-icon {
    background-color: rgba(0, 123, 255, 0.8);
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    width: 12px !important;
    height: 12px !important;
    margin-left: -6px !important;
    margin-top: -6px !important;
}

/* PV Module Style */
.pv-module {
    fill-color: #28323c;
    fill-opacity: 0.8;
    color: #a5f3fc;
    weight: 1;
}

/* Area Cards */
.area-card {
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    background-color: #f9fafb;
    transition: all 0.3s ease-in-out;
    overflow: hidden;
}

.area-card.active {
    border-color: #3b82f6;
    background-color: white;
}

.area-card.collapsed .arrow-icon {
    transform: rotate(0deg);
}

.area-card.expanded .arrow-icon {
    transform: rotate(90deg);
}

.area-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    cursor: pointer;
    width: 100%;
}

.area-summary:hover {
    background: #f3f4f6;
}

.area-summary h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #374151;
}

.area-card.active .area-summary {
    background: #eff6ff;
}

.area-content-wrapper {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-in-out;
}

.area-content-wrapper .area-content {
    padding: 0 1rem 1rem 1rem;
    border-top: 1px solid #e5e7eb;
}

.area-content {
    padding: 1rem;
}

.area-name-input {
    font-size: 1rem;
    font-weight: 600;
    border: none;
    outline: none;
    padding: 0.25rem;
    border-radius: 0.25rem;
    flex-grow: 1;
}

.area-name-input:focus {
    background: white;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.area-mode-indicator {
    font-size: 1.25rem;
    margin-right: 0.5rem;
}

/* Delete Area Button */
.delete-area-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: background 0.2s;
}

.delete-area-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Result Text Colors */
.ground-area-result,
.roof-area-result,
.azimuth-result,
.length-result {
    color: #059669;
}

.module-count-result,
.total-power-result {
    color: #2563eb;
}

/* Pitch Input */
.pitch-input,
.calculate-btn {
    transition: all 0.2s;
}

.pitch-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}

.calculate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Eave Arrow Indicator */
.eave-arrow-indicator {
    pointer-events: auto;
    cursor: pointer;
    transition: all 0.3s ease;
}

.eave-arrow-indicator:hover {
    transform: scale(1.2);
}

.eave-arrow-indicator .arrow-container {
    animation: pulseArrow 2s ease-in-out infinite;
}

@keyframes pulseArrow {
    0%, 100% {
        opacity: 1;
        transform: rotate(var(--arrow-rotation, 0deg)) translateX(0);
    }
    50% {
        opacity: 0.6;
        transform: rotate(var(--arrow-rotation, 0deg)) translateX(-5px);
    }
}

/* Resizable 3D Window */
.resizable {
    resize: none;
    position: relative;
}

.resizer-handle {
    width: 12px;
    height: 12px;
    background: #e5e7eb; /* gray-200 */
    border-left: 2px solid #a1a1aa; /* gray-400 */
    border-top: 2px solid #a1a1aa;
    position: absolute;
    left: 0;
    top: 0;
    cursor: nwse-resize;
    z-index: 10;
}


/* =============================================================================
   14. MODUL: PHOTOVOLTAIK
   ============================================================================= */

/* (Styles are mostly in tab-navigation section above) */


/* =============================================================================
   15. MODUL: TESLA
   ============================================================================= */

#car-grid-layout {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 1rem;
    width: 520px;
    height: 220px;
}

.car-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    color: white;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.car-panel:hover {
    border-color: #3b82f6;
}

/* Grid-Positionierung */
#frunk-btn { grid-column: 1 / 2; grid-row: 1 / 3; }
#climate-btn { grid-column: 2 / 3; grid-row: 1 / 2; }
#door-lock-btn { grid-column: 2 / 3; grid-row: 2 / 3; }
#battery-btn { grid-column: 3 / 4; grid-row: 1 / 3; }
#trunk-btn { grid-column: 4 / 5; grid-row: 1 / 3; }

/* Zustands-Farben */
.state-off { background-color: #64748b; }
.state-on { background-color: #3b82f6; }
.state-charging { background-color: #22c55e !important; }
.state-plugged-in { background-color: #0284c7 !important; }

/* Batterie-Füll-Animation */
#battery-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #16a34a;
    height: var(--soc-percent, 0%);
    transition: height 0.5s ease-in-out;
    z-index: 5;
}

#battery-icon,
#battery-soc {
    position: relative;
    z-index: 10;
}

/* Lade-Anzeige */
#charge-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 1rem;
}

#charge-cable {
    width: 5px;
    height: 30px;
    background-color: #1f2937;
    position: relative;
}

#charge-stats {
    @apply bg-gray-800 text-white p-2 rounded-md text-xs leading-tight shadow-lg;
    min-width: 80px;
    text-align: center;
}

#charge-flow-dot {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: white;
    opacity: 0;
}

#charge-display.state-plugged-in #charge-cable {
    background-color: #1f2937;
}

#charge-display.state-charging #charge-cable {
    background-color: #22c55e;
}

#charge-display.state-charging #charge-flow-dot {
    opacity: 1;
    animation: flow-up 1.5s linear infinite;
}

@keyframes flow-up {
    from { bottom: -10%; }
    to { bottom: 100%; }
}


/* =============================================================================
   16. MODUL: GEBÄUDE-EDITOR
   ============================================================================= */

#grundriss-canvas {
    cursor: crosshair;
    background-color: #ffffff;
    touch-action: none;
}

#grundriss-canvas.panning {
    cursor: grabbing !important;
}

#grundriss-canvas.pan-tool {
    cursor: grab;
}

.tool-button.active {
    background-color: #4f46e5;
    color: white;
}

.snap-button.active {
    background-color: #dbeafe;
    color: #1e40af;
    font-weight: 500;
}


/* =============================================================================
   17. MODUL: GERÄTEKATALOG
   ============================================================================= */

/* Device Cards */
.device-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.device-card:hover {
    transform: translateY(-2px);
}

/* AI Suggested Fields */
.ai-suggested {
    border-color: #9333ea !important;
    background-color: #faf5ff !important;
}

.ai-loading {
    border-color: #a855f7 !important;
    background: linear-gradient(90deg, #faf5ff 0%, #f3e8ff 50%, #faf5ff 100%) !important;
    background-size: 200% 100% !important;
    animation: ai-shimmer 1.5s ease-in-out infinite;
}

@keyframes ai-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.ai-indicator {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
}

/* PDF Viewer */
#pdf-viewer-container {
    background: #374151; /* gray-700 */
}

#pdf-pages-container {
    padding-bottom: 20px;
}

.pdf-page-wrapper {
    background: white;
    margin-bottom: 16px;
}

.pdf-page-canvas {
    display: block;
}

/* PDF Text Layer - enables text selection */
.pdf-text-layer {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    opacity: 0.2;
    line-height: 1.0;
}

.pdf-text-layer > span {
    color: transparent;
    position: absolute;
    white-space: pre;
    pointer-events: all;
}

.pdf-text-layer > span::selection {
    background: rgba(0, 0, 255, 0.3);
}

.pdf-text-layer > span::-moz-selection {
    background: rgba(0, 0, 255, 0.3);
}

/* PDF Drag & Drop Zone */
.pdf-drop-zone {
    transition: all 0.3s ease;
    border: 2px dashed transparent;
    position: relative;
}

.pdf-drop-zone.drag-over {
    border-color: #3b82f6;
    background-color: rgba(59, 130, 246, 0.1) !important;
}

.pdf-drop-zone.drag-over .drag-overlay {
    display: flex !important;
}

.pdf-drop-zone .drag-overlay {
    display: none;
}

/* Split View Resize Handle */
.split-handle {
    width: 4px;
    background: #e5e7eb;
    cursor: col-resize;
    transition: background 0.2s;
}

.split-handle:hover {
    background: #3b82f6;
}

/* Checkbox Grid Styling */
#inverter-fields label.flex.items-center,
#storage-fields label.flex.items-center {
    white-space: nowrap;
}

#inverter-fields .grid.grid-cols-2 label,
#storage-fields .grid.grid-cols-2 label {
    min-height: 24px;
    display: flex;
    align-items: center;
}

/* Scrollbar Styling for Modal */
#create-device-modal .overflow-y-auto::-webkit-scrollbar {
    width: 8px;
}

#create-device-modal .overflow-y-auto::-webkit-scrollbar-track {
    background: #f1f5f9;
}

#create-device-modal .overflow-y-auto::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

#create-device-modal .overflow-y-auto::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}


/* =============================================================================
   18. MODUL: TICKETS
   ============================================================================= */

#ticket-form-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#screenshot-preview-container {
    max-height: 300px;
    overflow-y: auto;
}


/* =============================================================================
   19. RESPONSIVE STYLES
   ============================================================================= */

@media (max-width: 768px) {
    .tab-nav-container {
        padding: 0.5rem;
        gap: 0.25rem;
        overflow-x: auto;
    }

    .tab-nav-button {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }

    .tab-pane {
        padding: 1rem;
    }
}


/* =============================================================================
   20. PRINT STYLES
   ============================================================================= */

@media print {
    body > nav,
    .print-button,
    details summary .arrow-icon,
    .edit-btn,
    #foerderung-details > summary,
    .reset-btn {
        display: none !important;
    }

    body {
        background-color: white !important;
    }

    .card,
    .result-item {
        box-shadow: none !important;
        border: 1px solid #e5e7eb;
        page-break-inside: avoid !important;
    }

    .delta-box {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    details {
        page-break-inside: avoid !important;
    }

    details[open] {
        padding-bottom: 0.5rem;
    }

    details > summary {
        pointer-events: none;
    }

    details > summary .arrow-icon {
        display: none;
    }

    #create-device-modal,
    #device-detail-modal,
    #approval-modal {
        display: none !important;
    }
}

/* =============================================
   DACHFLAECHE / PV-AUSLEGUNG MODULE
   ============================================= */

/* Verhindert Scrolling im Dachplaner-Modul */
body.dachflaeche-module {
    overflow: hidden !important;
    height: 100vh !important;
    max-height: 100vh !important;
    margin: 0;
    padding: 0;
    position: fixed !important;
    width: 100%;
}

body.dachflaeche-module > div.min-h-full {
    min-height: 0 !important;
    height: 100vh !important;
    max-height: 100vh !important;
    overflow: hidden !important;
}

body.dachflaeche-module main {
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
    height: auto !important;
}

body.dachflaeche-module main > div {
    padding: 0 !important;
    margin: 0 !important;
    height: 100%;
}

#dachplaner-container {
    position: fixed;
    top: 120px;
    left: 0;
    right: 0;
    bottom: 0;
    height: auto !important;
    overflow: hidden !important;
}

/* Collapsible Sections */
.collapsible-content {
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.collapsible-content.collapsed {
    max-height: 0 !important;
}

.collapse-arrow {
    transition: transform 0.3s ease;
}

.collapse-arrow.rotate-180 {
    transform: rotate(-180deg);
}

/* Terrain Editing Toolbar */
#terrain-editing-toolbar-container {
    background: #f9fafb;
}

#terrain-editing-toolbar input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #d1d5db;
    border-radius: 3px;
    outline: none;
}

#terrain-editing-toolbar input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #0066cc;
    border-radius: 50%;
    cursor: pointer;
}

#terrain-editing-toolbar input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #0066cc;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

#terrain-editing-toolbar input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* 3D View Container - Kleines Fenster */
#3d-view-container {
    background: #1a1a2e !important;
    border: 1px solid #374151 !important; /* gray-700 - gleich wie Header */
}

#3d-canvas-container {
    background: #1a1a2e !important;
}

/* 3D Fullscreen Mode */
#3d-view-container.fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    min-width: unset !important;
    min-height: unset !important;
    z-index: 10000 !important;
    border-radius: 0 !important;
    resize: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

#3d-view-container.fullscreen #3d-view-header {
    cursor: default !important;
}

/* Toolbar in Fullscreen Mode */
#3d-view-container.fullscreen #terrain-editing-toolbar-container {
    position: absolute !important;
    display: block !important;
    top: 0 !important;
    right: 0 !important;
    width: 320px !important;
    height: 100vh !important;
    z-index: 10001 !important;
}

#3d-view-container.fullscreen #3d-canvas-container {
    width: calc(100% - 320px) !important;
}

/* View Swap Mode */
#map-overlay-header {
    display: none;
}

/* Im Swap-Mode: Map-Container wird zur kleinen Ansicht */
#main-view-area.views-swapped #map-container {
    resize: both;
    overflow: hidden;
}

#main-view-area.views-swapped #map {
    height: calc(100% - 32px) !important;
}

/* Zoom-Buttons ausblenden (Mausrad reicht) */
.leaflet-control-zoom {
    display: none !important;
}

/* Im Swap-Mode: Leaflet-Controls in der kleinen Karte ausblenden */
#main-view-area.views-swapped #map-container .leaflet-control-container {
    display: none !important;
}


/* =============================================================================
   21. MODUL: BACHELORARBEIT
   ============================================================================= */

/* ===== HAUPTLAYOUT: Fixe Höhe, kein Seitenscroll ===== */
.bachelorarbeit-module {
    overflow: hidden !important;
    height: 100vh !important;
}

/* Navbar + Header = ca. 128px (64px + 52px + etwas Padding) */
.bachelorarbeit-module main {
    overflow: hidden !important;
    height: calc(100vh - 116px) !important;
}

.bachelorarbeit-module main > div {
    max-width: 100% !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    height: 100% !important;
    overflow: hidden !important;
}

#thesis-container {
    height: 100% !important;
    width: 100% !important;
    display: flex !important;
    overflow: hidden !important;
}

/* ===== LINKE SIDEBAR: Kapitelstruktur ===== */
#sidebar-struktur {
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid #e5e7eb;
    background: white;
}

#kapitel-baum {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    padding: 0.5rem;
}

#statistik-box {
    flex-shrink: 0;
}

/* ===== MITTE: Editor + Vorschau ===== */
#main-editor {
    flex: 1;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#editor-toolbar {
    flex-shrink: 0;
    height: 44px;
}

#current-path {
    flex-shrink: 0;
    height: 28px;
}

#editor-split {
    flex: 1;
    min-height: 0;
    display: flex;
    overflow: hidden;
}

#editor-container {
    flex: 1;
    min-width: 0;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#markdown-editor {
    flex: 1;
    width: 100%;
    min-height: 0;
    resize: none;
    border: none;
    padding: 1rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    background: #fafafa;
    overflow-y: auto;
}

#markdown-editor:focus {
    outline: none;
}

#preview-container {
    flex: 1;
    min-width: 0;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    background: white;
}

/* ===== RECHTE SIDEBAR: Quellen ===== */
#sidebar-quellen {
    width: 320px;
    min-width: 320px;
    max-width: 320px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-left: 1px solid #e5e7eb;
    background: white;
}

#quellen-liste {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    padding: 0.5rem;
}

/* Quellen-Suche und Filter */
#sidebar-quellen > div:nth-child(2),
#sidebar-quellen > div:nth-child(3) {
    flex-shrink: 0;
}

/* Tabs unten */
#sidebar-quellen > div:last-child {
    flex-shrink: 0;
}

/* Toolbar Buttons */
.bachelorarbeit-module .toolbar-btn {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    color: #374151;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s;
}

.bachelorarbeit-module .toolbar-btn:hover {
    background-color: #e5e7eb;
}

.bachelorarbeit-module .toolbar-btn.active {
    background-color: #dbeafe;
    color: #1d4ed8;
}

/* Kapitel-Baum Elemente */
.kapitel-header {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: #f3f4f6;
    border-radius: 0.25rem;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    font-size: 0.8rem;
}

.kapitel-header:hover {
    background: #e5e7eb;
}

.kapitel-chevron {
    transition: transform 0.2s;
}

.kapitel-chevron.rotate-180 {
    transform: rotate(180deg);
}

.kapitel-dateien {
    margin-top: 0.25rem;
}

.kapitel-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.75rem;
    color: #4b5563;
}

.kapitel-item:hover {
    background: #f3f4f6;
}

.kapitel-item.active {
    background: #dbeafe;
    color: #1e40af;
}

.status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-offen { background: #d1d5db; }
.status-in_arbeit { background: #fbbf24; }
.status-done { background: #22c55e; }

/* Quellen-Karten */
.quelle-card {
    padding: 0.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.75rem;
}

.quelle-card:hover {
    border-color: #93c5fd;
    background: #eff6ff;
}

.quelle-card.selected {
    border-color: #3b82f6;
    background: #eff6ff;
}

/* Markdown-Vorschau Styling */
#markdown-preview {
    font-family: Arial, sans-serif;
    font-size: 11pt;
    line-height: 1.5;
    color: #1f2937;
    padding: 1.5rem;
}

#markdown-preview h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 1.5rem 0 0.75rem 0;
    color: #111827;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0.5rem;
}

#markdown-preview h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 1.25rem 0 0.5rem 0;
    color: #1f2937;
}

#markdown-preview h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1rem 0 0.5rem 0;
    color: #374151;
}

#markdown-preview h4 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0.75rem 0 0.5rem 0;
    color: #4b5563;
}

#markdown-preview p {
    margin-bottom: 0.75rem;
    text-align: justify;
}

#markdown-preview ul,
#markdown-preview ol {
    margin: 0.5rem 0 0.75rem 1.5rem;
}

#markdown-preview li {
    margin-bottom: 0.25rem;
}

#markdown-preview blockquote {
    border-left: 4px solid #3b82f6;
    padding-left: 1rem;
    margin: 1rem 0;
    color: #4b5563;
    font-style: italic;
    background: #f8fafc;
    padding: 0.75rem 1rem;
    border-radius: 0 0.25rem 0.25rem 0;
}

#markdown-preview code {
    background: #f1f5f9;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
    font-family: 'Consolas', monospace;
    color: #be185d;
}

#markdown-preview pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 1rem 0;
}

#markdown-preview pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

#markdown-preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9rem;
}

#markdown-preview th,
#markdown-preview td {
    border: 1px solid #e5e7eb;
    padding: 0.5rem 0.75rem;
    text-align: left;
}

#markdown-preview th {
    background: #f8fafc;
    font-weight: 600;
}

#markdown-preview tr:nth-child(even) {
    background: #fafafa;
}

#markdown-preview a {
    color: #2563eb;
    text-decoration: underline;
}

#markdown-preview a:hover {
    color: #1d4ed8;
}

#markdown-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    margin: 1rem 0;
}

#markdown-preview hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 1.5rem 0;
}

/* Chart-Container */
.chart-container {
    margin: 1rem 0;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    height: 320px;
    position: relative;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* TODO/FIXME/Kommentar Marker */
.todo-marker {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    padding: 0.5rem 0.75rem;
    margin: 0.5rem 0;
    font-size: 0.875rem;
    color: #92400e;
    border-radius: 0 0.25rem 0.25rem 0;
}

.fixme-marker {
    background: #fee2e2;
    border-left: 4px solid #ef4444;
    padding: 0.5rem 0.75rem;
    margin: 0.5rem 0;
    font-size: 0.875rem;
    color: #991b1b;
    border-radius: 0 0.25rem 0.25rem 0;
}

.kommentar-marker {
    background: #dbeafe;
    border-left: 4px solid #3b82f6;
    padding: 0.5rem 0.75rem;
    margin: 0.5rem 0;
    font-size: 0.875rem;
    color: #1e40af;
    border-radius: 0 0.25rem 0.25rem 0;
}

/* Zitationen */
.citation {
    color: #2563eb;
    cursor: pointer;
    transition: background-color 0.15s;
    border-radius: 2px;
    padding: 0 2px;
}

.citation:hover {
    background-color: #dbeafe;
}

.citation-error {
    color: #dc2626;
    background-color: #fee2e2;
}

/* Literaturverzeichnis */
.bibliography {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid #e5e7eb;
}

.bibliography h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: #1f2937;
}

.bibliography-entries {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.bib-entry {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 0.25rem;
    transition: background-color 0.15s;
}

.bib-entry:hover {
    background-color: #f3f4f6;
}

.bib-number {
    color: #6b7280;
    font-weight: 500;
    min-width: 2rem;
}

.bib-content {
    flex: 1;
    line-height: 1.5;
}

/* Resizer zwischen Editor und Vorschau */
#editor-resizer {
    width: 4px;
    background: #e5e7eb;
    cursor: col-resize;
    flex-shrink: 0;
    transition: background 0.15s;
}

#editor-resizer:hover {
    background: #3b82f6;
}

/* ========================================
   Math formula rendering (MathML for PDF, KaTeX for HTML)
   ======================================== */

/* Block-Formeln ($$...$$) */
.formula-block {
    margin: 1.5rem 0;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 0.375rem;
    text-align: center;
    overflow-x: auto;
}

.formula-block math {
    font-size: 1.2em;
}

/* Inline-Formeln ($...$) */
.formula-inline {
    display: inline;
    font-size: 1.1em;
}

.formula-inline math {
    display: inline;
}

/* Fehlerdarstellung */
.formula-error {
    color: #cc0000;
    font-family: monospace;
    background: #fee;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}

/* KaTeX-Kompatibilität (HTML-Ansicht) */
.katex-display {
    margin: 1.5rem 0;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 0.375rem;
    text-align: center;
    overflow-x: auto;
}

.katex {
    font-size: 1.1em;
}

.katex-display > .katex {
    font-size: 1.2em;
}
