/* ── layout.css ──────────────────────────────
   App shell, workspace, sidebar, responsive
   ──────────────────────────────────────────── */

/* ── App Shell ───────────────────────────── */

.app { display: flex; height: 100%; flex-direction: column; }
.app-body { display: flex; flex: 1; min-height: 0; }

/* ── Workspace (everything right of sidebar) ── */

.workspace {
    display: flex; flex: 1; min-width: 0; min-height: 0;
    overflow: hidden; position: relative;
}
.workspace-pane { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.workspace-primary { flex: 1; min-width: 0; background: var(--bg); }
.workspace-secondary {
    width: 0; min-width: 0; overflow: hidden;
    background: var(--bg); border-left: 1px solid var(--border);
    transition: width 0.25s ease, min-width 0.25s ease;
}
.workspace-secondary.open {
    width: 480px; min-width: 480px;
}
.workspace-secondary.fullscreen {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: 100% !important; min-width: 100% !important;
    z-index: 100; transition: none;
}
.workspace-handle {
    width: 0; flex-shrink: 0; position: relative; z-index: 10;
}
.workspace-handle.active {
    width: 6px; cursor: col-resize;
}
.workspace-handle.active::after {
    content: ''; position: absolute; inset: 0;
    transition: background 0.15s;
}
.workspace-handle.active:hover::after { background: var(--accent); opacity: 0.3; }
.workspace-secondary.fullscreen ~ .workspace-handle { display: none; }

/* ── Environment Banners ──────────────────── */

.banner {
    display: none;
    width: 100%; text-align: center;
    font-size: 12px; font-weight: 700; letter-spacing: 1px;
    text-transform: uppercase;
    padding: 2px 0; line-height: 1.4;
    background: var(--banner-bg); color: var(--banner-fg);
    flex-shrink: 0; z-index: 9999;
    min-height: 22px; box-sizing: border-box;
}
.banner.active { display: flex; align-items: center; justify-content: center; }
.banner-top { order: -1; }
.banner-bottom { order: 999; }

/* ── Sidebar ─────────────────────────────── */

.sidebar {
    width: var(--sidebar-w); background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    transition: width var(--transition);
    overflow: hidden; flex-shrink: 0;
}
.sidebar.collapsed { width: var(--sidebar-rail); }

.sidebar-top {
    display: flex; flex-direction: column; gap: 2px;
    padding: 10px 10px 6px;
    border-bottom: 1px solid var(--border);
}

/* Brand / collapse toggle */
.sb-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--radius);
    background: none; border: none; color: var(--text);
    cursor: pointer; font-size: 13px; white-space: nowrap;
    transition: background var(--transition); width: 100%;
    position: relative;
}
.sb-brand:hover { background: var(--bg-hover); }
.sb-logo { flex-shrink: 0; font-size: 18px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.sb-logo img, .sb-logo .brand-logo-img { width: 22px; height: 22px; object-fit: contain; border-radius: 3px; }
.brand-collapse { display: none; }
.brand-text { font-weight: 600; font-size: 14px; }

.sb-btn {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--radius);
    background: none; border: none; color: var(--text-2);
    cursor: pointer; font-size: 13px; white-space: nowrap;
    transition: background var(--transition), color var(--transition);
    width: 100%;
}
.sb-btn:hover { background: var(--bg-hover); color: var(--text); }
.sb-btn svg { flex-shrink: 0; }
/* Sidebar toggle: hidden on desktop (brand click handles collapse) */
.sidebar-toggle { display: none; }
.sb-label { overflow: hidden; transition: opacity var(--transition); }
.sidebar.collapsed .sb-label { opacity: 0; width: 0; }
.sidebar.collapsed .brand-text { opacity: 0; width: 0; }

/* Collapsed centering */
.sidebar.collapsed .sidebar-top { padding: 10px 0 8px; align-items: center; }
.sidebar.collapsed .sidebar-bottom { padding: 8px 0; display: flex; flex-direction: column; align-items: center; }
.sidebar.collapsed .sb-brand { justify-content: center; padding: 8px 0; gap: 0; }
.sidebar.collapsed .sb-btn { justify-content: center; padding: 8px 0; gap: 0; }
.sidebar.collapsed .split-btn-main { justify-content: center; padding: 8px 0; gap: 0; }
.sidebar.collapsed .user-btn { justify-content: center; padding: 6px 0; gap: 0; }
.sidebar.collapsed .avatar-bug { display: none; }

/* Split button (New Chat + dropdown) */
.split-btn { display: flex; width: 100%; gap: 0; position: relative; }
.split-btn-main {
    flex: 1; display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--radius) 0 0 var(--radius);
    background: none; border: none; color: var(--text-2);
    cursor: pointer; font-size: 13px; white-space: nowrap;
    transition: background var(--transition), color var(--transition);
}
.split-btn-main:hover { background: var(--bg-hover); color: var(--text); }
.split-btn-main svg { flex-shrink: 0; }

