/* Copyright (c) 2026 Simon Eder (RecuvaPumDEV) | https://recuvapumdev.eu */
:root {
    --glass: rgba(10, 11, 14, 0.97);
    --sidebar-bg: rgba(0, 0, 0, 0.38);
    --border: rgba(255, 255, 255, 0.08);
    --accent: #2f8fff;
    --accent-deep: #0b5fd4;
    --text: #f3f6fb;
    --text-dim: rgba(232, 238, 247, 0.58);
    --rail: rgba(47, 143, 255, 0.85);
    --user-ink: linear-gradient(160deg, rgba(47, 143, 255, 0.92), rgba(11, 95, 212, 0.88));
    --code-bg: #0a0c11;
    --thread: 760px;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
}

body {
    background: #0a0c11;
    color: var(--text);
    font-family: 'Segoe UI Variable Display', 'Segoe UI', system-ui, sans-serif;
    font-size: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: rgba(14, 16, 20, 0.98);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 1000;
}

.brand-name {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--accent);
    text-transform: uppercase;
}

.logout-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    transition: 0.2s;
}

.logout-btn:hover {
    background: rgba(232, 17, 35, 0.15);
    border-color: rgba(232, 17, 35, 0.4);
    color: #fff;
}

#loginScreen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 999;
    background: #0a0c11;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.brand-title { color: var(--accent); font-size: 48px; margin-bottom: 5px; letter-spacing: 2px; }
.brand-sub { color: var(--text-dim); margin-bottom: 40px; letter-spacing: 1px; }

.login-btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    color: white;
    border: none;
    padding: 16px 50px;
    border-radius: 14px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(47, 143, 255, 0.3);
    transition: 0.3s;
}

.login-btn:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}

.app-container {
    display: none;
    flex: 1;
    flex-direction: row;
    min-height: 0;
    background: var(--glass);
    border-top: none;
    overflow: hidden;
}

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 18px 16px;
    min-height: 0;
}

.sidebar h2 {
    font-weight: 600;
    font-size: 22px;
    margin: 0 0 16px 0;
    text-align: center;
    color: var(--accent);
    letter-spacing: 1px;
}

.new-chat-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: white;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    width: 100%;
    margin-bottom: 16px;
    transition: 0.2s;
    flex-shrink: 0;
}

.new-chat-btn:hover { background: var(--accent); }

.history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    padding-right: 4px;
    min-height: 0;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 10px; }
.history-list:hover::-webkit-scrollbar-thumb,
.chat-area:hover::-webkit-scrollbar-thumb { background: var(--accent); }

.user-profile {
    flex-shrink: 0;
    margin-top: auto;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--border);
}

.user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-avatar { width: 35px; height: 35px; border-radius: 50%; background: var(--accent); object-fit: cover; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.user-status { font-size: 10px; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; }

.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-width: 0;
    min-height: 0;
}

.chat-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 22px 0 8px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.msg {
    width: min(var(--thread), calc(100% - 40px));
    margin: 0 auto;
    font-size: 16px;
    line-height: 1.7;
    animation: riseIn 0.28s ease;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-width: 0;
}

@keyframes riseIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.msg.user {
    display: flex;
    justify-content: flex-end;
}

.msg.user .msg-body {
    max-width: min(640px, 100%);
    background: var(--user-ink);
    color: #fff;
    padding: 12px 16px;
    border-radius: 18px 18px 6px 18px;
    box-shadow: 0 10px 28px rgba(11, 95, 212, 0.22);
}

.msg.ai {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    column-gap: 14px;
    align-items: stretch;
}

.msg-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100%;
}

.msg-mark {
    width: 20px;
    height: 20px;
    border-radius: 7px;
    background: linear-gradient(180deg, var(--accent), var(--accent-deep));
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 16px rgba(47, 143, 255, 0.45);
    flex-shrink: 0;
}

.msg-rail::after {
    content: '';
    width: 2px;
    flex: 1;
    margin-top: 8px;
    border-radius: 99px;
    background: linear-gradient(180deg, var(--rail), transparent);
    min-height: 18px;
}

.msg.ai .msg-body {
    min-width: 0;
    padding: 1px 0 0;
    color: var(--text);
}

.img-msg {
    background: transparent !important;
    box-shadow: none;
    padding: 0;
    display: flex;
    justify-content: flex-end;
}

.img-msg .msg-body,
.img-msg.user .msg-body {
    background: transparent;
    box-shadow: none;
    padding: 0;
    max-width: min(420px, 100%);
}

