/* Sidebar and the session history panel.
   Split out of console.css; see channel/web/README.md for the
   load order, which is load-bearing. */

/* Sidebar */
.sidebar-item.active {
    background: rgba(255, 255, 255, 0.08);
    color: #FFFFFF;
}
.sidebar-item.active .item-icon { color: #4ABE6E; }

/* Session Panel */
.session-panel {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: #fafafa;
    border-right: 1px solid #e5e7eb;
    height: 100vh;
    overflow: hidden;
    transition: width 0.2s ease;
}
.dark .session-panel {
    background: #111111;
    border-right-color: rgba(255, 255, 255, 0.08);
}
.session-panel.hidden { display: none; }
.session-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Match the chat header height (h-14 = 56px) so both top bars align. */
    height: 56px;
    padding: 0 16px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}
.dark .session-panel-header { border-bottom-color: rgba(255, 255, 255, 0.08); }
.session-panel-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}
.dark .session-panel-title { color: #d1d5db; }
.session-panel-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: none;
    background: none;
    color: #9ca3af;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-size: 12px;
}
.session-panel-close:hover {
    background: #f3f4f6;
    color: #374151;
}
.dark .session-panel-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #e5e5e5;
}
.session-panel-new {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 12px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px dashed #d1d5db;
    background: none;
    color: #6b7280;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    flex-shrink: 0;
}
.session-panel-new:hover {
    border-color: #9ca3af;
    color: #374151;
    background: #f9fafb;
}
.dark .session-panel-new {
    border-color: rgba(255, 255, 255, 0.12);
    color: #9ca3af;
}
.dark .session-panel-new:hover {
    border-color: rgba(255, 255, 255, 0.25);
    color: #e5e5e5;
    background: rgba(255, 255, 255, 0.04);
}
.session-panel-new-wrap { position: relative; flex-shrink: 0; }
.session-panel-new-wrap .session-panel-new { width: calc(100% - 24px); }
.new-chat-caret { margin-left: auto; font-size: 10px; opacity: .7; }
.new-chat-menu {
    position: absolute; left: 12px; right: 12px; top: calc(100% - 2px);
    z-index: 70; padding: 6px;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
    box-shadow: 0 16px 40px -12px rgba(0,0,0,.28);
}
.dark .new-chat-menu { background: #1A1A1A; border-color: rgba(255,255,255,.1); }
.new-chat-menu.hidden { display: none; }
.new-chat-section { display: flex; flex-direction: column; }
.new-chat-item {
    display: flex; align-items: center; gap: 9px;
    padding: 7px 9px; border-radius: 8px;
    font-size: 13px; color: #334155; cursor: pointer; background: none; border: none;
    text-align: left; width: 100%;
}
.new-chat-item:hover { background: #EDFDF3; color: #228547; }
.dark .new-chat-item { color: #cbd5e1; }
.dark .new-chat-item:hover { background: rgba(74,190,110,.14); color: #6EE7A0; }
.new-chat-item .agent-avatar { flex-shrink: 0; }
.new-chat-sep { height: 1px; background: #f1f5f9; margin: 5px 4px; }
.dark .new-chat-sep { background: rgba(255,255,255,.07); }
.new-chat-team-ico {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 50%;
    background: #EDFDF3; color: #17803d; font-size: 11px; flex-shrink: 0;
}
.dark .new-chat-team-ico { background: rgba(74,190,110,.16); color: #6EE7A0; }

/* Team-chat picker rows in the modal */
.team-chat-list-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px;
}
.team-chat-list-label {
    font-size: 12px; font-weight: 600; color: #94a3b8;
    text-transform: uppercase; letter-spacing: 0.03em;
}
.team-chat-list { display: flex; flex-direction: column; gap: 6px; }
.team-chat-row {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 11px; border-radius: 10px;
    border: 1px solid #e2e8f0; background: #f8fafc;
    cursor: pointer; text-align: left; width: 100%;
    transition: border-color .15s, background .15s;
}
.team-chat-row .agent-avatar { flex-shrink: 0; }
.team-chat-row:hover { border-color: #cbd5e1; }
.team-chat-row.on { border-color: #4ABE6E; background: #EDFDF3; }
.dark .team-chat-row { border-color: rgba(255,255,255,.1); background: rgba(255,255,255,.04); }
.dark .team-chat-row.on { border-color: #4ABE6E; background: rgba(74,190,110,.12); }
.team-chat-name { font-size: 14px; color: #1e293b; }
.dark .team-chat-name { color: #f1f5f9; }
.team-chat-owner {
    font-size: 10px; padding: 1px 7px; border-radius: 999px;
    background: #4ABE6E; color: #fff; font-weight: 500;
}
.team-chat-check { margin-left: auto; color: #cbd5e1; font-size: 16px; }
.team-chat-row.on .team-chat-check { color: #4ABE6E; }

/* Session List */
.session-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
    scrollbar-width: none;
}
.session-list:hover { scrollbar-width: thin; }
.session-list::-webkit-scrollbar { width: 4px; background: transparent; }
.session-list::-webkit-scrollbar-thumb { background: transparent; border-radius: 2px; }
.session-list:hover::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); }
.dark .session-list:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }
.session-group-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 8px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
}
/* Project / pinned headers carry an icon; date headers stay plain text. */
.session-group-label i { font-size: 10px; flex-shrink: 0; }
.session-group-label span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dark .session-group-label { color: #525252; }

/* Collapsible, draggable project group header. Deliberately styled unlike the
   date headers and session rows: normal-case, larger and darker, so a project
   reads as a real section title rather than a faint label. */
.session-group-project {
    position: relative;
    cursor: pointer;
    border-radius: 6px;
    margin-top: 4px;
    padding: 6px 8px;
    transition: background 0.12s ease;
    user-select: none;
    text-transform: none;
    letter-spacing: 0;
    font-size: 12px;
    font-weight: 600;
    color: #9ca3af;
}
.dark .session-group-project { color: #8a8a8a; }
.session-group-project:hover { background: rgba(148, 163, 184, 0.12); }
.session-group-project.dragging { opacity: 0.5; }
.session-group-project.drop-target { box-shadow: inset 0 2px 0 0 #4ABE6E; }
.session-group-caret {
    transition: transform 0.15s ease;
    font-size: 9px !important;
    width: 10px;
    text-align: center;
    opacity: 0.6;
}
.session-group-caret.collapsed { transform: rotate(-90deg); }
.session-group-icon { font-size: 11px !important; }
/* Name takes the remaining width (and truncates), which pushes the count to a
   consistent right edge across projects and the default space. */
.session-group-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-transform: none;
}
/* Count always sits flush right (margin-left:auto), so it lines up across every
   project and the default space regardless of name length. */
.session-group-count {
    margin-left: auto;
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 500;
    color: #9ca3af;
    opacity: 0.8;
}
/* Actions overlay the right edge (absolute, out of flow) so they never shift
   the count's position; they only appear on hover, replacing the count. */
.session-group-actions {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.12s ease;
}
.session-group-project:hover .session-group-actions { opacity: 1; }
.session-group-project:hover .session-group-count { visibility: hidden; }
.session-group-action {
    border: none;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 5px;
    font-size: 10px;
    line-height: 1;
}
.session-group-action:hover { background: rgba(74, 190, 110, 0.16); color: #35A85B; }
.dark .session-group-action:hover { background: rgba(74, 190, 110, 0.2); color: #6EE7A0; }

.prompt-modal-input {
    width: 100%;
    margin: 14px 0 4px;
    padding: 9px 12px;
    border: 1px solid #E2E8F0;
    border-radius: 9px;
    font-size: 14px;
    color: #1e293b;
    background: #fff;
    outline: none;
    box-sizing: border-box;
}
.prompt-modal-input:focus { border-color: #4ABE6E; }
.dark .prompt-modal-input {
    background: #1A1A1A;
    border-color: rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
}

.session-empty {
    padding: 20px 12px;
    text-align: center;
    font-size: 13px;
    color: #9ca3af;
}
.session-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin: 1px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    color: #6b7280;
    font-size: 13px;
    position: relative;
}
.dark .session-item { color: #a3a3a3; }
.session-item:hover {
    background: #f3f4f6;
    color: #111827;
}
.dark .session-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #e5e5e5;
}
.session-item.active {
    background: #e5e7eb;
    color: #111827;
}
.dark .session-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}
.session-icon {
    flex-shrink: 0;
    font-size: 11px;
    color: #9ca3af;
    width: 16px;
    text-align: center;
}
.dark .session-icon { color: #525252; }
.session-item.active .session-icon { color: #4ABE6E; }
.session-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    /* Breathing room at rest so the title doesn't run flush to the edge; the
       gap collapses on hover when the action buttons take that space. */
    padding-right: 20px;
}
.session-item:hover .session-title { padding-right: 0; }
/* Under a multi-project list, sessions indent so their leading icon lines up
   with the folder icon of the project header above them. The session icon sits
   in a centered 16px box, so it needs a touch less left padding than the raw
   folder-icon offset (24px) to visually align. */
.session-item-indent { padding-left: 21px; }
.session-delete {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    font-size: 10px;
    color: #9ca3af;
    transition: color 0.15s, background 0.15s;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}
.session-item:hover .session-delete { display: flex; }
.session-delete:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}
.dark .session-delete:hover { background: rgba(239, 68, 68, 0.15); }

/* Rename button: shares the look of the delete button, sits to its left.
   Negative right margin tightens the gap to the delete button only. */
.session-rename {
    flex-shrink: 0;
    margin-right: -6px;
    width: 22px;
    height: 22px;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #9ca3af;
    font-size: 11px;
    transition: color 0.15s, background 0.15s;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}
.session-item:hover .session-rename { display: flex; }
.session-rename:hover {
    color: #4ABE6E;
    background: rgba(74, 190, 110, 0.12);
}
.dark .session-rename:hover { background: rgba(74, 190, 110, 0.18); }

/* Pin button: same affordance as rename, and the pinned state stays visible
   after the cursor leaves so the row explains its own position in the list. */
.session-pin {
    flex-shrink: 0;
    margin-right: -6px;
    width: 22px;
    height: 22px;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #9ca3af;
    font-size: 10px;
    transition: color 0.15s, background 0.15s;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}
.session-item:hover .session-pin { display: flex; }
.session-pin:hover {
    color: #4ABE6E;
    background: rgba(74, 190, 110, 0.12);
}
.dark .session-pin:hover { background: rgba(74, 190, 110, 0.18); }
/* A pinned row already shows a pin as its leading icon, so on hover the button
   turns into "unpin" and the leading icon is what carries the state. */
.session-item.pinned .session-icon { color: #4ABE6E; transform: rotate(45deg); }
.session-item.pinned .session-pin { color: #4ABE6E; }
.session-item.pinned .session-pin:hover { color: #ef4444; background: rgba(239, 68, 68, 0.1); }

/* Inline title editor */
.session-title-input {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-family: inherit;
    color: #111827;
    background: #ffffff;
    border: 1px solid #4ABE6E;
    border-radius: 6px;
    padding: 2px 6px;
    outline: none;
}
.dark .session-title-input {
    color: #e5e5e5;
    background: rgba(255, 255, 255, 0.06);
    border-color: #4ABE6E;
}

/* Context Divider */
.context-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: #9ca3af;
}
.context-divider::before, .context-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, #d1d5db, transparent);
}
.dark .context-divider::before, .dark .context-divider::after {
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.12), transparent);
}
.context-divider span {
    font-size: 12px;
    white-space: nowrap;
    color: #9ca3af;
}

/* Session panel overlay (mobile only, click to close) */
.session-panel-overlay {
    display: none;
}
@media (max-width: 768px) {
    .session-panel-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 44;
        background: rgba(0, 0, 0, 0.3);
    }
    .session-panel-overlay.hidden {
        display: none;
    }
}

/* Mobile: session panel as overlay */
@media (max-width: 768px) {
    .session-panel {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 45;
        width: 220px;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }
    .dark .session-panel {
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }
}

