:root {
    --primary: #79b51c;
    --primary-glow: rgba(121, 181, 28, 0.15);
    --bg: #f8fafc;
    --sidebar: #ffffff;
    --card: #ffffff;
    --text: #0f172a;
    --text-dim: #64748b;
    --border: #e2e8f0;
    --radius: 20px;
    --font-main: 'Plus Jakarta Sans';
}

body.dark-mode {
    --bg: #0f172a;
    --sidebar: #1e293b;
    --card: #1e293b;
    --text: #f8fafc;
    --text-dim: #94a3b8;
    --border: #334155;
}

* { 
    margin: 0; padding: 0; box-sizing: border-box; 
    font-family: var(--font-main), sans-serif; 
    letter-spacing: -0.01em; /* Subtiler moderner Look */
}

body {
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: all 0.3s;
    line-height: 1.5; /* Bessere Grund-Lesbarkeit */
}

/* App Wrapper als Flex-Container für Desktop */
#app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
#sidebar {
    width: 320px;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 40px 24px;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    z-index: 10;
}

.sidebar-header { margin-bottom: 40px; }
.sidebar-header h1 { 
    font-size: clamp(24px, 5vw, 28px); 
    font-weight: 800; 
    letter-spacing: -1px; 
    margin-top: 8px; 
    overflow-wrap: break-word;
}

.search-container {
    position: relative;
    margin-bottom: 30px;
}

.search-container i {
    position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
    color: var(--text-dim); width: 18px;
}

.search-container input {
    width: 100%; padding: 14px 14px 14px 44px;
    background: var(--bg); border: 2px solid transparent; border-radius: 14px;
    font-size: 15px; color: var(--text); outline: none; transition: 0.3s;
}

.search-container input:focus { border-color: var(--primary); background: var(--sidebar); }

#categoryNav { flex: 1; display: flex; flex-direction: column; gap: 8px; }

.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px; border-radius: 14px;
    color: var(--text-dim); font-weight: 700; cursor: pointer;
    transition: 0.2s;
}

.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--primary-glow); color: var(--primary); }
.nav-link i { width: 20px; }

/* Sidebar Subcategories */
.sidebar-subcats {
    display: flex;
    flex-direction: column;
    gap: 0px;
    padding-left: 20px;
    margin-top: 2px;
    margin-bottom: 8px;
    animation: fadeIn 0.3s ease-out;
}

.nav-sub-link {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 14px; border-radius: 12px;
    color: var(--text-dim); font-size: 14px; font-weight: 600; cursor: pointer;
    transition: 0.2s;
}

.nav-sub-link:hover { background: var(--bg); color: var(--text); }
.nav-sub-link.active { background: var(--primary-glow); color: var(--primary); }
.nav-sub-link i { width: 16px; height: 16px; }

.sidebar-footer {
    display: flex; gap: 12px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border);
}

.icon-btn {
    background: var(--bg); border: 1px solid var(--border); color: var(--text);
    width: 44px; height: 44px; border-radius: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}

/* Content Area */
#contentArea {
    flex: 1; min-width: 0; padding: 60px 5vw;
}

.welcome-screen {
    height: 60vh; display: flex; align-items: center; justify-content: center; text-align: center;
}

.welcome-screen h2 { 
    font-size: clamp(32px, 8vw, 48px); 
    font-weight: 800; 
    margin-bottom: 16px; 
    line-height: 1.1;
    overflow-wrap: break-word;
    hyphens: auto;
}

.drill-down { animation: fadeIn 0.4s ease-out; }

.breadcrumbs {
    font-size: 11px; font-weight: 800; color: var(--primary); text-transform: uppercase;
    letter-spacing: 1px; margin-bottom: 24px;
    overflow-wrap: break-word;
}

.crumb { cursor: pointer; transition: 0.2s; }
.crumb:hover { text-decoration: underline; }

.node-content {
    margin-bottom: 40px; line-height: 1.6; 
    font-size: clamp(16px, 4vw, 18px); 
    color: var(--text-dim);
    overflow-wrap: break-word;
    hyphens: auto;
}

.children-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px;
}

.child-card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 0; cursor: pointer; transition: 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
    display: flex; flex-direction: column; height: 100%;
}

.child-card-content {
    padding: 24px; flex: 1;
}

.child-card-action {
    padding: 15px 24px;
    border-top: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    color: var(--primary); font-weight: 700; font-size: 14px;
    background: rgba(140, 198, 63, 0.05); /* very light primary */
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
    transition: 0.3s;
}

.child-card:hover .child-card-action {
    background: var(--primary);
    color: white;
}

.child-card:hover { transform: translateY(-5px); box-shadow: 0 12px 30px rgba(0,0,0,0.05); border-color: var(--primary); }

.child-card h3 { 
    font-size: clamp(18px, 4vw, 20px); 
    font-weight: 800; 
    margin-bottom: 12px; 
    overflow-wrap: break-word;
    hyphens: auto;
}

.content-card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 30px; box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}

