/* MatCat Agent — local additions over shared.2it.onl CSS */

/* ---------- login ---------- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.login-wrap { width: 100%; max-width: 420px; }
.login-card { text-align: center; }
.login-icon { width: 72px; height: 72px; margin-bottom: 12px; }
.login-card h1 { font-size: 1.8rem; margin-bottom: 4px; }
.login-card form { text-align: left; margin-top: 20px; }
.login-error {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.4);
    color: #f87171;
    font-size: 0.95rem;
}

/* ---------- app layout ---------- */
#app { display: flex; flex-direction: column; height: 100vh; padding: 0; }
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    flex: 0 0 auto;
}
.app-header-left { display: flex; align-items: center; gap: 12px; }
.app-logo { width: 40px; height: 40px; }
.app-title {
    font-size: 1.25rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}
.app-subtitle { color: var(--text-muted); font-size: 0.85rem; margin: 0; }
.app-header-right { display: flex; align-items: center; gap: 8px; }
.btn-sm { padding: 7px 14px; font-size: 0.9rem; }
.btn-danger { background: #7f1d1d; color: #fca5a5; }
.btn-danger:hover { box-shadow: 0 10px 25px rgba(248, 113, 113, 0.3); }

.server-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: #555;
    display: inline-block;
}
.server-dot.up { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.server-dot.down { background: #f87171; box-shadow: 0 0 8px #f87171; }

.pane-collapse {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    padding: 3px 9px;
    font-size: 0.85rem;
    line-height: 1.2;
    flex: 0 0 auto;
}
.pane-collapse:hover { color: var(--accent); border-color: var(--accent); }

.pane-expand {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 8px 10px;
    flex: 0 0 auto;
}
.pane-expand:hover { color: var(--accent); }

.pane-body { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; min-width: 0; }

.pane-rail {
    display: none;
    flex-direction: column;
    align-items: center;
    height: 100%;
    overflow: hidden;
    flex: 0 0 auto;
}
.sidebar .pane-rail { border-right: 1px solid var(--border); }
.workspace .pane-rail { border-left: 1px solid var(--border); }
.pane-rail-label {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    margin-top: 12px;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    user-select: none;
}

.app-body.sb-off { grid-template-columns: 46px 1fr 340px; }
.app-body.ws-off { grid-template-columns: 280px 1fr 46px; }
.app-body.sb-off.ws-off { grid-template-columns: 46px 1fr 46px; }
.app-body.sb-off .sidebar .pane-body,
.app-body.sb-off .sidebar .pane-collapse { display: none; }
.app-body.sb-off .sidebar .pane-rail { display: flex; }
.app-body.ws-off .workspace .pane-body,
.app-body.ws-off .workspace .pane-collapse { display: none; }
.app-body.ws-off .workspace .pane-rail { display: flex; }
.app-body.sb-off .sidebar { border-right: 0; }
.app-body.ws-off .workspace { border-left: 0; }

.app-body {
    display: grid;
    grid-template-columns: 280px 1fr 340px;
    flex: 1 1 auto;
    min-height: 0;
}
.panel { overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.sidebar { border-right: 1px solid var(--border); }
.workspace { border-left: 1px solid var(--border); }
.panel-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
}
.panel-title { font-size: 0.95rem; margin: 0; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }

/* ---------- session list ---------- */
.session-list { overflow-y: auto; padding: 8px; flex: 1 1 auto; }
.session-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid transparent;
    margin-bottom: 4px;
    background: transparent;
    transition: background 0.15s;
}
.session-item:hover { background: var(--bg-input); }
.session-item.active {
    background: rgba(0, 255, 157, 0.08);
    border-color: var(--accent);
}
.session-main { flex: 1 1 auto; min-width: 0; }
.session-title {
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.session-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    gap: 8px;
    align-items: center;
    white-space: nowrap;
    overflow: hidden;
}
.session-meta .model-chip {
    color: var(--accent);
    background: rgba(0, 255, 157, 0.1);
    border-radius: 4px;
    padding: 0 5px;
}
.session-actions { display: none; gap: 4px; }
.session-item:hover .session-actions { display: flex; }
.icon-btn {
    background: var(--bg-input);
    border: none;
    color: var(--text-muted);
    border-radius: 6px;
    padding: 4px 7px;
    cursor: pointer;
    font-size: 0.8rem;
}
.icon-btn:hover { color: var(--accent); }
.session-tokens { font-size: 0.7rem; color: var(--text-muted); }
.session-tokens.warn { color: #ffb74d; }

/* ---------- chat ---------- */
.chat-col { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
    font-size: 0.95rem;
}
.chat-spacer { flex: 1 1 auto; }

.toggle-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 5px 12px 5px 6px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: border-color 0.2s, color 0.2s;
}
.toggle-switch:hover { border-color: var(--border-hover); }
.toggle-track { width: 34px; height: 18px; border-radius: 999px; background: #333; position: relative; flex: 0 0 auto; transition: background 0.2s; }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #888; transition: transform 0.2s, background 0.2s; }
.toggle-switch.on { border-color: var(--accent); color: var(--text); }
.toggle-switch.on .toggle-track { background: rgba(0, 255, 157, 0.35); }
.toggle-switch.on .toggle-thumb { transform: translateX(16px); background: var(--accent); }
.messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px 20px;
    scroll-behavior: smooth;
}
.msg { margin-bottom: 18px; max-width: 100%; }
.msg-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.msg-role { font-weight: 600; }
.msg-role.user { color: #7dd3fc; }
.msg-role.assistant { color: var(--accent); }
.msg-tokens { margin-left: auto; font-size: 0.75rem; }
.part { margin-bottom: 8px; }

.part-text {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    border: 1px solid var(--border);
    font-size: 0.95rem;
    line-height: 1.55;
    overflow-wrap: break-word;
}
.part-text pre {
    background: #0d0d10;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    overflow-x: auto;
    margin: 8px 0;
}
.part-text pre code { font-family: var(--font-mono); font-size: 0.85rem; }
.part-text code {
    font-family: var(--font-mono);
    background: rgba(255, 255, 255, 0.07);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.88em;
}
.part-text pre code { background: none; padding: 0; }
.part-text table { border-collapse: collapse; margin: 8px 0; }
.part-text th, .part-text td { border: 1px solid var(--border); padding: 5px 10px; }
.part-text blockquote { border-left: 3px solid var(--accent); padding-left: 12px; color: var(--text-muted); margin: 8px 0; }
.part-text a { color: var(--accent); }
.part-text h1, .part-text h2, .part-text h3, .part-text h4 { margin: 12px 0 6px; }
.part-text h1 { font-size: 1.3rem; } .part-text h2 { font-size: 1.15rem; }
.part-text h3 { font-size: 1.05rem; } .part-text h4 { font-size: 1rem; }
.part-text ul, .part-text ol { padding-left: 22px; margin: 6px 0; }
.copy-btn {
    float: right;
    font-size: 0.72rem;
    padding: 2px 8px;
    background: var(--bg-input);
    color: var(--text-muted);
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
.copy-btn:hover { color: var(--accent); }

.part-reasoning {
    border-left: 2px solid #555;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
    margin: 4px 0 8px;
    padding: 8px 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.part-reasoning[open] summary { border-bottom: 1px solid var(--border); padding-bottom: 6px; margin-bottom: 6px; }
.part-reasoning summary { cursor: pointer; user-select: none; color: #ffb74d; }
.part-reasoning .reasoning-body { white-space: pre-wrap; font-size: 0.82rem; opacity: 0.9; line-height: 1.55; }

.part-tool {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    margin: 4px 0;
    font-size: 0.85rem;
}
.part-tool summary { cursor: pointer; padding: 7px 12px; display: flex; align-items: center; gap: 8px; }
.tool-state { margin-left: auto; font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; }
.tool-state.running { background: rgba(0, 212, 255, 0.15); color: #00d4ff; }
.tool-state.completed { background: rgba(0, 255, 157, 0.15); color: var(--accent); }
.tool-state.error { background: rgba(248, 113, 113, 0.15); color: #f87171; }
.tool-state.pending { background: rgba(255, 183, 77, 0.15); color: #ffb74d; }
.tool-body { padding: 8px 12px; border-top: 1px solid var(--border); }
.tool-body pre { background: #0d0d10; border-radius: var(--radius-sm); padding: 8px; overflow-x: auto; max-height: 220px; overflow-y: auto; font-size: 0.8rem; font-family: var(--font-mono); white-space: pre-wrap; word-break: break-word; }

.part-step { font-size: 0.75rem; color: var(--text-muted); margin: 4px 0; }
.part-file { display: inline-block; margin: 4px 6px 4px 0; }
.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 0.85rem;
    text-decoration: none;
    color: var(--text);
}
.file-chip:hover { border-color: var(--accent); }
.part-image { max-width: 100%; max-height: 480px; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; }

.part-permission {
    border: 1px solid #ffb74d;
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin: 8px 0;
    background: rgba(255, 183, 77, 0.06);
}
.part-permission .perm-title { font-weight: 600; margin-bottom: 6px; }
.part-permission .perm-buttons { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.agent-chip {
    display: inline-block;
    background: rgba(0, 255, 157, 0.12);
    color: var(--accent);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 0.75rem;
    margin: 2px 6px 2px 0;
}
.msg-error-part {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.4);
    color: #f87171;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 0.9rem;
}

/* ---------- tasks modal ---------- */
.task-list { list-style: none; max-height: 50vh; overflow-y: auto; }
.task-item { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; font-size: 0.92rem; line-height: 1.45; border-bottom: 1px solid var(--border); }
.task-item:last-child { border-bottom: none; }
.task-content.completed { text-decoration: line-through; color: var(--text-muted); }
.todo-state { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; margin-top: 4px; }
.todo-state.pending { background: #555; }
.todo-state.in_progress { background: #00d4ff; }
.todo-state.completed { background: var(--accent); }
.todo-state.cancelled { background: #f87171; }

/* ---------- composer ---------- */
.composer-wrap {
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    padding: 10px 16px 12px;
    flex: 0 0 auto;
}
.composer-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.composer-spacer { flex: 1 1 auto; }
.composer-input {
    min-height: 120px;
    max-height: 50vh;
    width: 100%;
    flex: none;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.6;
    padding: 14px 16px;
}
.composer-input:disabled { opacity: 0.55; }
.composer-select { width: auto; min-width: 170px; max-width: 240px; }
.composer-agent { min-width: 110px; }
.composer-files { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.file-chip .chip-remove { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.9rem; }
.file-chip .chip-remove:hover { color: #f87171; }

.context-meter-wrap { margin-top: 12px; display: flex; align-items: center; gap: 10px; }
.context-label { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
.context-nums { font-size: 0.78rem; color: var(--text-muted); min-width: 160px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.context-bar { flex: 1 1 auto; height: 8px; background: #2a2a32; border-radius: 9999px; overflow: hidden; }
.context-fill { height: 100%; width: 0%; background: var(--accent-gradient); border-radius: 9999px; transition: width 0.4s; }
.context-fill.warn { background: linear-gradient(90deg, #ffb74d, #f87171); }

/* ---------- workspace ---------- */
.ws-warning {
    margin: 10px 12px 0;
    padding: 8px 12px;
    font-size: 0.78rem;
    background: rgba(255, 183, 77, 0.1);
    border: 1px solid rgba(255, 183, 77, 0.35);
    border-radius: var(--radius-sm);
    color: #ffb74d;
}
.ws-breadcrumb {
    padding: 8px 14px;
    font-size: 0.78rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
    overflow-x: auto;
    white-space: nowrap;
}
.ws-breadcrumb a { color: var(--accent); text-decoration: none; cursor: pointer; }
.ws-breadcrumb a:hover { text-decoration: underline; }
.ws-tree { flex: 1 1 auto; overflow-y: auto; padding: 8px; }
.ws-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
}
.ws-item:hover { background: var(--bg-input); }
.ws-item .ws-caret { width: 12px; color: var(--text-muted); flex: 0 0 auto; }
.ws-item .ws-name { overflow: hidden; text-overflow: ellipsis; }
.ws-item .ws-arrow { color: var(--text-muted); font-size: 0.7rem; margin-left: auto; }
.ws-item .ws-exposed { color: #ffb74d; font-size: 0.68rem; margin-left: auto; flex: 0 0 auto; }
.ws-item .ws-size { color: var(--text-muted); font-size: 0.7rem; margin-left: auto; flex: 0 0 auto; }
.ws-item.dir .ws-name { color: #7dd3fc; }
.ws-children { padding-left: 14px; }
.ws-empty { color: var(--text-muted); font-size: 0.8rem; padding: 12px; text-align: center; }

/* ---------- modals ---------- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
.modal-card { width: 100%; max-width: 440px; }
.modal-wide { max-width: 780px; }
.modal-title { font-size: 1.2rem; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.usage-chart { width: 100%; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 14px; }
.usage-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.usage-table th, .usage-table td { border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: left; }
.usage-table th { color: var(--text-muted); font-weight: 600; }
.usage-table tbody tr:hover { background: var(--bg-input); }

.file-body { max-height: 60vh; overflow: auto; }
.file-body img { max-width: 100%; border-radius: var(--radius-sm); }
.file-editor { width: 100%; min-height: 320px; font-family: var(--font-mono); font-size: 0.85rem; background: #0d0d10; color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; resize: vertical; }
.file-save-row { margin-top: 10px; text-align: right; }

@media (max-width: 1100px) {
    .app-body { grid-template-columns: 240px 1fr; }
    .workspace { display: none; }
}
@media (max-width: 800px) {
    .app-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .sidebar { display: none; }
}
