/* --------------------------------------------------
   Modernes UI-Design mit CSS-Variablen (Light/Dark)
   Gilt für: index.php, create.php, login.php, register.php, edit.php
   -------------------------------------------------- */

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Farb- und Design-Variablen */
:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f2f4f8;
    --text: #0f172a; /* slate-900 */
    --muted: #64748b; /* slate-500 */
    --border: #e5e7eb; /* gray-200 */
    --ring: rgba(99, 102, 241, 0.25); /* indigo ring */
    --link: #4A60E0;
    --primary: #4A60E0;
    --primary-hover: #314094;
}

body.dark-mode {
    --bg: #31363F; /* slate-900 */
    --surface: #222831; /* deep panel */
    --surface-2: #191d24;
    --text: #e5e7eb; /* gray-200 */
    --muted: #9ca3af; /* gray-400 */
    --border: #43556d; /* gray-800 */
    --ring: rgba(99, 102, 241, 0.35);
    --link: #8896e2;
    --primary: #3747A6;
    --primary-hover: #5864a6;
}

/* Basis-Layout */
html,
body {
    width: 100%;
    /* Body wird über Flex min-height:100vh gestreckt */
    font-family: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.55;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Sticky-Footer-Layout: Body als Spalten-Flex-Container */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh; /* füllt den Viewport */
}

img,
svg {
    display: block;
    max-width: 100%;
}

a {
    color: var(--link);
    text-decoration: none;
    transition: color 0.2s ease;
}
a:hover {
    color: var(--primary-hover);
}

.center-aligned {
    text-align: center;
}

/* Header / Navigation (nur oben auf der Seite, nicht Inhalts-Header) */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--surface);
    backdrop-filter: saturate(160%) blur(8px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
}
.site-header h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.2px;
}
.site-header nav ul {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
}
.site-header nav { margin-right: auto; }
.site-header nav a {
    color: var(--text);
    padding: 8px 10px;
    border-radius: 8px;
}
.site-header nav a:hover {
    background: var(--surface-2);
}

/* Seiteninhalt */
main {
    width: 1100px; /* feste Seitenbreite */
    margin: 24px auto;
    padding: 0 20px;
    flex: 1 0 auto; /* füllt restliche Höhe, Footer bleibt unten */
}

/* Dashboard-Layout (Projekte links, Inhalte rechts) */
.dashboard {
    display: grid;
    grid-template-columns: 340px 696px; /* feste Breiten: 340 + 24 (gap) + 696 = 1060 (Inhaltsbreite) */
    gap: 24px;
    align-items: start; /* Inhalte oben ausrichten, nicht auf Zeilenhöhe strecken */
}
body.projects-collapsed .dashboard {
    grid-template-columns: 1036px; /* 1060 - 24 gap */
}

.project-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    position: sticky;
    align-self: start;
    top: 84px; /* unter dem .site-header */
}
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.panel-head h2 { font-size: 18px; }

.project-create {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin-bottom: 14px;
}
.project-create input[type="text"] {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}

.project-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 6px;
}
.project-item { /* Container für Projektzeilen */ }
.project-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.project-link {
    display: block;
    padding: 6px 8px;
    border-radius: 8px;
}
.project-item.active .project-link {
    background: var(--surface-2);
}
.project-action { /* Icon-Button rechts */
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.project-rename { display: none; margin-top: 8px; }
.project-rename.visible { display: block; }
.project-rename input[type="text"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}
.rename-actions { display: flex; gap: 8px; margin-top: 8px; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.mindmap-content { display: grid; gap: 16px; align-content: start; }
.mindmap-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.muted { color: var(--muted); }
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 12px;
    color: var(--muted);
}
.empty-state {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

/* Create: Zweispaltiges Grid */
.create-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}
@media (min-width: 800px) {
    .create-grid { grid-template-columns: 1fr 1fr; }
}
.create-card {
    background: var(--surface);
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}
.create-card h2 {
    margin-bottom: 16px;
}

/* Dropzone */
.dropzone {
    display: grid;
    place-items: center;
    gap: 6px;
    width: 100%;
    min-height: 140px;
    padding: 16px;
    text-align: center;
    color: var(--muted);
    background: var(--surface-2);
    border: 2px dashed var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.dropzone strong { color: var(--text); }
.dropzone.dragover {
    background: rgba(99, 102, 241, 0.08);
    border-color: var(--primary);
    color: var(--text);
}
.dz-file { font-size: 13px; color: var(--muted); }

/* Buttons */
.btn,
.btn-view,
button.btn,
a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    background: var(--primary)!important;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.06s ease;
    text-decoration: none;
}
.btn:hover,
.btn-view:hover,
button.btn:hover,
a.btn:hover {
    color: #ffffff;
    background: var(--primary-hover)!important;
}
.btn:active,
.btn-view:active {
    transform: translateY(1px) scale(0.99);
}

/* Mindmaps: kompakte Listenansicht (tabellenähnlich) */
.mindmap-list {
    display: block; /* Liste mit festen Zeilenbreiten */
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.mindmap-item {
    display: grid;
    grid-template-columns: 280px 220px 140px; /* feste Spaltenbreiten (Titel, Zeit, Aktion) */
    align-items: center;
    column-gap: 16px;
    padding: 0 12px;
    height: 36px; /* feste Zeilenhöhe */
    background: transparent;
    border: none;
    border-top: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
}
.mindmap-item:first-child {
    border-top: none;
}
.mindmap-item:hover {
    background: var(--surface-2);
}
.mindmap-item-head {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0; /* für ellipsis */
}
.mindmap-item h2 {
    font-size: 13px;
    line-height: 1; /* feste Zeilenhöhe im Text selbst */
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mindmap-item p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1; /* straff */
    white-space: nowrap; /* verhindert Zeilenumbruch -> hält die Zeile flach */
}
.mindmap-item .btn-view {
    height: 28px;       /* feste Buttonhöhe innerhalb der Zeile */
    padding: 0 10px;    /* nur horizontaler Abstand */
    font-size: 12px;
    line-height: 28px;  /* Text vertikal mittig, falls notwendig */
    border-radius: 8px;
    box-shadow: none;
}
@media (max-width: 640px) {
    .mindmap-item { grid-template-columns: 1fr auto; }
    .mindmap-item p { display: none; }
}

/* Formulare */
.form-container {
    background: var(--surface);
    padding: 28px;
    max-width: 420px;
    margin: 40px auto;
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}
.form-container h2 {
    text-align: center;
    margin-bottom: 18px;
}
.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-hover);
    box-shadow: 0 0 0 4px var(--ring);
}
.is-invalid {
    border-color: #ef4444;
}
.invalid-feedback {
    color: #ef4444;
    font-size: 13px;
    margin-top: 6px;
}
.alert {
    padding: 10px 12px;
    background: #ef4444;
    color: #fff;
    border-radius: 10px;
    margin-bottom: 14px;
    text-align: center;
}
.alert-success {
    background: #10b981;
}

