/* ============================================================
   Session — Session list, dots, tooltips, session header/view
   ============================================================ */

/* ── Session List ──────────────────────────────────────────── */

.session-list {
    list-style: none;
}

.session-list li {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    align-items: flex-start;
    gap: 8px;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

#history-sessions-list li {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.session-row-top {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}

.session-row-mid {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-row-bottom {
    margin-top: 1px;
}

.session-list li:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.session-list li:hover:not(.empty-state):not(.session-group-header) {
    box-shadow: inset 0 0 0 1px rgba(88, 166, 255, 0.06);
}

.session-list li.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-left: 2px solid var(--accent);
}

.session-list li.empty-state {
    cursor: default;
    color: var(--text-muted);
    font-style: italic;
}

.session-list li.empty-state:hover {
    background: transparent;
    color: var(--text-muted);
}

/* Duration badge in sidebar items */
.session-dur {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: 4px;
}

/* ── Session Dots ──────────────────────────────────────────── */

.session-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
}

.session-dot.stale    { background: var(--text-muted); }
.session-dot.sleeping { background: var(--warning); opacity: 0.5; }
.session-dot.working {
    background: #3b82f6;
    animation: pulse-working 1.5s ease-in-out infinite;
}
.session-dot.waiting {
    background: var(--warning);
    animation: pulse-waiting 1.5s ease-in-out infinite;
}
.session-dot.done {
    background: var(--success, #4caf50);
}
.session-dot.stuck {
    background: var(--danger, #ef4444);
    animation: pulse-stuck 3s ease-in-out infinite;
}

/* ── Session Hover Tooltip ─────────────────────────────────── */

.session-tooltip {
    display: none;
    position: fixed;
    z-index: 1000;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 10px 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    min-width: 220px;
    max-width: 400px;
}

.session-tooltip-table {
    border-collapse: collapse;
    font-size: 12px;
    line-height: 1.5;
}

.session-tooltip-table td {
    padding: 1px 0;
}

.tt-label {
    color: var(--text-muted);
    padding-right: 12px;
    font-weight: 500;
}

.tt-value {
    color: var(--text-primary);
    max-width: 300px;
    word-break: break-word;
}

.tt-state-working           { color: #3b82f6; font-weight: 600; }
.tt-state-needs-input       { color: var(--warning); font-weight: 600; }
.tt-state-done              { color: var(--success); font-weight: 600; }
.tt-state-stuck             { color: var(--danger, #ef4444); font-weight: 600; }
.tt-state-idle              { color: var(--text-muted); }
.tt-unread                   { color: var(--warning); font-weight: 600; }

.session-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.session-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.session-name-row {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.session-name-spacer {
    flex: 1;
}

.session-goal {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 3px;
}

.generate-goal-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 11px;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.generate-goal-link:hover {
    opacity: 1;
    text-decoration: underline;
}

/* ── Sidebar Kebab Menu ───────────────────────────────────── */

.sidebar-kebab-wrapper {
    position: relative;
    flex-shrink: 0;
}

.sidebar-kebab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 2px 4px;
    border-radius: 3px;
    line-height: 1;
    font-weight: bold;
    letter-spacing: 1px;
    opacity: 0;
    transition: opacity 0.1s;
}

.sidebar-kebab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.session-list li:hover .sidebar-kebab-btn {
    opacity: 1;
}

.sidebar-kebab-menu {
    position: fixed;
    z-index: 1100;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 4px 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    min-width: 160px;
}

/* ── Board Card Groups ─────────────────────────────────────── */

.session-board-card {
    border: 1px solid var(--border) !important;
    border-left: 3px solid var(--accent) !important;
    border-radius: 8px !important;
    background: rgba(255, 255, 255, 0.02) !important;
    margin: 4px 8px !important;
    padding: 0 !important;
    display: block !important;
    cursor: default !important;
}

.session-board-card.session-board-card-toplevel {
    border-left-width: 4px !important;
    margin: 6px 8px 6px 0 !important;
}

.session-board-card.team-sleeping .group-header-text,
.session-board-card.team-sleeping .group-chevron,
.session-board-card.team-sleeping .group-board-link,
.session-board-card.team-sleeping .board-card-agents {
    opacity: 0.6;
}

.board-card-folder-footer {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px 6px 22px;
    font-size: 10px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    opacity: 0.7;
    height: 24px;
    box-sizing: border-box;
}

.board-card-folder-path {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.board-card-folder-footer .folder-copy-btn {
    flex-shrink: 0;
    display: none;
    padding: 0 2px;
    line-height: 1;
}

.board-card-folder-footer:hover .folder-copy-btn {
    display: inline-flex;
    align-items: center;
}

.agent-folder-path {
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0.7;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: rtl;
    text-align: left;
}

.session-board-card:hover {
    background: rgba(255, 255, 255, 0.02) !important;
    box-shadow: none !important;
}

.board-card-header {
    padding: 10px 16px 10px 10px !important;
    margin: 0;
    border-radius: 7px 7px 0 0;
    font-size: 11px;
    min-height: 46px;
    box-sizing: border-box;
}

.session-board-card-toplevel .board-card-header .group-name-line {
    font-size: 14px;
    font-weight: 600;
}

.board-card-subline {
    font-size: 9px;
    font-weight: 400;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0;
    display: flex;
    align-items: center;
    gap: 3px;
    margin-top: 1px;
}

.board-card-agents {
    list-style: none;
    padding: 0;
    margin: 0;
}

.board-card-agents .session-group-item {
    padding-left: 22px !important;
}

.board-card-collapsed {
    display: none;
}

.session-compact {
    /* Same as regular agent rows — no size reduction */
}

.group-board-link {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    line-height: 1;
    flex-shrink: 0;
}

.group-board-link:hover {
    color: var(--accent);
    background: var(--bg-hover);
}

/* ── Grouped Sessions ──────────────────────────────────────── */

.session-group-header {
    font-size: 9px;
    font-weight: 500;
    color: var(--text-muted);
    padding: 4px 16px !important;
    text-transform: none;
    letter-spacing: 0.02em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.session-group-header:hover {
    background: rgba(255, 255, 255, 0.03) !important;
}

.group-header-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.group-name-line {
    display: flex;
    align-items: center;
    gap: 4px;
}

.group-branch-line {
    font-size: 8px;
    font-weight: 400;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0;
    display: flex;
    align-items: center;
    gap: 2px;
    margin-top: 1px;
    font-family: var(--font-mono);
}

.group-chevron {
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
    width: 10px;
}

.group-kebab .sidebar-kebab-btn {
    font-size: 13px;
    padding: 1px 3px;
    opacity: 0;
    align-self: center;
}

.group-kebab {
    align-self: center;
}

.session-group-header:hover .group-kebab .sidebar-kebab-btn {
    opacity: 1;
}

.session-group-item.group-collapsed {
    display: none !important;
}

/* ── Terminal icon in sidebar ─────────────────────────────── */

.terminal-icon {
    vertical-align: -1px;
    opacity: 0.7;
    flex-shrink: 0;
}

.orch-icon {
    vertical-align: -1px;
    flex-shrink: 0;
}

.agent-icon {
    font-size: 13px;
    vertical-align: middle;
}

.session-group-count {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 0 5px;
    line-height: 16px;
}

.session-group-name {
    display: flex;
    align-items: center;
    gap: 6px;
}

.folder-tag-full {
    font-size: 9px;
    font-weight: 500;
    color: #fff;
    padding: 1px 6px;
    border-radius: 8px;
    line-height: 14px;
    white-space: nowrap;
    text-transform: none;
    letter-spacing: 0;
}

.session-group-spacer {
    flex: 1;
}

.folder-copy-btn {
    display: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 2px 4px;
    border-radius: 3px;
    background: none;
    border: none;
    line-height: 1;
    flex-shrink: 0;
    align-self: center;
}

.folder-copy-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.session-group-header:hover .folder-copy-btn {
    display: inline-flex;
    align-items: center;
}

.session-group-item {
    padding-left: 33px !important;
    cursor: grab;
    min-height: 46px;
}

.session-group-item.dragging {
    opacity: 0.4;
    cursor: grabbing;
}

.session-group-item.drag-over {
    border-top: 2px solid var(--accent-primary, #58a6ff);
    margin-top: -2px;
}

/* ── Session View ──────────────────────────────────────────── */

.session-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.session-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.session-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.session-title-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
}

.session-title-actions .btn-icon-label {
    margin: 0;
}

.session-title-actions .actions-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
    flex-shrink: 0;
}

.session-title h2 {
    font-size: 16px;
    font-weight: 600;
}

.session-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.session-meta-compact {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.meta-separator {
    color: var(--text-muted);
    font-size: 14px;
}

.status-line, .summary-line {
    font-size: 13px;
    color: var(--text-secondary);
}

.summary-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    white-space: nowrap;
}

.goal-label {
    font-size: 15px;
    font-weight: 600;
    color: #bc8cff;
    flex-shrink: 0;
}

.summary-inline .summary-text {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.goal-action-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.goal-action-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.goal-edit-input {
    flex: 1;
    min-width: 0;
    background: var(--bg-primary);
    border: 1px solid var(--accent);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    padding: 2px 8px;
    outline: none;
}

.branch-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    background: rgba(88, 166, 255, 0.1);
    border: 1px solid rgba(88, 166, 255, 0.2);
    border-radius: 12px;
    font-size: 12px;
    color: var(--accent);
    font-family: var(--font-mono);
}

.branch-chip svg {
    flex-shrink: 0;
    color: var(--accent);
}

.copy-branch-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    margin-left: 2px;
    vertical-align: middle;
    opacity: 0.5;
    transition: opacity 0.15s;
}

.copy-branch-btn:hover {
    opacity: 1;
    color: var(--accent);
}

.sidebar-branch {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-top: 1px;
}

.sidebar-branch svg {
    flex-shrink: 0;
    opacity: 0.7;
}

/* ── Status Dots ───────────────────────────────────────────── */

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    background: var(--success);
}

.status-dot.working {
    background: #3b82f6;
    animation: pulse-working 1.5s ease-in-out infinite;
}

.status-dot.waiting {
    background: var(--warning);
    animation: pulse-waiting 1.5s ease-in-out infinite;
}

.status-dot.done {
    background: var(--success, #4caf50);
}

.status-dot.stuck {
    background: var(--danger, #ef4444);
    animation: pulse-stuck 3s ease-in-out infinite;
}

.status-dot-stale {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--fg-muted);
    flex-shrink: 0;
}

.status-dot-working {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse-working 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

/* ── Waiting / Done Banners ────────────────────────────────── */

.waiting-banner {
    display: none;
    background: rgba(255, 193, 7, 0.15);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 6px;
    padding: 6px 12px;
    margin: 0 12px 8px;
    font-size: 13px;
    color: var(--warning);
    text-align: center;
}

.waiting-banner.done-banner {
    background: rgba(76, 175, 80, 0.15);
    border-color: rgba(76, 175, 80, 0.3);
    color: var(--success, #4caf50);
}

/* ── Session ID Label ──────────────────────────────────────── */

.session-id-label {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

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

.live-job-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: 12px;
}

.live-job-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--fg);
}

.live-job-badge {
    font-size: 9px;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 3px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.live-job-badge-api {
    background: rgba(136, 87, 229, 0.2);
    color: #b392f0;
}

.live-job-badge-cron {
    background: rgba(88, 166, 255, 0.2);
    color: #58a6ff;
}

.live-job-elapsed {
    font-size: 10px;
    color: var(--fg-muted);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}
