/* ── modals.css ──────────────────────────────
   Modal system, debug modal, command palette, confirm dialog
   ──────────────────────────────────────────── */

/* ── Modal ────────────────────────────────── */

.modal-overlay {
    position: fixed; inset: 0; background: var(--overlay);
    display: none; align-items: center; justify-content: center;
    z-index: 1000; backdrop-filter: blur(2px);
    padding: 2rem;  /* keeps modal away from viewport edges at any zoom */
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); width: 90%; max-width: 520px;
    max-height: 100%; display: flex; flex-direction: column;
    animation: modal-in 0.15s ease;
}
.modal-wide { max-width: 700px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(-8px); } }

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-close {
    background: none; border: none; color: var(--text-3); font-size: 18px;
    cursor: pointer; padding: 2px 6px; border-radius: 4px;
    transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }
.modal-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.modal-footer {
    padding: 12px 20px; border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 0.5rem;
}

.settings-section { margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.settings-section:last-child { border-bottom: none; margin-bottom: 0; }
.settings-section h3 { font-size: 12px; font-weight: 600; color: var(--text-3); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.avatar-upload-row { display: flex; align-items: center; gap: 14px; margin-bottom: 1rem; }
.avatar-preview {
    width: 56px; height: 56px; border-radius: 50%; background: var(--bg-raised);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 600; color: var(--accent); flex-shrink: 0;
    overflow: hidden; border: 2px solid var(--border);
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-actions { display: flex; flex-direction: column; gap: 4px; }
.avatar-actions .form-hint { font-size: 11px; margin-left: 0; }
.avatar-preview-sm { width: 42px; height: 42px; font-size: 18px; }

/* Modal tab bars — shared horizontal scroll with arrow navigation */
.modal-tabs-wrap {
    position: relative; flex-shrink: 0;
    border-bottom: 1px solid var(--border); background: var(--bg-raised);
}
.modal-tabs {
    display: flex; padding: 0 16px;
    border-bottom: 1px solid var(--border); background: var(--bg-raised);
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    flex-shrink: 0;
}
.modal-tabs::-webkit-scrollbar { display: none; }
/* When wrapped, the wrapper owns the border */
.modal-tabs-wrap .modal-tabs { border-bottom: none; background: none; }

.tab-arrow {
    position: absolute; top: 0; bottom: 1px; /* 1px for border */ width: 28px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-raised); border: none; color: var(--text-2);
    cursor: pointer; font-size: 16px; z-index: 2; opacity: 0;
    pointer-events: none; transition: opacity 0.15s ease;
}
.tab-arrow.visible { opacity: 1; pointer-events: auto; }
.tab-arrow:hover { color: var(--accent); }
.tab-arrow-left { left: 0; padding-left: 2px; box-shadow: 4px 0 8px -2px rgba(0,0,0,0.15); }
.tab-arrow-right { right: 0; padding-right: 2px; box-shadow: -4px 0 8px -2px rgba(0,0,0,0.15); }

/* Settings tabs */
.settings-tabs { gap: 0; }
.settings-tabs .settings-tab {
    padding: 10px 14px; background: none; border: none; border-radius: 0;
    color: var(--text-3); cursor: pointer; font-size: 13px; font-family: var(--font);
    border-bottom: 2px solid transparent; transition: color var(--transition);
    outline: none; -webkit-appearance: none; appearance: none;
    white-space: nowrap; flex-shrink: 0;
}
.settings-tabs .settings-tab:hover { color: var(--text-2); }
.settings-tabs .settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.settings-notice {
    background: rgba(234,179,8,0.08); border: 1px solid var(--warning-dim);
    border-radius: var(--radius); padding: 10px 14px; font-size: 13px;
    color: var(--warning); display: flex; align-items: center; gap: 8px;
    margin-top: 1rem;
}

/* Providers */
.provider-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 0; border-bottom: 1px solid var(--border);
}
.provider-name { font-weight: 500; font-size: 13px; }
.provider-meta { font-size: 11px; color: var(--text-3); margin-left: 8px; }
.provider-actions { display: flex; align-items: center; gap: 8px; }

/* Admin panel (fullscreen) */
.admin-panel {
    position: fixed; z-index: 1000;
    top: var(--banner-top-height); right: 0;
    bottom: var(--banner-bottom-height); left: 0;
    background: var(--bg); display: flex; flex-direction: column;
}
.admin-topbar {
    display: flex; align-items: center; padding: 0 1rem; height: 48px;
    border-bottom: 1px solid var(--border); background: var(--bg-surface); flex-shrink: 0;
}
.admin-back {
    background: none; border: none; color: var(--text-3); cursor: pointer;
    font-size: 14px; padding: 4px 10px; border-radius: 4px; font-family: var(--font);
}
.admin-back:hover { color: var(--accent); background: var(--bg-raised); }
.admin-title { font-size: 16px; font-weight: 600; margin-left: 1rem; flex: 1; }
.admin-user { font-size: 12px; color: var(--text-3); }

.admin-categories {
    display: flex; gap: 0; border-bottom: 1px solid var(--border);
    background: var(--bg-surface); padding: 0 1rem; flex-shrink: 0;
}
.admin-cat {
    background: none; border: none; border-bottom: 2px solid transparent;
    color: var(--text-3); padding: 10px 20px; cursor: pointer;
    font-size: 14px; font-weight: 500; font-family: var(--font);
    transition: color 0.15s, border-color 0.15s; outline: none;
}
.admin-cat:hover { color: var(--text-2); }
.admin-cat.active { color: var(--accent); border-bottom-color: var(--accent); }

.admin-body { display: flex; flex: 1; overflow: hidden; }

.admin-sidebar {
    width: 160px; flex-shrink: 0; border-right: 1px solid var(--border);
    background: var(--bg-surface); padding: 0.75rem 0; overflow-y: auto;
}
.admin-sidebar button {
    display: block; width: 100%; text-align: left; background: none; border: none;
    padding: 8px 20px; color: var(--text-3); cursor: pointer;
    font-size: 13px; font-family: var(--font); border-left: 3px solid transparent;
    transition: color 0.1s, background 0.1s;
}
.admin-sidebar button:hover { color: var(--text-2); background: var(--bg-raised); }
.admin-sidebar button.active { color: var(--accent); border-left-color: var(--accent); background: var(--bg-raised); }

.admin-main { flex: 1; overflow-y: auto; padding: 1.5rem 2rem; }
.admin-section-content { /* replaces .admin-tab-content */ }

/* Admin shared */
/* admin-tab: still used by team admin modal */
.admin-tab {
    padding: 10px 14px; background: none; border: none; color: var(--text-3);
    cursor: pointer; font-size: 13px; border-bottom: 2px solid transparent;
    white-space: nowrap; flex-shrink: 0; transition: color var(--transition);
    outline: none; font-family: var(--font);
}
.admin-tab:hover { color: var(--text-2); }
.admin-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.admin-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 1rem; }
.admin-hint { font-size: 12px; color: var(--text-3); }
.admin-inline-form {
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1rem; margin-bottom: 1rem;
}
.ext-edit-form {
    background: var(--bg); padding: 12px 0;
}
.ext-edit-form textarea {
    resize: vertical; min-height: 60px;
    line-height: 1.5; white-space: pre; overflow-wrap: normal; overflow-x: auto;
}