.card-preview-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.card-preview-list li {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-preview-list li::before {
    content: '';
    width: 4px;
    height: 4px;
    background: var(--primary);
    border-radius: 50%;
}
.child-card p { font-size: 14px; color: var(--text-dim); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Admin View */
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 40px; }
.admin-actions { display: flex; gap: 12px; }

.btn-primary {
    background: var(--primary); color: #fff; border: none; padding: 12px 24px;
    border-radius: 12px; font-weight: 800; cursor: pointer;
}

.btn-secondary {
    background: var(--bg); border: 1px solid var(--border); color: var(--text);
    padding: 12px 24px; border-radius: 12px; font-weight: 700; cursor: pointer;
}

.admin-list { display: flex; flex-direction: column; gap: 12px; }
.admin-item {
    background: var(--card); border: 1px solid var(--border); padding: 16px 24px;
    border-radius: 16px; display: flex; justify-content: space-between; align-items: center;
}

/* Modals - Fix für Desktop-Sichtbarkeit */
.modal {
    position: fixed; 
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6); 
    backdrop-filter: blur(12px);
    display: flex; align-items: center; justify-content: center; 
    z-index: 9999; /* Sehr hoch für Priorität */
    padding: 20px;
    animation: modal-fade-in 0.3s ease;
}

.modal.hidden { display: none !important; }

.modal-content {
    background: var(--card); 
    width: 100%; 
    max-width: 650px; 
    border-radius: 32px;
    padding: 40px; 
    position: relative; 
    max-height: 95vh; 
    overflow-y: auto;
    box-shadow: 0 40px 100px rgba(0,0,0,0.3);
    /* Animation für flüssigen Wechsel */
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.modal-inner {
    animation: modalContentReveal 0.4s cubic-bezier(0.23, 1, 0.32, 1) both;
}

@keyframes modalContentReveal {
    from { opacity: 0; transform: translateY(15px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes modal-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.close-btn {
    position: absolute; 
    top: 20px; 
    right: 20px; 
    background: var(--bg); 
    border: none;
    padding: 10px; 
    border-radius: 100px; 
    cursor: pointer; 
    color: var(--text);
    z-index: 10;
}

/* Saubere Navigation unten in der Box (nur noch für Counter) */
.clean-modal-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.nav-counter {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-dim);
}

/* Neue linke und rechte Navigationspfeile */
.modal-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--primary);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 100;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.modal-nav-arrow:hover {
    background: var(--primary);
    color: #fff;
    transform: translateY(-50%) scale(1.1);
}

.modal-nav-arrow.left-arrow {
    left: calc(50% - 325px - 80px); /* 325px is half of 650px max-width, plus margin */
}

.modal-nav-arrow.right-arrow {
    right: calc(50% - 325px - 80px);
}

.modal-nav-arrow i {
    width: 28px;
    height: 28px;
}

.modal-nav-arrow.hidden {
    display: none !important;
}

@media (max-width: 900px) {
    .modal-nav-arrow {
        width: 44px;
        height: 44px;
    }
    .modal-nav-arrow i {
        width: 20px;
        height: 20px;
    }
    .modal-nav-arrow.left-arrow {
        left: 10px;
    }
    .modal-nav-arrow.right-arrow {
        right: 10px;
    }
    #detailModal .modal-content {
        padding: 30px 20px;
        width: calc(100% - 110px); /* 55px space on each side for the 44px arrows */
        max-width: none;
    }
}

.icon-library {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

.group-label {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
}

.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 10px;
}

.icon-pick {
    width: 44px;
    height: 44px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    color: var(--text);
}

.icon-pick:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    transform: scale(1.1);
}

.icon-pick i { width: 20px; }

.modal-title {
    font-size: clamp(24px, 6vw, 32px);
    font-weight: 800;
    margin-bottom: 16px;
    line-height: 1.1;
    overflow-wrap: break-word;
    hyphens: auto;
    color: var(--text);
}

.modal-text-content {
    padding: 0 10px;
}

/* Rich Text Content */
.rich-text { color: var(--text-dim); line-height: 1.6; }
.rich-text img { max-width: 100%; border-radius: 12px; }

/* Mobile Responsive */
@media (max-width: 900px) {
    #app { flex-direction: column; }
    #sidebar {
        width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border);
        padding: 24px; position: relative;
    }
    #categoryNav {
        flex-direction: row; overflow-x: auto; padding-bottom: 10px;
        scrollbar-width: none;
    }
    #categoryNav::-webkit-scrollbar { display: none; }
    .nav-link { white-space: nowrap; padding: 10px 16px; }
    .sidebar-subcats { display: none !important; }
    #contentArea { padding: 40px 24px; }
    .welcome-screen h2 { font-size: 32px; }
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.accent { color: var(--primary); }
.badge {
    background: var(--primary-glow); color: var(--primary); padding: 6px 12px;
    border-radius: 100px; font-size: 11px; font-weight: 800; text-transform: uppercase;
    display: inline-block;
}

.hidden { display: none !important; }

/* Form grid */
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 600px) { .grid-form { grid-template-columns: 1fr; } }

.input-group { margin-bottom: 20px; }
.input-group label { display: block; font-size: 11px; font-weight: 800; text-transform: uppercase; color: var(--text-dim); margin-bottom: 8px; }
.input-group input, .input-group select, .input-group textarea {
    width: 100%; padding: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
    color: var(--text); outline: none; font-size: 16px;
}
.input-group textarea { min-height: 150px; }

.actions { display: flex; gap: 12px; margin-top: 20px; }
.actions button { flex: 1; }

.modal-img { width: 100%; height: 250px; object-fit: cover; border-radius: 20px; margin-bottom: 24px; }

/* Trumbowyg Dark Fix */
body.dark-mode .trumbowyg-box, body.dark-mode .trumbowyg-editor {
    background-color: #1e293b !important;
    color: #fff !important;
    border-color: var(--border) !important;
}
body.dark-mode .trumbowyg-button-pane {
    background-color: #0f172a !important;
    border-bottom: 1px solid var(--border) !important;
}
