/* tabs.css — Session tab bar, tab items, overflow dropdown, tab actions */

/* Session Tabs Bar */
.session-tabs-bar {
    background-color: var(--surface-secondary);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    min-height: 40px;
    position: relative;
    overflow: visible; /* Ensure dropdown can overflow */
}

.tabs-section {
    display: flex;
    align-items: center;
    flex: 1;
    overflow-x: auto;
    overflow-y: visible; /* Allow dropdown to overflow vertically */
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.tabs-section::-webkit-scrollbar {
    height: 4px;
}

.tabs-section::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 2px;
}

.tabs-container {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 0;
}

.session-tab {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0 12px 0 0;
    background-color: var(--surface-tertiary);
    border: 1px solid var(--border-default);
    border-radius: 6px 6px 0 0;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--duration-normal, 200ms) var(--ease-default, cubic-bezier(0.4, 0, 0.2, 1));
    min-width: 150px;
    max-width: 240px;
    position: relative;
    user-select: none;
    height: 36px;
    overflow: hidden;
}

.session-tab:hover {
    background-color: var(--surface-primary);
    color: var(--text-primary);
}

.session-tab.active {
    background-color: var(--surface-primary);
    color: var(--text-primary);
    border-bottom-color: var(--surface-primary);
}

/* Accent bottom highlight for active tab */
.session-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--accent-default);
}

/* Left-border status indicator (replaces old dot) */
.tab-status-border {
    width: 3px;
    align-self: stretch;
    flex-shrink: 0;
    border-radius: 3px 0 0 0;
    transition: background-color var(--duration-normal, 200ms) var(--ease-default, cubic-bezier(0.4, 0, 0.2, 1));
    background-color: transparent;
}

.tab-status-border.active {
    background-color: var(--status-success);
}

.tab-status-border.idle {
    background-color: var(--status-info);
}

.tab-status-border.disconnected,
.tab-status-border.error {
    background-color: var(--status-error);
}

.tab-status-border.unread {
    background-color: var(--status-info) !important;
    animation: unread-border-pulse 1.5s infinite;
}

.tab-status-border.pulse {
    animation: border-pulse 2s infinite;
}

@keyframes border-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes unread-border-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Tool type badge */
.tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 18px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-inverse, #fff);
    flex-shrink: 0;
    line-height: 1;
}

/* Per-tool badge background (token-backed brand colors, shared with tool cards) */
.tab-badge[data-tool="claude"]   { background: var(--tool-claude); }
.tab-badge[data-tool="codex"]    { background: var(--tool-codex); }
.tab-badge[data-tool="copilot"]  { background: var(--tool-copilot); }
.tab-badge[data-tool="gemini"]   { background: var(--tool-gemini); }
.tab-badge[data-tool="terminal"] { background: var(--tool-terminal); }

.session-tab.dragging {
    opacity: 0.5;
}

.tab-content {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    overflow: hidden;
    position: relative;
    padding: 0 0 0 8px;
}

.tab-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Status dot hidden — consolidated to .tab-status-border as single indicator */
.tab-status {
    display: none;
}

.session-tab.has-unread .tab-name {
    color: var(--status-info);
    font-weight: 600;
}

.tab-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tab-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    opacity: 0.65;
    transition: background-color var(--duration-fast, 150ms) var(--ease-default, cubic-bezier(0.4, 0, 0.2, 1)),
                opacity var(--duration-fast, 150ms) var(--ease-default, cubic-bezier(0.4, 0, 0.2, 1));
    cursor: pointer;
    flex-shrink: 0;
}

.session-tab:hover .tab-close {
    opacity: 0.85;
}

.tab-close:hover {
    opacity: 1;
    background-color: var(--surface-tertiary);
}

@media (pointer: coarse) {
    .tab-close { min-width: 44px; min-height: 44px; opacity: 0.7; }
    .tab-new-main,
    .tab-new-dropdown { min-width: 44px; min-height: 44px; }
    .tab-new-split { min-height: 44px; }
    .overflow-menu-btn { min-width: 44px; min-height: 44px; }
}

.tab-name-input {
    width: 100%;
    font: inherit;
    color: var(--text-primary);
    background: var(--surface-primary);
    border: 1px solid var(--border-hover);
    border-radius: 4px;
    padding: 2px 4px;
    outline: none;
}

/* Split new-tab button (Windows Terminal style) */
.tab-new-split {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    margin-left: 4px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border);
    height: 28px;
}