.composer {
    position: relative;
    flex-shrink: 0;
    padding: 12px 20px 20px;
    border-top: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(10, 11, 14, 0.15), rgba(10, 11, 14, 0.55));
}

.input-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    width: min(var(--thread), 100%);
    margin: 0 auto;
    gap: 8px;
}

.input-box {
    flex: 1 1 auto;
    min-width: 0;
    background: rgba(22, 25, 32, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 13px 16px;
    border-radius: 16px;
    color: white;
    outline: none;
    font-size: 15.5px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.38), inset 0 0 0 1px rgba(47, 143, 255, 0.06);
    resize: none;
    min-height: 50px;
    max-height: 180px;
    font-family: inherit;
    line-height: 1.45;
    overflow-y: auto;
}

.input-box:focus {
    border-color: rgba(47, 143, 255, 0.55);
}

.plus-btn,
.mic-btn,
.send-btn {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    cursor: pointer;
    flex-shrink: 0;
    border: none;
    color: white;
    transition: 0.2s;
}

.plus-btn {
    background: var(--accent);
    font-size: 24px;
}

.plus-btn:hover { transform: rotate(90deg); filter: brightness(1.15); }

.mic-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    font-size: 18px;
}

.mic-btn:hover { background: rgba(255, 255, 255, 0.1); }

.mic-btn.listening {
    background: #e81123;
    animation: pulse-mic 1.5s infinite;
    border-color: #e81123;
}

.send-btn {
    background: linear-gradient(180deg, var(--accent), var(--accent-deep));
    font-size: 20px;
    font-weight: 700;
}

.send-btn:hover { filter: brightness(1.12); }
.send-btn:disabled {
    opacity: 0.35;
    cursor: default;
    filter: none;
}

