@font-face {
    font-family: 'Fira Code';
    src: url('lib/fonts/firacode.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg-primary: #1e1e1e;
    --bg-secondary: #252526;
    --text-primary: #cccccc;
    --text-secondary: #999999;
    --accent-color: #007acc;
    --win-border: #333333;
    --toolbar-bg: #2d2d2d;
    --hover-bg: #3c3c3c;
    --status-bg: #252526;
    --font-ui: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f3f3f3;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --accent-color: #0078d4;
    --win-border: #d0d0d0;
    --toolbar-bg: #ffffff;
    --hover-bg: #e5e5e5;
    --status-bg: #e1e1e1;
}

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

body {
    font-family: var(--font-ui);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Windows Header */
.window-header {
    height: 32px;
    background-color: var(--bg-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px;
    border-bottom: 1px solid var(--win-border);
    -webkit-app-region: drag; /* Ermöglicht das Verschieben des Fensters */
}

.window-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    pointer-events: none; /* Verhindert, dass Text ausgewählt wird beim Ziehen */
}

.window-controls {
    display: flex;
    height: 100%;
    -webkit-app-region: no-drag; /* Buttons müssen klickbar bleiben */
}

.win-btn {
    width: 46px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: none;
    background: transparent;
}

.win-btn:hover { background-color: var(--win-hover); }

.win-btn.close:hover {
    background-color: #e81123;
    color: white;
}

/* Icons für die Buttons */
.win-btn span {
    display: block;
    border-style: solid;
    border-color: currentColor;
    border-width: 0;
}

.minify span {
    width: 10px;
    border-bottom-width: 1px;
}

.expand span {
    width: 10px;
    height: 10px;
    border-width: 1px;
}

.close span {
    position: relative;
    width: 10px;
    height: 10px;
}

.close span::before, .close span::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: currentColor;
}

.close span::before { transform: rotate(45deg); }
.close span::after { transform: rotate(-45deg); }

/* Menu Bar */
.menu-bar {
    display: flex;
    background-color: var(--bg-secondary);
    padding: 2px 8px;
    border-bottom: 1px solid var(--win-border);
    -webkit-app-region: no-drag; /* Menü muss klickbar bleiben */
}

.menu-item {
    position: relative;
    padding: 4px 8px;
    font-size: 12px;
    cursor: default;
    border-radius: 4px;
}

.menu-item:hover { background-color: var(--win-hover); }

/* Dropdown */
.dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--bg-secondary);
    border: 1px solid var(--win-border);
    box-shadow: 0 8px 16px rgba(0,0,0,0.3);
    z-index: 5000; /* Viel höher als der Editor */
    min-width: 180px;
    padding: 4px 0;
}

.menu-item.active > .dropdown {
    display: block;
}

/* Submenu / Side Dropdown */
.submenu .dropdown.side {
    left: 100%;
    top: 0;
    display: none;
}

.submenu:hover > .dropdown.side {
    display: block;
}

.dropdown div {
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
}

.dropdown div:hover {
    background-color: var(--accent-color);
    color: white;
}

.dropdown .divider {
    height: 1px;
    background-color: var(--win-border);
    margin: 4px 0;
    padding: 0;
}

.dropdown .divider:hover { background-color: var(--win-border); }

/* Editor Area */
.editor-container {
    flex: 1;
    background-color: var(--bg-primary);
    overflow: hidden;
}

/* ToastUI Custom Styling */
.toastui-editor-defaultUI {
    border: none !important;
}

/* --- FINALE THEME-ABHERTUNG --- */

/* 1. Generelle Textfarben (WYSIWYG & Vorschau) */
.toastui-editor-contents,
.toastui-editor-contents *,
.toastui-editor-ww-container *,
.toastui-editor-md-container * {
    color: var(--text-primary);
}

/* 2. Zwinge Paragraphs und Headlines zur Theme-Farbe */
.toastui-editor-contents p,
.toastui-editor-contents h1,
.toastui-editor-contents h2,
.toastui-editor-contents h3,
.toastui-editor-contents li,
.toastui-editor-ww-container [contenteditable] {
    color: var(--text-primary) !important;
}

/* 3. Code-Blöcke & Inline-Code (In beiden Themes dunkel mit heller Schrift) */
.toastui-editor-contents code,
.toastui-editor-contents pre,
.toastui-editor-ww-code-block,
.toastui-editor-ww-code-block *,
.toastui-editor-ww-container code,
.toastui-editor-md-container .cm-keyword,
.toastui-editor-md-container .cm-variable {
    color: #e0e0e0 !important;
    background-color: #262626 !important;
}

/* 4. Spezifisch für Inline-Code im Text */
code {
    padding: 2px 4px !important;
    border-radius: 3px !important;
}


.toastui-editor-contents {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
    font-size: 16px !important;
}

.toastui-editor-ww-container {
    background-color: transparent !important;
}

/* Toolbar Theme Fix & Premium Look */
.toastui-editor-defaultUI-toolbar {
    background-color: var(--win-header-bg) !important;
    border-bottom: 1px solid var(--win-border) !important;
    padding: 4px !important;
    height: auto !important;
}

.toastui-editor-defaultUI-toolbar button {
    border: none !important; /* Weg mit den hässlichen Kästen */
    background-color: transparent !important;
    border-radius: 4px !important;
    margin: 2px !important;
    transition: background-color 0.2s !important;
}

.toastui-editor-defaultUI-toolbar button:hover {
    background-color: var(--win-hover) !important;
}

/* Icons im Dark Mode hell machen, im Light Mode dunkel */
[data-theme="dark"] .toastui-editor-defaultUI-toolbar button {
    filter: brightness(0) invert(1) !important;
}

[data-theme="light"] .toastui-editor-defaultUI-toolbar button {
    filter: none !important;
}

/* Trennlinien in der Toolbar */
.toastui-editor-toolbar-divider {
    background-color: var(--win-border) !important;
    margin: 5px 4px !important;
}


/* Status Bar */
.status-bar {
    height: 24px;
    background-color: var(--status-bg);
    border-top: 1px solid var(--win-border);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0 12px;
    font-size: 11px;
    gap: 16px;
}

.status-item {
    padding-left: 12px;
    border-left: 1px solid var(--win-border);
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out, visibility 0.5s;
}

#loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
    color: var(--text-primary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent-color);
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Modal Styling */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: #f3f3f3; /* Helles Grau für Light Mode */
    margin: 12% auto;
    padding: 30px;
    border: 1px solid #ccc;
    width: 500px;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: slideIn 0.3s ease-out;
}

[data-theme="dark"] .modal-content {
    background-color: #2d2d2d; /* Dunkles Grau für Dark Mode */
    border-color: #444;
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.about-container {
    display: flex;
    align-items: center;
    gap: 30px;
}

.about-logo {
    width: 128px;
    height: 128px;
    object-fit: contain;
}

.about-text {
    flex: 1;
    color: var(--text-color);
}

.about-text h2 {
    margin-top: 0;
    color: var(--win-accent);
}

.btn-primary {
    background-color: var(--win-accent);
    color: white;
    border: none;
    padding: 8px 25px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 20px;
    font-size: 14px;
    transition: filter 0.2s;
}

.btn-primary:hover {
    filter: brightness(1.2);
}
/* Web / Electron Visibility */
.electron-only { display: none; }
body.is-electron .electron-only { display: flex; }

.web-only { display: block; }
body.is-electron .web-only { display: none; }

@media (max-width: 600px) {
    .window-header { display: none; }
    .menu-bar { flex-wrap: wrap; }
}
