/* 1. SPA-Routing */
.view-hidden { display: none !important; }

/* 2. Animationen */
.app-module { animation: fadeIn 0.3s ease-in-out; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 3. Modals */
dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}
dialog { margin: auto; }

/* ==========================================
   4. DRUCK-LAYOUT (FÜR PDF RECHNUNGEN)
   ========================================== */
@media print {
    /* Alles verstecken */
    body * { visibility: hidden; }
    
    /* Nur das generierte Papier und dessen Kinder anzeigen */
    #invoice-document-paper, #invoice-document-paper * { 
        visibility: visible; 
    }
    
    /* Papier ganz nach oben links ziehen */
    #invoice-document-paper {
        position: absolute !important;
        left: 0 !important; 
        top: 0 !important; 
        width: 100% !important;
        margin: 0 !important; 
        padding: 0 !important;
        box-shadow: none !important; 
        border: none !important;
    }

    /* Modal-Beschränkungen (Scrollbars, Höhen) auflösen, damit mehrere Seiten druckbar sind */
    dialog[open], dialog[open] > div, dialog[open] > div > div {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
        background: transparent !important;
        border: none !important;
    }

    .no-print, .no-print * { display: none !important; visibility: hidden !important; }
    
    /* Erzwingt das Drucken von Tabellen-Hintergrundfarben */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* ==========================================
   5. VORLAGEN-EDITOR (CANVAS)
   ========================================== */
.editor-grid {
    background-size: 20px 20px;
    background-image: 
        linear-gradient(to right, rgba(0, 0, 0, 0.05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
}

.editor-element {
    position: absolute;
    cursor: move;
    border: 1px dashed transparent;
    min-height: 20px;
    min-width: 50px;
    padding: 4px;
    transition: border-color 0.1s;
}

.editor-element:hover {
    border-color: #cbd5e1;
}

.editor-element.active {
    border-color: #3b82f6; 
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
    z-index: 50;
}

.editor-element.editing {
    cursor: text;
    border-color: #22c55e;
    background-color: rgba(255,255,255,0.9);
}

.editor-element[contenteditable="true"]:focus {
    outline: none;
}

/* Custom Resize Handle für Grid-Snapping */
.resize-handle {
    position: absolute;
    right: -6px;
    bottom: -6px;
    width: 14px;
    height: 14px;
    background-color: #3b82f6;
    border: 2px solid white;
    border-radius: 50%;
    cursor: se-resize;
    display: none; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.editor-element.active .resize-handle {
    display: block;
}