/* ─── Reset & Basis ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:           #111318;
    --bg-panel:     #1a1d27;
    --bg-input:     #12151f;
    --bg-card:      #1e2235;
    --border:       #2a2d3e;
    --accent:       #3db54a;      /* AERMAX Grün */
    --accent-dark:  #2d9438;
    --accent-light: rgba(61,181,74,0.10);
    --text:         #f0f2f5;
    --text-sub:     #9aa3b2;
    --text-muted:   #555f72;
    --user-bubble:  #1e3a28;
    --ai-bubble:    #1e2235;
    --topbar-h:     60px;
    --font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    --shadow-sm:    0 1px 4px rgba(0,0,0,0.25);
    --shadow-md:    0 4px 20px rgba(0,0,0,0.40);
}

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* ─── Login ──────────────────────────────────────────────────────────────── */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at 50% 0%, #1a2e1c 0%, var(--bg) 70%);
}

.login-box {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 10px;
    padding: 48px 44px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.login-logo { margin-bottom: 28px; }
.login-logo img { height: 42px; width: auto; }

.login-box h1 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.2px;
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-sub);
    font-size: 13px;
    margin-bottom: 32px;
}

.login-error {
    background: rgba(239,68,68,0.08);
    border: 1px solid rgba(239,68,68,0.25);
    color: #f87171;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 20px;
    text-align: left;
}

.form-group { margin-bottom: 16px; text-align: left; }

.form-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(61,181,74,0.12);
}

.btn-login {
    width: 100%;
    margin-top: 8px;
    padding: 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-login:hover { background: var(--accent-dark); }

.login-footer {
    margin-top: 28px;
    font-size: 11px;
    color: var(--text-muted);
}

/* ─── App-Layout ─────────────────────────────────────────────────────────── */
.app-body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Topbar */
.topbar {
    height: var(--topbar-h);
    min-height: var(--topbar-h);
    background: #0d0f14;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 10;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-logo img { height: 30px; width: auto; }

.topbar-separator {
    width: 1px;
    height: 22px;
    background: var(--border);
}

.topbar-title {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}
.topbar-title strong {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.3px;
}
.topbar-title span { font-size: 11px; color: var(--text-muted); }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.topbar-user {
    font-size: 12px;
    color: var(--text-sub);
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 12px;
}

.filebrowser-dropdown { position: relative; }

.filebrowser-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 7px;
    box-shadow: var(--shadow-md);
    min-width: 200px;
    z-index: 100;
    overflow: hidden;
}
.filebrowser-menu.open { display: block; }

.filebrowser-menu a {
    display: block;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text);
    text-decoration: none;
    transition: background 0.15s;
}
.filebrowser-menu a:hover { background: var(--accent-light); color: var(--accent); }

.btn-filebrowser {
    font-size: 12px;
    padding: 6px 14px;
    background: var(--accent-light);
    border: 1px solid rgba(61,181,74,0.3);
    border-radius: 5px;
    color: var(--accent);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-filebrowser:hover { background: rgba(61,181,74,0.18); border-color: var(--accent); }

.btn-logout {
    font-size: 12px;
    padding: 6px 14px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text-sub);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.15s;
}
.btn-logout:hover { border-color: var(--accent); color: var(--accent); }

/* Splitscreen */
.splitscreen { display: flex; flex: 1; overflow: hidden; }

.panel { display: flex; flex-direction: column; overflow: hidden; }

.panel-chat   {
    flex: 0 0 42%;
    min-width: 280px;
    border-right: 1px solid var(--border);
    border-top: 3px solid var(--accent);
}
.panel-viewer { flex: 1; position: relative; }

.panel-header {
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text-muted);
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Divider */
.divider {
    width: 4px;
    background: var(--border);
    cursor: col-resize;
    flex-shrink: 0;
    transition: background 0.2s;
}
.divider:hover { background: var(--accent); }

/* ─── Chat ───────────────────────────────────────────────────────────────── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
    background: var(--bg);
}

.chat-message { display: flex; }
.chat-message.user      { justify-content: flex-end; }
.chat-message.assistant { justify-content: flex-start; }

.message-bubble {
    max-width: 84%;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13.5px;
    line-height: 1.65;
    word-break: break-word;
}

.chat-message.user .message-bubble {
    background: var(--user-bubble);
    color: #c8f0cc;
    border: 1px solid rgba(61,181,74,0.25);
    border-bottom-right-radius: 3px;
}

.chat-message.assistant .message-bubble {
    background: var(--ai-bubble);
    color: var(--text);
    border-bottom-left-radius: 3px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.message-bubble strong { color: var(--accent); }
.message-bubble em     { color: var(--text-sub); }
.message-bubble code {
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 3px;
    padding: 1px 5px;
    font-family: monospace;
    font-size: 12px;
}

/* Quellenlinks */
.source-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
    margin-right: 4px;
    padding: 5px 11px;
    background: var(--accent-light);
    border: 1px solid rgba(61,181,74,0.25);
    border-radius: 5px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
}
.source-link:hover {
    background: rgba(61,181,74,0.18);
    border-color: var(--accent);
}

/* Loading-Dots */
.dots span { animation: blink 1.2s infinite; display: inline-block; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
    0%, 80%, 100% { opacity: 0.1; }
    40%            { opacity: 1; }
}

/* Chat Input */
.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
    background: var(--bg-panel);
    flex-shrink: 0;
}

.chat-input-area textarea {
    flex: 1;
    padding: 9px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text);
    font-size: 13.5px;
    font-family: var(--font);
    resize: none;
    outline: none;
    line-height: 1.5;
    transition: border-color 0.2s;
}
.chat-input-area textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(61,181,74,0.10);
}
.chat-input-area textarea::placeholder { color: var(--text-muted); }

.chat-input-area button {
    padding: 9px 18px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    align-self: flex-end;
    transition: background 0.2s;
    white-space: nowrap;
}
.chat-input-area button:hover    { background: var(--accent-dark); }
.chat-input-area button:disabled { background: var(--text-muted); cursor: default; }

/* ─── Datei-Viewer ───────────────────────────────────────────────────────── */
.viewer-path {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60%;
}

.file-iframe {
    display: none;
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
    flex: 1;
}

.viewer-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    background: var(--bg);
}
.viewer-placeholder .placeholder-icon { font-size: 52px; opacity: 0.15; }
.viewer-placeholder p { opacity: 0.5; line-height: 1.7; max-width: 260px; }

/* ─── Download-Panel (für Office-Dateien) ────────────────────────────────── */
.viewer-download {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 14px;
    background: var(--bg);
    padding: 48px 40px;
    text-align: center;
}

.download-icon {
    font-size: 72px;
    line-height: 1;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
}

.download-ext-badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--accent);
    background: var(--accent-light);
    border: 1px solid rgba(61,181,74,0.30);
    border-radius: 4px;
    padding: 3px 10px;
}

.download-filename {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    word-break: break-all;
    max-width: 80%;
    line-height: 1.4;
}

.download-note {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.6;
    max-width: 300px;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    padding: 11px 28px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    letter-spacing: 0.2px;
}
.btn-download:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
}
.btn-download:active { transform: translateY(0); }

/* Scrollbar */
::-webkit-scrollbar       { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