.split-btn-drop {
    display: flex; align-items: center; padding: 8px 6px;
    border-radius: 0 var(--radius) var(--radius) 0;
    background: none; border: none; border-left: 1px solid var(--border);
    color: var(--text-3); cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.split-btn-drop:hover { background: var(--bg-hover); color: var(--text); }
.sidebar.collapsed .split-btn-drop { display: none; }

/* Dropdown menu */
.split-dropdown {
    display: none; position: absolute; left: 6px; right: 6px;
    top: 100%; z-index: 200;
    background: var(--bg-raised); border: 1px solid var(--border-light);
    border-radius: var(--radius); padding: 4px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.split-dropdown.open { display: block; }
.split-dropdown-item {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 10px; border-radius: 4px; width: 100%;
    background: none; border: none; color: var(--text-2);
    cursor: pointer; font-size: 12px; white-space: nowrap;
    transition: background var(--transition), color var(--transition);
}
.split-dropdown-item:hover { background: var(--bg-hover); color: var(--text); }
.split-dropdown-item.disabled { opacity: 0.4; pointer-events: none; }
.split-dropdown-item .dd-hint {
    margin-left: auto; font-size: 10px; color: var(--text-3);
}


.user-btn {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 8px; border-radius: var(--radius);
    background: none; border: none; color: var(--text);
    cursor: pointer; width: 100%;
    transition: background var(--transition);
}
.user-btn:hover { background: var(--bg-hover); }

.user-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--accent-dim); display: flex; align-items: center;
    justify-content: center; font-size: 13px; font-weight: 600;
    color: var(--accent); flex-shrink: 0; position: relative;
    overflow: hidden;
}
.user-avatar-img {
    width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}
.avatar-bug {
    position: absolute; bottom: -3px; right: -3px;
    font-size: 10px; line-height: 1;
    display: none;
    transition: filter var(--transition);
}
.avatar-bug.has-errors {
    display: block;
    filter: drop-shadow(0 0 4px var(--danger));
    animation: bug-pulse 1.5s ease infinite;
}
@keyframes bug-pulse { 0%,100% { filter: drop-shadow(0 0 3px var(--danger)); } 50% { filter: drop-shadow(0 0 8px var(--danger)); } }
.user-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Flyout styles moved to primitives.css (.sw-menu-flyout) — v0.31.1 */


/* ── Sidebar Tabs (v0.21.6) ──────────── */

.sidebar-tabs {
    display: flex; padding: 0 8px; gap: 0;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.sidebar-tab {
    flex: 1; padding: 6px 0; font-size: 12px; font-weight: 500;
    background: none; border: none; border-bottom: 2px solid transparent;
    color: var(--text-3); cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.sidebar-tab:hover { color: var(--text-2); }
.sidebar-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.sidebar.collapsed .sidebar-tabs { display: none; }
.sidebar-tab-panel { flex: 1; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; }
.sidebar-files-panel { padding: 0; }


/* ── Sidebar Search ──────────────────────── */

.sidebar-search {
    display: flex; align-items: center; gap: 7px;
    padding: 6px 10px; margin: 8px 10px 4px;
    background: var(--input-bg); border: 1px solid var(--border);
    border-radius: var(--radius); transition: border-color var(--transition);
}
.sidebar-search:focus-within { border-color: var(--accent); }
.sidebar-search svg { color: var(--text-3); flex-shrink: 0; }
.sidebar-search input {
    flex: 1; background: none; border: none; color: var(--text);
    font-size: 12px; font-family: var(--font); outline: none;
    min-width: 0;
}
.sidebar-search input::placeholder { color: var(--text-3); }
.sidebar-search-clear {
    background: none; border: none; color: var(--text-3); cursor: pointer;
    font-size: 11px; padding: 2px 4px; border-radius: 4px;
    transition: color var(--transition); display: none;
}
.sidebar-search-clear:hover { color: var(--text); }
.sidebar-search.has-value .sidebar-search-clear { display: block; }
.sidebar.collapsed .sidebar-search { display: none; }

.sidebar-search-empty {
    color: var(--text-3); font-size: 12px; text-align: center;
    padding: 1.5rem 0.5rem;
}


/* ── Responsive ──────────────────────────── */

.mobile-menu-btn {
    display: none; align-items: center; justify-content: center;
    background: none; border: none; color: var(--text-2);
    cursor: pointer; padding: 4px; border-radius: var(--radius);
    transition: color var(--transition);
}
.mobile-menu-btn:hover { color: var(--text); }
.sidebar-overlay {
    display: none; position: fixed; inset: 0; z-index: 99;
    background: var(--overlay);
}

@media (max-width: 768px) {
    .sidebar { position: fixed; z-index: 100; height: 100%; transition: width 0.2s ease; }
    .sidebar.collapsed { width: 0; border: none; overflow: hidden; }
    .msg-inner { padding: 0 1rem; }
    .model-caps { display: none; }
    .input-area { padding: 0 0.5rem 0.5rem; }
    .input-wrap textarea { font-size: 16px; } /* prevent iOS zoom */
    .mobile-menu-btn { display: flex; }
    .modal-overlay { padding: 0.75rem; }
    .modal { width: 100%; }
    .tab-arrow { width: 36px; font-size: 20px; } /* larger touch target */
    .modal-tabs { padding: 0 12px; }
    .admin-sidebar { width: 48px; padding: 0.5rem 0; }
    .admin-sidebar button { padding: 8px 0; text-align: center; font-size: 11px; border-left: none; border-bottom: 2px solid transparent; }
    .admin-sidebar button.active { border-bottom-color: var(--accent); border-left: none; }
    .admin-main { padding: 1rem; }
    .admin-cat { padding: 10px 12px; font-size: 13px; }
}