@keyframes pulse-mic {
    0% { box-shadow: 0 0 0 0 rgba(232, 17, 35, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(232, 17, 35, 0); }
    100% { box-shadow: 0 0 0 0 rgba(232, 17, 35, 0); }
}

.command-menu {
    position: absolute;
    bottom: calc(100% - 6px);
    left: max(20px, calc(50% - (var(--thread) / 2)));
    background: rgba(18, 20, 26, 0.97);
    border: 1px solid var(--border);
    border-radius: 15px;
    padding: 10px;
    display: none;
    flex-direction: column;
    gap: 5px;
    backdrop-filter: blur(20px);
    z-index: 2000;
    min-width: 260px;
}

.command-menu.active { display: flex; animation: slideUp 0.25s ease; }

.command-menu button {
    background: transparent;
    border: none;
    color: white;
    padding: 10px 20px;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: 0.2s;
}

.command-menu button:hover { background: rgba(255, 255, 255, 0.1); }

.thinking { opacity: 1 !important; }

.thinking .msg-body {
    font-style: italic;
    color: var(--text-dim);
}

.think-pulse {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.think-pulse::after {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    animation: thinkDot 1s infinite ease-in-out;
}

@keyframes thinkDot {
    0%, 100% { opacity: 0.25; transform: scale(0.75); }
    50% { opacity: 1; transform: scale(1); }
}

.action-card {
    align-self: center;
    width: min(var(--thread), calc(100% - 40px));
    background: rgba(47, 143, 255, 0.1);
    border: 1px solid rgba(47, 143, 255, 0.4);
    padding: 10px 20px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-img {
    width: 100%;
    border-radius: 14px;
    border: 1px solid rgba(47, 143, 255, 0.45);
    display: block;
}

.md p { margin: 0 0 0.85em 0; }
.md p:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 {
    margin: 1.05em 0 0.4em;
    line-height: 1.28;
    color: #fff;
    font-weight: 680;
    letter-spacing: -0.02em;
}
.md h1:first-child, .md h2:first-child, .md h3:first-child { margin-top: 0; }
.md h1 { font-size: 1.42rem; }
.md h2 { font-size: 1.24rem; }
.md h3, .md h4 { font-size: 1.08rem; }
.md ul, .md ol { margin: 0.35em 0 0.9em 1.3em; padding: 0; }
.md li { margin: 0.28em 0; }
.md li > p { margin: 0.2em 0; }

.table-wrap {
    width: 100%;
    overflow-x: auto;
    margin: 0.85em 0;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.md table {
    border-collapse: collapse;
    width: 100%;
    min-width: 280px;
    margin: 0;
    font-size: 14.5px;
}

.md th, .md td {
    border-bottom: 1px solid var(--border);
    padding: 9px 12px;
    text-align: left;
    vertical-align: top;
}

.md th { background: rgba(47, 143, 255, 0.16); font-weight: 650; color: #fff; }
.md tr:nth-child(even) td { background: rgba(255, 255, 255, 0.025); }

.md :not(pre) > code {
    background: rgba(255, 255, 255, 0.08);
    padding: 0.12em 0.42em;
    border-radius: 6px;
    font-family: 'Cascadia Code', 'Cascadia Mono', Consolas, 'JetBrains Mono', monospace;
    font-size: 0.9em;
    color: #d7e7ff;
}

.msg.user .md :not(pre) > code {
    background: rgba(0, 0, 0, 0.22);
    color: #fff;
}

.md blockquote {
    border-left: 3px solid var(--accent);
    margin: 0.7em 0;
    padding: 0.2em 0 0.2em 0.95em;
    color: var(--text-dim);
}

.md hr { border: none; border-top: 1px solid var(--border); margin: 1em 0; }
.md strong { color: #fff; font-weight: 680; }

.md a {
    color: #7cbcff;
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px solid rgba(124, 188, 255, 0.35);
}

.md a:hover { filter: brightness(1.15); }
.msg.user .md a { color: #fff; border-bottom-color: rgba(255,255,255,0.4); }

.recuva-link {
    font-weight: 700 !important;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 1px;
}

.code-block {
    margin: 0.9em 0;
    border-radius: 14px;
    overflow: hidden;
    background: var(--code-bg);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

.msg.user .code-block {
    background: rgba(6, 8, 12, 0.55);
    border-color: rgba(255,255,255,0.14);
}

.code-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.035);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.code-lang {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
    font-weight: 700;
}

.copy-btn {
    appearance: none;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.04);
    color: #e8eef7;
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 650;
    cursor: pointer;
    transition: 0.15s ease;
}

.copy-btn:hover { background: rgba(47, 143, 255, 0.22); border-color: rgba(47, 143, 255, 0.45); }
.copy-btn.copied {
    background: rgba(80, 200, 140, 0.2);
    border-color: rgba(80, 200, 140, 0.45);
    color: #b8f3d2;
}

.code-block pre {
    margin: 0;
    padding: 14px 16px 16px;
    overflow-x: auto;
    background: transparent;
    border: none;
}

.code-block code {
    display: block;
    background: none;
    padding: 0;
    font-family: 'Cascadia Code', 'Cascadia Mono', Consolas, 'JetBrains Mono', monospace;
    font-size: 13.75px;
    line-height: 1.65;
    color: #dce6f5;
    white-space: pre;
    tab-size: 4;
}

.tok-cmt { color: #6d7686; font-style: italic; }
.tok-str { color: #7ee0c3; }
.tok-kw  { color: #6cb6ff; }
.tok-num { color: #f0b429; }
.tok-fn  { color: #c4b5fd; }
.tok-tag { color: #7cbcff; }
.tok-attr { color: #9ad0ff; }
.tok-plain { color: inherit; }

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 45px;
    padding: 0 15px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-dim);
    cursor: pointer;
    transition: 0.2s;
    border: 1px solid transparent;
}

.history-item:hover {
    color: white;
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.1);
}

.chat-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-actions {
    display: none;
    gap: 5px;
}

.history-item:hover .history-actions { display: flex; }

.action-btn {
    background: transparent;
    border: none;
    font-size: 14px;
    cursor: pointer;
    opacity: 0.5;
    transition: 0.2s ease;
    padding: 0 2px;
}

.action-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
}

.modal-content {
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid var(--border);
    padding: 30px;
    border-radius: 20px;
    width: 350px;
    text-align: center;
    box-shadow: 0 15px 50px rgba(0,0,0,0.6);
    color: white;
    animation: riseIn 0.3s ease;
}

.modal-content h3 { margin: 0 0 10px 0; color: var(--accent); }
.modal-content p { margin: 0 0 20px 0; font-size: 14px; color: var(--text-dim); }

.modal-input {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 20px;
    background: rgba(10, 10, 10, 0.8);
    border: 1px solid var(--border);
    color: white;
    border-radius: 10px;
    outline: none;
    font-size: 14px;
}

.modal-input:focus { border-color: var(--accent); }

.modal-buttons {
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

.modal-buttons button {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
}

.btn-cancel { background: rgba(255, 255, 255, 0.08); color: white; }
.btn-cancel:hover { background: rgba(255, 255, 255, 0.15); }
.btn-confirm { background: var(--accent); color: white; }
.btn-confirm:hover { filter: brightness(1.2); }

@media (max-width: 680px) {
    .sidebar {
        display: none;
    }
}