/* Footer */
footer {
    max-width: 1100px;
    margin: 40px auto 0 auto;
    padding: 24px 20px 0 20px;
    color: var(--muted);
    text-align: center;
    border-top: 1px solid var(--border);
}

/* Mindmap Editor: Floating Header + Toolbar */
#floating_header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: var(--surface);
    color: var(--text);
    display: flex;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    z-index: 10;
}
#floating_header h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}
#floating_header nav { margin-left: auto; display:flex; align-items:center; gap:10px; }
#floating_header nav ul {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 0;
}

#floating_header .mindmap-name-display {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 16px;
}

#mindmap_name_input {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    min-width: 220px;
}

#mindmap_name_input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--ring);
}

body.dark-mode #mindmap_name_input {
    background: var(--surface-2);
}

#floating_toolbar {
    position: fixed;
    top: 60px;
    left: 0;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px;
    z-index: 10;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.tool-btn {
    width: 40px;
    height: 40px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.06s ease;
    position: relative;
    color: var(--text);
}
.tool-btn i {
    color: currentColor;
}
.tool-btn:hover {
    background: var(--primary);
    border-color: transparent;
    color: #ffffff;
}
.btn-save {
    background: var(--primary);
    border-color: transparent;
    color: #ffffff;
}
.btn-save:hover {
    background: var(--primary-hover);
}
/* Tooltip */
.tool-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.tool-btn:hover::after {
    opacity: 1;
}

/* Spezifischer Look für den Collapse-Button im Projekt-Panel,
   damit er nicht wie ein schwebender Toolbar-Button wirkt */
.project-panel .project-collapse {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: transparent;
    border: none;
    box-shadow: none;
    color: var(--muted);
}
.project-panel .project-collapse:hover {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
}
.project-panel .project-collapse::after { display: none; }

/* Mindmap-Container (Standard-Ansicht unter einer 60px-Leiste) */
#jsmind_container {
    position: absolute;
    top: 60px;
    left: 0;
    width: 100vw;
    height: calc(100vh - 60px);
    overflow: hidden !important;
    background: var(--bg);
    z-index: 1;
    cursor: grab;
}
#jsmind_container.dragging { cursor: grabbing; }
#jsmind_inner {
    width: 100%;
    height: 100%;
    transform-origin: 50% 50%;
    overflow: hidden !important; /* als Viewport, Pan/Zoom via Transform */
    position: relative; /* Bezugspunkt für Inhalte */
    user-select: none; /* verhindert Textmarkierung beim Panning */
    touch-action: none; /* verhindert natives Scroll/Pan auf Touch/Wheel */
}
#jsmind_inner::-webkit-scrollbar { display: none; } /* WebKit - Scrollbar ausblenden */

/* ===== Mobile Optimierungen ===== */
@media (max-width: 768px) {
    #floating_header {
        height: 56px;
        padding: 8px 12px;
    }

    #floating_toolbar {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        height: 64px;
        padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
        justify-content: center;
        gap: 8px;
    }

    .tool-btn {
        width: 48px;
        height: 48px;
        border-radius: 12px;
    }

    /* Tooltips auf Touch-Geräten ausblenden */
    .tool-btn::after { display: none; }

    /* Platz für Header und untere Toolbar einplanen */
    #jsmind_container {
        top: 56px;
        height: calc(100vh - 56px - 64px);
    }
}

/* Nur auf Geräten mit Maus Hover-Tooltips anzeigen */
@media (hover: none) and (pointer: coarse) {
    .tool-btn::after { display: none; }
}

/* Modal (einfache, unaufdringliche Basis) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-card {
    width: 420px;
    max-width: calc(100vw - 40px);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.modal-card h3 { font-size: 18px; margin-bottom: 8px; }
.modal-card p { font-size: 14px; color: var(--muted); }
.modal-actions { display:flex; gap:8px; justify-content: flex-end; margin-top: 14px; }
.modal-danger { background: #ef4444!important; }
