:root {
    --orange: #f5a623;
    --orange-dark: #e09000;
    --yellow: #ffd54f;
    --yellow-dark: #ffb300;
    --red: #ef5350;
    --red-dark: #c62828;
    --pink: #f8e0f8;
    --blue: #e0f0ff;
    --white: #ffffff;
    --text: #333333;
    --border: #333333;
    --shadow: rgba(0, 0, 0, 0.15);
    --bg: #f5f5f5;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.toolbar {
    background: #fff;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ddd;
    box-shadow: 0 2px 4px var(--shadow);
    flex-wrap: wrap;
    gap: 1rem;
}

.toolbar h1 {
    margin: 0;
    font-size: 1.5rem;
}

.actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.5rem 1rem;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s, transform 0.1s;
}

.btn:hover {
    background: #f0f0f0;
}

.btn.primary {
    background: #2196f3;
    color: #fff;
    border-color: #2196f3;
}

.btn.primary:hover {
    background: #1976d2;
}

.btn.danger {
    color: #d32f2f;
    border-color: #d32f2f;
}

.btn.danger:hover {
    background: #ffebee;
}

.workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.editor-panel {
    width: 320px;
    background: #fff;
    border-right: 1px solid #ddd;
    padding: 1.5rem;
    overflow-y: auto;
}

.editor-panel h2 {
    margin-top: 0;
    font-size: 1.2rem;
}

.editor-panel label {
    display: block;
    margin-bottom: 1rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.editor-panel input,
.editor-panel select {
    display: block;
    width: 100%;
    margin-top: 0.4rem;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.95rem;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.hint {
    margin-top: 2rem;
    padding: 1rem;
    background: #fffde7;
    border-left: 4px solid var(--yellow-dark);
    border-radius: 4px;
    font-size: 0.85rem;
    line-height: 1.5;
}

.preview-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem;
    overflow: auto;
}

.chart {
    min-width: 320px;
    max-width: 420px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px var(--shadow);
}

/* Bereichsfarben */
.chart-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 1rem;
    position: relative;
}

.chart-section.orange {
    background: var(--orange);
}

.chart-section.yellow {
    background: var(--yellow);
}

.chart-section.red {
    background: var(--red);
}

.chart-section + .chart-section::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 20px;
    z-index: 0;
}

.chart-section.orange + .chart-section.yellow::before {
    background: linear-gradient(to right, var(--orange), var(--yellow));
}

.chart-section.yellow + .chart-section.red::before {
    background: linear-gradient(to right, var(--yellow), var(--red));
}

.chart-section.orange + .chart-section.red::before {
    background: linear-gradient(to right, var(--orange), var(--red));
}

/* Verbindungspfeile */
.node-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    position: relative;
    z-index: 1;
}

.node-wrapper.drag-over {
    background: rgba(33, 150, 243, 0.1);
}

.node-wrapper + .node-wrapper {
    margin-top: 0.5rem;
}

.node-wrapper + .node-wrapper::before {
    content: '';
    width: 2px;
    height: 1.5rem;
    background: var(--border);
    margin-bottom: 0.5rem;
}

.node-wrapper + .node-wrapper::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid var(--border);
    margin-bottom: 0.5rem;
}

.node {
    width: 100%;
    max-width: 280px;
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    position: relative;
}

.node:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow);
}

.node {
    cursor: grab;
}

.node.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.node.selected {
    outline: 3px solid #2196f3;
    outline-offset: 3px;
}

.node.bg-pink {
    background: var(--pink);
}

.node.bg-yellow {
    background: #fffde7;
}

.node.bg-blue {
    background: var(--blue);
}

.node.border-dashed {
    border-style: dashed;
}

.node-title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.node-subtitle {
    font-size: 0.85rem;
    color: #555;
    font-weight: 600;
}

.reorder-btns {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.5rem;
    justify-content: center;
}

.reorder-btns button {
    border: none;
    background: rgba(0,0,0,0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.reorder-btns button:hover {
    background: rgba(0,0,0,0.2);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.modal-content h3 {
    margin-top: 0;
}

.modal-content textarea {
    width: 100%;
    font-family: monospace;
    font-size: 0.85rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

@media (max-width: 768px) {
    .workspace {
        flex-direction: column;
    }

    .editor-panel {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #ddd;
    }

    .preview-area {
        padding: 1rem;
    }
}

/* Drucken / Export */
@media print {
    .toolbar, .editor-panel, .reorder-btns, .hint, .modal {
        display: none !important;
    }

    .preview-area {
        padding: 0;
        align-items: flex-start;
    }

    .chart {
        box-shadow: none;
    }
}
