/* Robotext — стили интерфейса */
:root {
    --accent: #FF6F61;
    --dark: #363738;
    --cream: #f8f7f3;
    --bg: #ffffff;
    --border: #e8e6e1;
    --text: #363738;
    --muted: #8a8b8d;
    --accent-soft: #fff0ee;
    --accent-dark: #e5564a;
    --radius: 14px;
    --shadow: 0 8px 30px rgba(54, 55, 56, .08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: 'Manrope', sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Header ── */
header {
    height: 64px;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg);
    flex-shrink: 0;
}
.logo { font-weight: 800; letter-spacing: 1px; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.logo i { color: var(--accent); font-size: 22px; }
.logo span { color: var(--accent); }
.user-info { color: var(--muted); font-size: 14px; display: flex; gap: 10px; align-items: center; }
.icon-btn {
    background: none; border: 1px solid var(--border); color: var(--muted);
    width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
    font-size: 18px; display: inline-flex; align-items: center; justify-content: center;
    transition: all .15s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* ── Layout ── */
main { flex: 1; display: flex; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
    width: 300px;
    border-right: 1px solid var(--border);
    background: var(--cream);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.sidebar-head {
    padding: 18px 20px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sidebar-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); font-weight: 700; }
.asst-list { flex: 1; overflow-y: auto; padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.asst-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border-radius: 12px; cursor: pointer;
    border: 1px solid transparent; transition: all .15s;
}
.asst-item:hover { background: #fff; border-color: var(--border); }
.asst-item.active { background: #fff; border-color: var(--accent); box-shadow: 0 2px 10px rgba(255, 111, 97, .12); }
.asst-item .avatar {
    width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
    background: var(--accent-soft); color: var(--accent);
    display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.asst-item.active .avatar { background: var(--accent); color: #fff; }
.asst-item .info { min-width: 0; flex: 1; }
.asst-item .name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asst-item .dir { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asst-item .edit-btn {
    background: none; border: none; color: var(--muted); cursor: pointer;
    font-size: 16px; padding: 4px; border-radius: 6px; opacity: 0; transition: opacity .15s;
}
.asst-item:hover .edit-btn { opacity: 1; }
.asst-item .edit-btn:hover { color: var(--accent); }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.sidebar-foot .btn {
    flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--border);
    background: #fff; color: var(--text); font-family: inherit; font-weight: 600;
    font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
    transition: all .15s;
}
.sidebar-foot .btn:hover { border-color: var(--accent); color: var(--accent); }
.sidebar-foot .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.sidebar-foot .btn.primary:hover { background: var(--accent-dark); }

/* ── Chat area ── */
.chat-area { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.chat-head {
    padding: 14px 24px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.chat-head .avatar {
    width: 38px; height: 38px; border-radius: 11px;
    background: var(--accent-soft); color: var(--accent);
    display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.chat-head .name { font-weight: 700; font-size: 15px; }
.chat-head .dir { font-size: 12px; color: var(--muted); }
.chat-head .spacer { flex: 1; }

#chat-box { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.msg { max-width: 72%; padding: 12px 16px; border-radius: 16px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; font-size: 14.5px; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.msg.assistant { align-self: flex-start; background: var(--cream); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.msg .role { font-size: 10px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 1.2px; font-weight: 700; }
.msg.user .role { color: rgba(255,255,255,.7); }

.composer { border-top: 1px solid var(--border); padding: 16px 24px; display: flex; gap: 10px; flex-shrink: 0; }
.composer textarea {
    flex: 1; background: var(--cream); border: 1px solid var(--border); color: var(--text);
    border-radius: 12px; padding: 13px 16px; font-family: inherit; font-size: 15px;
    resize: none; min-height: 48px; max-height: 160px;
}
.composer textarea:focus { outline: none; border-color: var(--accent); background: #fff; }
.composer button {
    background: var(--accent); color: #fff; border: none; border-radius: 12px;
    padding: 0 22px; font-size: 20px; cursor: pointer; transition: background .15s;
}
.composer button:hover { background: var(--accent-dark); }
.composer button:disabled { opacity: .5; cursor: not-allowed; }

.empty-state {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: var(--muted); gap: 12px; text-align: center; padding: 40px;
}
.empty-state i { font-size: 48px; color: var(--accent); opacity: .5; }
.empty-state h3 { color: var(--text); font-size: 18px; }
.empty-state p { font-size: 14px; max-width: 380px; }

/* ── Modals ── */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(54, 55, 56, .45);
    display: flex; align-items: center; justify-content: center; z-index: 100;
    padding: 20px; overflow-y: auto;
}
.modal {
    background: #fff; border-radius: 18px; padding: 28px;
    width: 100%; max-width: 440px; box-shadow: var(--shadow);
    max-height: 90vh; overflow-y: auto;
}
.modal.wide { max-width: 560px; }
.modal h2 { font-size: 19px; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; }
.modal h2 i { color: var(--accent); }
.modal .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field textarea, .field select {
    width: 100%; background: var(--cream); border: 1px solid var(--border); color: var(--text);
    border-radius: 10px; padding: 10px 12px; font-family: inherit; font-size: 14px;
}
.field textarea { resize: vertical; min-height: 70px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); background: #fff; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.error { color: #d93025; font-size: 13px; margin-bottom: 12px; min-height: 18px; }
.btn-primary {
    width: 100%; background: var(--accent); color: #fff; border: none; border-radius: 10px;
    padding: 12px; font-weight: 700; cursor: pointer; font-family: inherit; font-size: 14px;
    display: flex; align-items: center; justify-content: center; gap: 8px; transition: background .15s;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost {
    width: 100%; background: none; color: var(--muted); border: 1px solid var(--border);
    border-radius: 10px; padding: 11px; font-weight: 600; cursor: pointer; font-family: inherit;
    font-size: 13px; margin-top: 8px; transition: all .15s;
}
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); }
.switch { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }
.switch a { color: var(--accent); cursor: pointer; text-decoration: none; font-weight: 600; }

/* ── Icon picker ── */
.icon-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-top: 6px; }
.icon-grid button {
    aspect-ratio: 1; border: 1px solid var(--border); background: var(--cream);
    border-radius: 8px; font-size: 18px; color: var(--text); cursor: pointer; transition: all .12s;
}
.icon-grid button:hover { border-color: var(--accent); color: var(--accent); }
.icon-grid button.sel { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Tasks panel ── */
.tasks-panel {
    position: absolute; top: 70px; right: 20px; width: 320px; max-height: 70vh;
    background: #fff; border: 1px solid var(--border); border-radius: 16px;
    box-shadow: var(--shadow); z-index: 50; display: flex; flex-direction: column; overflow: hidden;
}
.tasks-head { padding: 16px 18px 10px; display: flex; justify-content: space-between; align-items: center; }
.tasks-head h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.tasks-head h3 i { color: var(--accent); }
.tasks-list { overflow-y: auto; padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.task-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px; border-radius: 10px; }
.task-item:hover { background: var(--cream); }
.task-item input[type="checkbox"] { accent-color: var(--accent); width: 17px; height: 17px; margin-top: 2px; cursor: pointer; }
.task-item .t { font-size: 14px; font-weight: 600; }
.task-item .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.task-item.done .t { text-decoration: line-through; color: var(--muted); }
.task-item .del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px; margin-left: auto; opacity: 0; transition: opacity .15s; }
.task-item:hover .del { opacity: 1; }
.task-item .del:hover { color: #d93025; }
.task-add { padding: 12px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.task-add input {
    flex: 1; background: var(--cream); border: 1px solid var(--border); border-radius: 8px;
    padding: 9px 12px; font-family: inherit; font-size: 13px;
}
.task-add input:focus { outline: none; border-color: var(--accent); }
.task-add button {
    background: var(--accent); color: #fff; border: none; border-radius: 8px;
    width: 38px; cursor: pointer; font-size: 17px;
}
.task-add button:hover { background: var(--accent-dark); }
.tasks-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }

/* ── Documents ── */
.docs-upload { display: flex; align-items: center; gap: 12px; margin: 14px 0; }
.docs-limit { font-size: 12px; color: var(--muted); }
.docs-list { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; margin-bottom: 14px; }
.docs-empty {
    padding: 28px 20px; text-align: center; color: var(--muted); font-size: 13px;
    border: 1px dashed var(--border); border-radius: 12px; background: var(--cream);
}
.docs-empty i { display: block; font-size: 26px; margin-bottom: 8px; opacity: .5; }
.doc-row {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 10px; background: var(--cream);
}
.doc-row > i { color: var(--accent); font-size: 20px; flex-shrink: 0; }
.doc-row .i { flex: 1; min-width: 0; }
.doc-row .n { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-row .m { font-size: 11px; color: var(--muted); margin-top: 2px; }
.doc-status { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; flex-shrink: 0; }
.doc-status.wait { background: #eee9e4; color: #8a7f76; }
.doc-status.run { background: #ffe9e6; color: var(--accent-dark); }
.doc-status.ok { background: #e3f2e5; color: #2e7d32; }
.doc-status.err { background: #fdecea; color: #d93025; }
.doc-row .del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; opacity: 0; transition: opacity .15s; }
.doc-row:hover .del { opacity: 1; }
.doc-row .del:hover { color: #d93025; }

.hidden { display: none !important; }

/* ── Admin ── */
.admin-tabs { display: flex; gap: 6px; margin: 14px 0 16px; }
.admin-tab {
    flex: 1; padding: 9px; border: 1px solid var(--border); background: var(--cream);
    border-radius: 10px; font-family: inherit; font-size: 13px; font-weight: 600;
    color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
    transition: all .15s;
}
.admin-tab:hover { color: var(--accent); border-color: var(--accent); }
.admin-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.admin-stats { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.admin-stats .stat {
    flex: 1; min-width: 90px; background: var(--cream); border: 1px solid var(--border);
    border-radius: 10px; padding: 10px; text-align: center;
}
.admin-stats .stat b { display: block; font-size: 18px; color: var(--accent); }
.admin-stats .stat span { font-size: 11px; color: var(--muted); }

.admin-user-row {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 10px; margin-bottom: 6px; background: var(--cream);
}
.admin-user-row .u { flex: 1; min-width: 0; }
.admin-user-row .u .e { font-weight: 700; font-size: 14px; }
.admin-user-row .u .m { font-size: 11px; color: var(--muted); }
.admin-user-row .badge {
    font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 20px; letter-spacing: .5px;
}
.admin-user-row .badge.admin { background: var(--accent-soft); color: var(--accent-dark); }
.admin-user-row .badge.off { background: #eee; color: var(--muted); }
.admin-user-row .badge.lock { background: #fdecea; color: #d93025; }
.admin-user-row .icon-btn { width: 30px; height: 30px; font-size: 15px; }

.setting-row {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 14px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; background: var(--cream);
}
.setting-title { font-weight: 700; font-size: 14px; }
.setting-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.toggle { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
    position: absolute; inset: 0; background: #d5d3cd; border-radius: 20px; cursor: pointer; transition: .2s;
}
.toggle .slider:before {
    content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider:before { transform: translateX(20px); }

.invite-gen { display: flex; gap: 8px; margin-bottom: 14px; }
.invite-gen input {
    flex: 1; background: var(--cream); border: 1px solid var(--border); border-radius: 10px;
    padding: 10px 12px; font-family: inherit; font-size: 13px;
}
.invite-gen input:focus { outline: none; border-color: var(--accent); }
.invite-gen .btn-primary { padding: 10px 16px; font-size: 12px; white-space: nowrap; }

.invite-row {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px;
    border: 1px solid var(--border); border-radius: 10px; margin-bottom: 6px; background: var(--cream);
}
.invite-row .code { font-family: monospace; font-weight: 700; font-size: 13px; letter-spacing: 1px; }
.invite-row .note { flex: 1; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite-row .used { font-size: 11px; color: var(--muted); }
.invite-row .used.yes { color: #2e7d32; }
.invite-row .icon-btn { width: 28px; height: 28px; font-size: 14px; }

/* ── Site indexing field ── */
.site-field {
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
}
.site-field > label {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--text); font-weight: 700;
}
.site-field > label i { color: var(--accent); font-size: 16px; }
.site-field input[type="text"], .site-field input:not([type]) {
    background: #fff;
}
.site-field .hint {
    display: flex; gap: 8px; align-items: flex-start;
    margin-top: 8px; padding: 10px 12px;
    background: var(--accent-soft); border-radius: 10px;
    font-size: 12.5px; line-height: 1.5; color: var(--text);
}
.site-field .hint i { color: var(--accent); font-size: 15px; margin-top: 1px; flex-shrink: 0; }
.site-auto {
    display: flex; align-items: center; gap: 12px; margin-top: 12px;
    padding-top: 12px; border-top: 1px dashed var(--border);
}
.site-auto-info { flex: 1; }
.site-auto-info .t { font-size: 13px; font-weight: 700; }
.site-auto-info .s { font-size: 11.5px; color: var(--muted); }
.site-auto select {
    background: #fff; border: 1px solid var(--border); border-radius: 8px;
    padding: 7px 10px; font-family: inherit; font-size: 12.5px; color: var(--text);
    cursor: pointer;
}
.site-auto select:focus { outline: none; border-color: var(--accent); }
.site-status { margin-top: 10px; font-size: 12px; color: var(--muted); min-height: 16px; }
.site-status.run { color: var(--accent-dark); font-weight: 600; }
.site-status.err { color: #d93025; font-weight: 600; }

/* ── Прогресс индексации сайта ── */
.site-progress { margin-top: 10px; }
.site-progress .bar {
    height: 8px; background: #fff; border: 1px solid var(--border);
    border-radius: 6px; overflow: hidden;
}
.site-progress .fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-dark));
    border-radius: 6px; transition: width .6s ease;
}
.site-progress .lbl { margin-top: 6px; font-size: 11.5px; color: var(--muted); }

/* ── Индикатор набора текста (чат) ── */
.typing { display: inline-flex; gap: 5px; align-items: center; padding: 4px 2px; }
.typing span {
    width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
    opacity: .35; animation: typing-blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes typing-blink {
    0%, 80%, 100% { opacity: .25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

@media (max-width: 860px) {
    .admin-tab { font-size: 12px; padding: 8px 4px; }
    .invite-gen { flex-wrap: wrap; }
}

@media (max-width: 860px) {
    .sidebar { position: fixed; left: 0; top: 64px; bottom: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
    .sidebar.open { transform: translateX(0); }
    .msg { max-width: 88%; }
    .tasks-panel { right: 12px; left: 12px; width: auto; }
}
@media (max-width: 560px) {
    header { padding: 0 14px; }
    .composer { padding: 12px 14px; }
    #chat-box { padding: 16px; }
}