.tab-new-main {
    width: 24px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border: none;
    border-right: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--duration-normal, 200ms) var(--ease-default, cubic-bezier(0.4, 0, 0.2, 1));
}

.tab-new-main:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.tab-new-dropdown {
    width: 16px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--duration-normal, 200ms) var(--ease-default, cubic-bezier(0.4, 0, 0.2, 1));
    padding: 0;
}

.tab-new-dropdown:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Legacy .tab-new kept for backwards compatibility */
.tab-new {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--duration-normal, 200ms) var(--ease-default, cubic-bezier(0.4, 0, 0.2, 1));
    flex-shrink: 0;
    margin-left: 4px;
}

.tab-actions { display: flex; gap: 6px; align-items: center; position: relative; }

/* Clipboard copy feedback badge — inline in tab-actions */
.copy-feedback-badge {
    display: none;
    font-size: var(--text-sm);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--accent-default);
    font-weight: var(--weight-medium);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}
.copy-feedback-badge.visible {
    display: inline-flex;
    opacity: 1;
}
.copy-feedback-badge.error {
    background: rgba(239, 68, 68, 0.12);
    color: var(--status-error);
}
@media (prefers-reduced-motion: reduce) {
    .copy-feedback-badge { transition: none; }
}

/* Header action overflow menu — desktop: children flow inline; tablet/mobile: dropdown */
.overflow-menu-panel {
    display: contents;
}

.overflow-menu-btn {
    display: none;
    width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--duration-normal, 200ms) var(--ease-default, cubic-bezier(0.4, 0, 0.2, 1));
    flex-shrink: 0;
    padding: 0;
}

.overflow-menu-btn:hover {
    background-color: var(--surface-tertiary);
    color: var(--text-primary);
}

/* Tablet breakpoint: collapse overflow items behind three-dot button */
@media (max-width: 1023px) {
    .overflow-menu-btn {
        display: inline-flex;
    }

    .overflow-menu-panel {
        display: none;
        position: absolute;
        top: 100%;
        right: 0;
        flex-direction: column;
        background: var(--surface-elevated);
        border: 1px solid var(--border-default);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-lg);
        z-index: var(--z-dropdown);
        padding: 4px 0;
        min-width: 180px;
    }

    .overflow-menu-panel.open {
        display: flex;
    }

    .overflow-menu-panel > button,
    .overflow-menu-panel > .tab-browse-files,
    .overflow-menu-panel > .tab-attach-image,
    .overflow-menu-panel > .tab-vscode-tunnel,
    .overflow-menu-panel > .tab-app-tunnel {
        width: 100%;
        justify-content: flex-start;
        padding: 8px 12px;
        border-radius: 0;
        gap: 8px;
        font-size: var(--text-sm);
    }

    .overflow-menu-panel > button:hover {
        background-color: var(--surface-tertiary);
    }
}

.connection-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background-color: var(--text-muted);
    flex-shrink: 0;
    transition: background-color var(--duration-normal) var(--ease-default);
}

.connection-status.connected {
    background-color: var(--status-success);
}

.connection-status.disconnected {
    background-color: var(--status-error);
}

.connection-status.reconnecting {
    background-color: var(--status-warning);
    animation: plan-indicator-pulse 1.5s infinite;
}

.tab-tile {
  width: 28px; height: 28px; display:flex; align-items:center; justify-content:center;
  background: transparent; border: 1px solid var(--border); border-radius: 4px;
  color: var(--text-secondary); cursor: pointer; transition: all var(--duration-normal, 200ms) var(--ease-default, cubic-bezier(0.4, 0, 0.2, 1)); flex-shrink: 0; margin-left: 4px;
}
.tab-tile:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.tab-tile[disabled] { opacity: .5; cursor: not-allowed; }

/* Global tabs are visible; panes can be enabled optionally */

.tab-new:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.tab-settings {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    transition: all var(--duration-normal, 200ms) var(--ease-default, cubic-bezier(0.4, 0, 0.2, 1));
    margin-left: auto;
    flex-shrink: 0;
}

