/* Corporate Design: CHANCEN-Verbund */
:root {
    --cv-gruen: #356D39;
    --cv-gruen-light: #4a8a4f;
    --cv-gruen-dark: #2a5730;
    --scp-gelb: #E1E100;
    --scp-gruen: #64D4C6;
    --scp-blau: #1E8BDA;
    --scp-dunkelblau: #003C93;
    --topbar-height: 25px;
    --bottombar-height: 15px;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
}

/* App shell: sidebar + main content side by side */
.app-shell {
    display: flex;
    height: calc(100vh - var(--topbar-height) - var(--bottombar-height));
}

.app-main {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
}

/* Side navigation */
.side-nav {
    width: 56px;
    min-width: 56px;
    max-width: 56px;
    background-color: var(--cv-gruen);
    transition: width 0.2s ease, min-width 0.2s ease, max-width 0.2s ease;
    overflow: hidden;
    flex-shrink: 0;
}

.side-nav--open {
    width: 220px;
    min-width: 220px;
    max-width: 220px;
}

/* Drawer layout: top nav + bottom user */
.side-nav .drawer-content {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--topbar-height) - var(--bottombar-height));
    overflow: hidden;
    width: 220px;
}

.side-nav .drawer-top {
    flex: 1;
    overflow: hidden;
}

.side-nav .drawer-bottom {
    flex-shrink: 0;
}

/* White text for nav links on green sidebar */
.side-nav .mud-nav-link {
    color: white !important;
    white-space: nowrap;
    overflow: hidden;
}

/* Hide link text when sidebar is collapsed */
.side-nav:not(.side-nav--open) .mud-nav-link-text {
    display: none;
}

.side-nav .mud-nav-link .mud-nav-link-icon {
    color: rgba(255, 255, 255, 0.85) !important;
}

.side-nav .mud-nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

.side-nav .mud-nav-link.active {
    background-color: rgba(255, 255, 255, 0.2) !important;
}

.side-nav .mud-nav-link.mud-nav-link-disabled {
    opacity: 0.4;
}

/* Login page */
.login-page {
    min-height: calc(100vh - var(--topbar-height) - var(--bottombar-height));
    background: linear-gradient(135deg, #356D39 0%, #2a5730 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-header {
    color: white;
    font-size: 1.3rem;
    font-weight: 700;
    padding: 2rem 0;
    text-align: center;
    font-family: 'Calibri', 'Roboto', 'Segoe UI', sans-serif;
}

.login-body {
    width: 100%;
    max-width: 400px;
    padding: 0 1rem;
}

.login-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.login-card-header {
    background-color: var(--cv-gruen);
    color: white;
    padding: 1.25rem;
    text-align: center;
}

.login-card-header h4 {
    margin: 0;
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
}

.login-card-body {
    padding: 1.5rem;
}

.login-field {
    margin-bottom: 1rem;
}

.login-field label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
    color: #555;
}

.login-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.login-input:focus {
    outline: none;
    border-color: var(--cv-gruen);
    box-shadow: 0 0 0 3px rgba(53, 109, 57, 0.15);
}

.login-button {
    width: 100%;
    padding: 0.7rem;
    background-color: var(--cv-gruen);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 0.5rem;
}

.login-button:hover {
    background-color: var(--cv-gruen-light);
}

.login-error {
    background-color: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Editor layout */
.editor-layout {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--topbar-height) - var(--bottombar-height));
}

.editor-split {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.editor-split .editor-panel {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

.editor-split .preview-panel-outer {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

.preview-frame {
    border: 2px solid var(--cv-gruen);
    border-radius: 12px;
    background-color: #fafafa;
    padding: 1rem 1.5rem;
}

.editor-footer {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid #e0e0e0;
}

/* Template editor split layout */
.template-editor-split {
    display: flex;
    gap: 1rem;
    height: calc(100vh - var(--topbar-height) - var(--bottombar-height) - 160px);
}

.template-editor-left {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.template-editor-right {
    flex: 1;
    overflow-y: auto;
    background-color: #fafafa;
    border-left: 1px solid #e0e0e0;
    padding: 1rem;
    border-radius: 4px;
}

/* Template syntax highlighting overlay */
.template-editor-wrapper {
    position: relative;
    margin-bottom: 8px;
    border-radius: 4px;
}

.template-editor-wrapper .template-highlight-layer,
.template-editor-wrapper .template-editor-textarea {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    padding: 12px 14px;
    margin: 0;
    border: 1px solid #bbb;
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
    tab-size: 4;
    letter-spacing: normal;
}

.template-editor-wrapper .template-highlight-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
    overflow: auto;
    background: #fff;
    border-color: transparent;
}

.template-editor-wrapper .template-editor-textarea {
    position: relative;
    z-index: 2;
    background: transparent;
    color: transparent;
    caret-color: #000;
    resize: vertical;
    outline: none;
}

.template-editor-wrapper .template-editor-textarea:focus {
    border-color: var(--mud-palette-primary, #1976d2);
}

.template-editor-wrapper .template-editor-textarea::selection {
    background: rgba(25, 118, 210, 0.3);
}

.template-preview-content h1,
.template-preview-content h2,
.template-preview-content h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.template-preview-content img {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: 4px;
}

.template-preview-content ul,
.template-preview-content ol {
    padding-left: 2rem;
    list-style: revert;
}

/* Radzen HtmlEditor: fix list rendering inside MudBlazor */
.rz-html-editor-content ul,
.rz-html-editor-content ol {
    padding-left: 2rem;
    list-style: revert;
}

/* Markdown field preview */
.markdown-field-preview {
    font-size: 0.9rem;
    border-left: 3px solid #64D3C6;
    background: #fafafa;
}
.markdown-field-preview h1,
.markdown-field-preview h2,
.markdown-field-preview h3 {
    margin-top: 0.5rem;
    margin-bottom: 0.3rem;
}
.markdown-field-preview ul,
.markdown-field-preview ol {
    padding-left: 2rem;
    list-style: revert;
}
.markdown-field-preview p {
    margin-bottom: 0.5rem;
}

/* Help drawer (right side) */
.help-drawer {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    background-color: #E1E100;
    transition: width 0.2s ease, min-width 0.2s ease, max-width 0.2s ease;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.help-drawer--open {
    width: 380px;
    min-width: 380px;
    max-width: 380px;
    background-color: white;
    border-left: 2px solid #E1E100;
}

.help-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background-color: #E1E100;
    flex-shrink: 0;
}

.help-toggle:hover {
    background-color: #c8c800;
}

.help-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 1rem 1rem;
}

.help-body h1 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0.5rem 0 0.75rem;
    color: #356D39;
}

.help-body h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 1rem 0 0.5rem;
    color: #333;
}

.help-body p, .help-body li {
    font-size: 0.85rem;
    line-height: 1.5;
}

.help-body ul {
    padding-left: 1.5rem;
    list-style: disc;
}

.help-body code {
    background-color: #f0f0f0;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.8rem;
}

/* Snackbar corporate colors */
.mud-snackbar.mud-alert-filled-success {
    background-color: #64D3C6 !important;
    color: #000 !important;
}

.mud-snackbar.mud-alert-filled-info {
    background-color: #1E8BDA !important;
    color: #fff !important;
}

.mud-snackbar.mud-alert-filled-warning {
    background-color: #E1E100 !important;
    color: #000 !important;
}

.mud-snackbar.mud-alert-filled-error {
    background-color: #003C93 !important;
    color: #fff !important;
}

/* Blazor error UI */
#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}