.admin-user-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px;
    min-height: 52px;
}
.admin-user-info { flex: 1; text-align: left; min-width: 0; }
.admin-user-email { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.admin-user-actions { display: flex; gap: 6px; flex-shrink: 0; }
.admin-user-actions button { background: none; border: 1px solid var(--border); color: var(--text-2); border-radius: 4px; padding: 4px 10px; font-size: 12px; cursor: pointer; min-width: 68px; text-align: center; }
.admin-user-actions button:hover { border-color: var(--border-light); color: var(--text); }
.admin-user-actions .btn-danger { color: var(--danger); }
.admin-user-actions .btn-danger:hover { border-color: var(--danger); }
.inline-select { background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-2); border-radius: 4px; padding: 3px 8px; font-size: 12px; cursor: pointer; }

.admin-model-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; min-height: 44px; }
.admin-model-row .model-name { flex: 1; font-weight: 500; }
.admin-model-row .model-caps-inline { display: flex; gap: 3px; }
.admin-model-row .provider-meta { min-width: 80px; text-align: right; color: var(--text-3); font-size: 12px; }
.admin-model-toggle { background: none; border: 1px solid var(--border); border-radius: 4px; padding: 4px 10px; font-size: 12px; cursor: pointer; color: var(--text-2); min-width: 82px; text-align: center; }
.admin-model-toggle:hover { border-color: var(--accent); color: var(--accent); }
.admin-model-toggle.enabled { border-color: var(--success); color: var(--success); }
.admin-model-toggle.team { border-color: var(--accent); color: var(--accent); }
.model-list-item.model-hidden { opacity: 0.5; }
.model-list-item.model-hidden .model-name { text-decoration: line-through; }