.tab-settings:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Sticky-note toggle (status note) — flat toolbar button, matches .tab-voice-input. */
.tab-sticky-note {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
    position: relative;
    flex-shrink: 0;
}
.tab-sticky-note:hover {
    color: var(--accent);
    background: var(--accent-soft, rgba(255, 107, 0, 0.1));
}
/* Open (card visible) → accent colour only, consistent with the flat toolbar (no box). */
.tab-sticky-note[aria-pressed="true"] {
    color: var(--accent);
}
.tab-sticky-note .sticky-note-badge {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent, #5ac8fa);
    box-shadow: 0 0 0 1.5px var(--bg-primary, #1c1c22);
    pointer-events: none;
}
.tab-sticky-note.summarizing .sticky-note-badge {
    animation: sticky-note-pulse 1.1s ease-in-out infinite;
}

/* Tab Overflow Dropdown for Mobile */
.tab-overflow-wrapper {
    position: relative;
    display: none;
}

.tab-overflow-btn {
    width: auto;
    height: 28px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    background-color: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--duration-normal, 200ms) var(--ease-default, cubic-bezier(0.4, 0, 0.2, 1));
    margin-left: 4px;
}

.tab-overflow-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.tab-overflow-count {
    font-size: 12px;
    font-weight: 600;
}

.tab-overflow-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow-md);
    min-width: 200px;
    max-width: 300px;
    z-index: var(--z-dropdown);
    max-height: 400px;
    overflow-y: auto;
}

.tab-overflow-menu.active {
    display: block;
}

.overflow-tab-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color var(--duration-normal, 200ms) var(--ease-default, cubic-bezier(0.4, 0, 0.2, 1));
    border-bottom: 1px solid var(--border);
}

.overflow-tab-item:last-child {
    border-bottom: none;
}

.overflow-tab-item:hover {
    background-color: var(--bg-tertiary);
}

.overflow-tab-item.active {
    background-color: var(--bg-tertiary);
    color: var(--accent);
}

.overflow-tab-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.overflow-tab-close {
    width: 20px;
    height: 20px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--duration-normal, 200ms) var(--ease-default, cubic-bezier(0.4, 0, 0.2, 1));
}

.overflow-tab-close:hover {
    background-color: var(--status-error);
    color: var(--text-inverse, #fff);
}

/* Mobile: compact session pills instead of wide tabs (820px catches iPad Mini portrait) */
@media (max-width: 820px) {
    .session-tabs-bar {
        min-height: 36px;
        padding: 0 6px;
    }

    .tabs-container {
        gap: 4px;
        padding: 4px 0;
    }

    .session-tab {
        min-width: 0;
        max-width: 140px;
        height: 28px;
        padding: 0 8px 0 0;
        border-radius: var(--radius-full);
        font-size: 11px;
        border: 1px solid var(--border-default);
        background: var(--surface-tertiary);
    }

    .session-tab.active {
        background: var(--surface-primary);
        border-color: var(--accent-default);
    }

    /* Remove the accent bottom bar on mobile pills */
    .session-tab.active::after {
        display: none;
    }

    .tab-content {
        gap: 4px;
        padding: 0 0 0 6px;
    }

    .tab-status-border {
        width: 2px;
        border-radius: var(--radius-full) 0 0 var(--radius-full);
    }

    .tab-name {
        font-size: 11px;
    }

    .tab-close {
        width: auto;
        height: auto;
        opacity: 0.5;
    }

    /* Hide the badge on mobile pills to save space */
    .tab-badge {
        display: none;
    }

    /* Compact new tab button */
    .tab-new-split {
        height: 24px;
        margin-left: 2px;
    }

    .tab-new-main {
        width: 20px;
    }

    .tab-new-dropdown {
        width: 14px;
    }

    /* Hide desktop-only action buttons - moved to bottom nav */
    .tab-actions .tab-browse-files,
    .tab-actions .tab-vscode-tunnel,
    .tab-actions .tab-attach-image,
    .tab-actions .tab-voice-input {
        display: none;
    }

    /* Hide the overflow menu button on mobile — bottom nav handles these actions */
    .overflow-menu-btn {
        display: none;
    }

    .overflow-menu-panel {
        display: none;
    }

    /* Keep settings gear visible on desktop tab bar */
    .tab-settings {
        width: 24px;
        height: 24px;
    }

    /* Make overflow button more discoverable on mobile */
    .tab-overflow-btn {
        background: var(--surface-tertiary);
        border: 1px solid var(--border-default);
        border-radius: var(--radius-full);
        min-width: 44px;
        min-height: 44px;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .session-tab {
        max-width: 110px;
        font-size: 10px;
    }
}
