/* Chat application page. */
body {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar ---------------------------------------------------------------- */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width .18s ease, min-width .18s ease;
}
body.sidebar-collapsed .sidebar {
    width: 0;
    min-width: 0;
    border-right: none;
}

/* Collapse / expand controls */
.sidebar-collapse {
    margin-left: auto; flex-shrink: 0;
    background: transparent; border: none; color: var(--muted);
    cursor: pointer; font-size: 16px; line-height: 1;
    padding: 4px 6px; border-radius: 7px;
    transition: color .12s, background .12s;
}
.sidebar-collapse:hover { color: var(--text); background: var(--panel-2); }

.sidebar-expand {
    position: fixed; top: 14px; left: 14px; z-index: 20;
    display: none; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 8px;
    background: var(--panel); border: 1px solid var(--border);
    color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1;
    transition: color .12s, border-color .12s;
}
.sidebar-expand:hover { color: var(--text); border-color: var(--accent); }
body.sidebar-collapsed .sidebar-expand { display: flex; }
.sidebar-head {
    padding: 16px;
    display: flex; align-items: center; gap: 10px;
    border-bottom: 1px solid var(--border);
}
.sidebar-head .dot {
    width: 26px; height: 26px; border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), #a06dff);
}
.sidebar-head h1 { font-size: 14.5px; margin: 0; font-weight: 650; }

.new-chat {
    margin: 12px; padding: 11px; border-radius: 10px;
    border: 1px dashed var(--border); background: transparent;
    color: var(--text); cursor: pointer; font-size: 14px; font-weight: 550;
    transition: border-color .15s, background .15s;
}
.new-chat:hover { border-color: var(--accent); background: var(--panel-2); }

.chat-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.chat-item {
    padding: 10px 12px; border-radius: 9px; cursor: pointer;
    font-size: 13.5px; color: var(--muted); margin-bottom: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: background .12s, color .12s;
}
.chat-item:hover { background: var(--panel-2); color: var(--text); }
.chat-item.active { background: var(--panel); color: var(--text); }
.chat-list .empty { padding: 16px 14px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }

.sidebar-foot {
    border-top: 1px solid var(--border); padding: 12px;
    display: flex; align-items: center; justify-content: space-between;
}
.sidebar-foot span { font-size: 12.5px; color: var(--muted); }
.sidebar-foot button {
    background: transparent; border: 1px solid var(--border); color: var(--muted);
    padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 12.5px;
}
.sidebar-foot button:hover { color: var(--text); border-color: var(--accent); }

/* Main ------------------------------------------------------------------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.messages { flex: 1; overflow-y: auto; padding: 5vw 0; }
.messages-inner { max-width: 85vw; margin: 0 auto; padding: 0 24px; }
.placeholder {
    height: 100%; display: flex; align-items: center; justify-content: center;
    color: var(--muted); font-size: 14.5px; text-align: center; padding: 24px;
}

.row { display: flex; margin-bottom: 18px; }
.row.user { justify-content: flex-end; }
.bubble {
    max-width: 80%; padding: 12px 15px; border-radius: 14px;
    font-size: 14.5px; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word;
}
.row.user .bubble { background: var(--user-bubble); border-bottom-right-radius: 4px; }
.row.assistant .bubble { background: var(--bot-bubble); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble.error { border-color: var(--danger); color: var(--danger); }
.bubble pre {
    background: #0c0e13; border: 1px solid var(--border); border-radius: 8px;
    padding: 12px; overflow-x: auto; margin: 8px 0; font-size: 13px;
}
.bubble code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.bubble :not(pre) > code {
    background: #0c0e13; border: 1px solid var(--border);
    padding: 1px 5px; border-radius: 5px; font-size: 13px;
}
.cursor::after {
    content: "▋"; margin-left: 1px; color: var(--muted);
    animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }

/* Composer --------------------------------------------------------------- */
.composer { border-top: 1px solid var(--border); padding: 16px 24px 22px; }
.composer-inner {
    max-width: 85vw; margin: 0 auto;
    display: flex; gap: 10px; align-items: flex-end;
    background: var(--panel-2); border: 1px solid var(--border);
    border-radius: 14px; padding: 8px 8px 8px 14px;
}
.composer-inner:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109, 139, 255, .15); }
textarea {
    flex: 1; resize: none; border: none; background: transparent; color: var(--text);
    font-family: inherit; font-size: 14.5px; line-height: 1.5; outline: none;
    max-height: 200px; padding: 6px 0;
}
textarea::placeholder { color: var(--muted); }
.send {
    width: 38px; height: 38px; border-radius: 10px; border: none; cursor: pointer;
    background: var(--accent); color: white; font-size: 16px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.send:hover { background: var(--accent-hover); }
.send:disabled { opacity: .5; cursor: default; }
.composer-note { max-width: 760px; margin: 8px auto 0; font-size: 11.5px; color: var(--muted); text-align: center; }

/* Modal ------------------------------------------------------------------ */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0, 0, 0, .55);
    display: none; align-items: center; justify-content: center; padding: 24px;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
    padding: 22px; width: 100%; max-width: 440px;
}
.modal h2 { margin: 0 0 4px; font-size: 16px; }
.modal p { margin: 0 0 16px; font-size: 13px; color: var(--muted); }
.modal textarea {
    width: 100%; min-height: 90px; background: var(--panel-2);
    border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px;
    color: var(--text); font-size: 14px; max-height: none;
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.modal-actions button { padding: 9px 16px; border-radius: 9px; cursor: pointer; font-size: 14px; font-weight: 550; border: 1px solid var(--border); }
.modal-actions .cancel { background: transparent; color: var(--muted); }
.modal-actions .create { background: var(--accent); color: white; border-color: var(--accent); }