.admin-provider-row {
    display: flex; align-items: center; gap: 12px; padding: 10px 0;
    border-bottom: 1px solid var(--border); font-size: 14px;
}
.admin-provider-row .provider-name { font-weight: 500; flex: 1; }
.admin-provider-row .provider-endpoint { font-size: 12px; color: var(--text-3); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-edit { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 16px; padding: 2px 6px; }
.btn-edit:hover { color: var(--accent); }
.admin-provider-row .btn-delete { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 16px; padding: 2px 6px; }
.admin-provider-row .btn-delete:hover { color: var(--danger); }

.admin-persona-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.admin-persona-row .persona-info { flex: 1; min-width: 0; }
.persona-row-avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; vertical-align: middle; margin-right: 6px; }
.persona-row-icon { margin-right: 4px; }
.admin-persona-row .persona-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.admin-persona-row .persona-desc { font-size: 12px; color: var(--text-2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-persona-row .persona-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.admin-persona-row .btn-delete { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 16px; padding: 2px 6px; }
.admin-persona-row .btn-delete:hover { color: var(--danger); }

/* Stats cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.stat-card {
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 16px; text-align: center;
}
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat-card .stat-label { font-size: 0.78rem; color: var(--text-3); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.04em; }

/* Audit log */
.audit-row { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.audit-row:last-child { border-bottom: none; }
.audit-main { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.audit-action { font-weight: 600; color: var(--accent); font-family: var(--mono); font-size: 12px; }
.audit-actor { color: var(--text); }
.audit-resource { color: var(--text-3); font-family: var(--mono); font-size: 11px; }
.audit-meta { display: flex; gap: 10px; margin-top: 2px; font-size: 11px; color: var(--text-3); flex-wrap: wrap; }
.audit-details { color: var(--text-2); }
.audit-ip { font-family: var(--mono); }
.pagination-row { display: flex; align-items: center; justify-content: center; gap: 12px; }

/* Banner preview */
.banner-preview {
    margin-top: 0.75rem; padding: 6px 16px; text-align: center;
    font-size: 12px; font-weight: 700; letter-spacing: 0.06em;
    border-radius: var(--radius);
}
.color-input-wrap { display: flex; align-items: center; gap: 8px; }
.color-input-wrap input[type="color"] {
    width: 36px; height: 32px; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--bg);
    cursor: pointer; padding: 2px;
}
.color-hex {
    width: 80px; background: var(--bg-raised); border: 1px solid var(--border);
    color: var(--text); padding: 6px 10px; border-radius: var(--radius);
    font-family: var(--mono); font-size: 12px;
}
.section-hint { font-size: 13px; color: var(--text-3); margin-bottom: 0.75rem; }

/* User model list */
.model-list-grid { display: flex; flex-direction: column; gap: 2px; }
.model-list-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border-radius: var(--radius); font-size: 13px; cursor: default;
}
.model-list-item:hover { background: var(--bg-hover); }
.model-list-item .model-name { flex: 1; font-weight: 500; }
.model-list-item .model-provider { font-size: 12px; color: var(--text-3); }
.model-list-item .model-caps-inline { display: flex; gap: 3px; }

.admin-approve-form { padding: 10px 12px; margin: -4px 0 8px; background: var(--glass); border-radius: 0 0 8px 8px; border-top: 1px solid var(--border); }
.admin-approve-form .checkbox-label { display: block; margin: 2px 0; }
.btn-approve { background: var(--success-dim); color: var(--success-light); border: 1px solid rgba(34,197,94,0.3); border-radius: 4px; padding: 3px 10px; cursor: pointer; font-size: 12px; }
.team-card { padding: 8px 10px; background: var(--glass); border-radius: 6px; margin-bottom: 6px; }
.team-card-info { display: flex; align-items: center; gap: 8px; }
.team-admin-back {
    cursor: pointer; margin-right: 4px; opacity: 0.5;
    transition: opacity var(--transition);
}
.team-admin-back:hover { opacity: 1; }
.team-admin-content { flex: 1; flex-direction: column; min-width: 0; }
.team-tab-content { padding: 0; }

/* Health + Routing admin (v0.22.3) */
.admin-health-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.admin-health-card { background: var(--bg-raised); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.list-card { background: var(--bg-raised); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 8px; }
.admin-user-row.user-inactive { opacity: 0.7; }


/* ── Debug Modal — moved to sw-debug.css (v0.37.18) ── */

/* ── Command Palette ─────────────────────── */

.cmd-palette-overlay {
    position: fixed; inset: 0; background: var(--overlay);
    display: none; align-items: flex-start; justify-content: center;
    z-index: 2000; backdrop-filter: blur(4px);
    padding-top: min(20vh, 160px);
}
.cmd-palette-overlay.active { display: flex; }

.cmd-palette {
    background: var(--bg-surface); border: 1px solid var(--border-light);
    border-radius: var(--radius-lg); width: 90%; max-width: 480px;
    box-shadow: 0 16px 64px rgba(0,0,0,0.6);
    animation: modal-in 0.12s ease;
    overflow: hidden;
}

.cmd-input-wrap {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.cmd-input-wrap svg { color: var(--text-3); flex-shrink: 0; }
.cmd-input-wrap input {
    flex: 1; background: none; border: none; color: var(--text);
    font-size: 15px; font-family: var(--font); outline: none;
}
.cmd-input-wrap input::placeholder { color: var(--text-3); }
.cmd-kbd {
    font-size: 10px; font-family: var(--mono); color: var(--text-3);
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 4px; padding: 2px 6px; flex-shrink: 0;
}

.cmd-results {
    max-height: 320px; overflow-y: auto;
    padding: 4px;
}

.cmd-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; border-radius: var(--radius);
    cursor: pointer; font-size: 13px; color: var(--text-2);
    transition: background 60ms ease, color 60ms ease;
}
.cmd-item:hover, .cmd-item.active {
    background: var(--accent-dim); color: var(--text);
}
.cmd-item svg { flex-shrink: 0; color: var(--text-3); }
.cmd-item.active svg { color: var(--accent); }
.cmd-item-label { flex: 1; }
.cmd-item-hint {
    font-size: 11px; color: var(--text-3); flex-shrink: 0;
}
.cmd-item.active .cmd-item-hint { color: var(--accent); }
.cmd-group-label {
    font-size: 10px; font-weight: 600; color: var(--text-3);
    padding: 8px 12px 4px; text-transform: uppercase; letter-spacing: 0.5px;
}

.cmd-footer {
    display: flex; align-items: center; gap: 16px;
    padding: 8px 16px; border-top: 1px solid var(--border);
    font-size: 11px; color: var(--text-3);
}
.cmd-footer kbd {
    font-size: 10px; font-family: var(--mono);
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 3px; padding: 1px 4px;
}


/* ── Confirm Dialog ──────────────────────── */

.confirm-overlay {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    background: var(--overlay);
    animation: fade-in 0.12s ease;
}
.confirm-dialog {
    background: var(--bg-raised); border: 1px solid var(--border-light);
    border-radius: var(--radius-lg); padding: 0;
    min-width: 320px; max-width: 440px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    animation: confirm-in 0.15s ease;
}
.confirm-header {
    padding: 16px 20px 0; font-weight: 600; font-size: 15px; color: var(--text);
}
.confirm-body {
    padding: 12px 20px 20px; font-size: 13px; color: var(--text-2);
    line-height: 1.5; white-space: pre-wrap;
}
.confirm-footer {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 0 20px 16px;
}
@keyframes confirm-in { from { opacity: 0; transform: scale(0.95); } }
@keyframes fade-in { from { opacity: 0; } }

/* ── Group Chat persona picker (v0.23.0) ────── */
.group-persona-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px; border-radius: var(--radius);
    cursor: pointer; font-size: 13px;
    transition: background 0.1s;
}
.group-persona-item:hover { background: var(--bg-hover); }
.group-persona-item input[type="checkbox"] { accent-color: var(--accent); flex-shrink: 0; }
.group-persona-name { flex: 1; color: var(--text); font-weight: 500; }
.group-persona-model { font-size: 11px; color: var(--text-3); font-family: var(--mono); }
.chain-typing-name { font-size: 11px; font-weight: 600; color: var(--accent); margin-right: 6px; }

/* ── Creation Dialog (project / channel / folder — v0.23.1) ── */
.sb-dialog-overlay {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    background: var(--overlay);
    animation: fade-in 0.12s ease;
}
.sb-dialog {
    background: var(--bg-raised); border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 20px 22px 16px;
    min-width: 300px; max-width: 420px; width: 90vw;
    display: flex; flex-direction: column; gap: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    animation: confirm-in 0.15s ease;
}
.sb-dialog-title { font-size: 14px; font-weight: 600; color: var(--text); }
.sb-dialog-input {
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 8px 10px;
    font-size: 13px; color: var(--text);
    font-family: inherit; outline: none; width: 100%; box-sizing: border-box;
}
.sb-dialog-input:focus { border-color: var(--accent); }
.sb-dialog-color-row { display: flex; align-items: center; gap: 10px; }
.sb-dialog-color-label { font-size: 12px; color: var(--text-2); }
.sb-dialog-color-input { width: 32px; height: 26px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; padding: 1px; background: none; }
.sb-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
