/* Tab Bar, Tab Buttons, Overflow Menu */

/* Tab bar */
.tab-bar {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  min-height: 40px;
  overflow: visible;  /* Allow overflow menu dropdown to be visible */
  position: relative;  /* Position context for overflow menu */
}

.tabs-scroll {
  display: flex;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
}

.tabs-scroll::-webkit-scrollbar {
  display: none;
}

.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  cursor: pointer;
  border-right: 1px solid var(--border);
  border-bottom: 2px solid transparent;  /* Reserve space for active indicator */
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
}

.tab:hover {
  background: var(--tab-hover);
}

.tab.active {
  background: var(--bg-tertiary);
  border-bottom: 2px solid var(--accent);  /* Blue accent line */
}

.tab.new-tab {
  animation: tab-pulse 0.5s ease-out;
}

@keyframes tab-pulse {
  0% { background: var(--accent); }
  100% { background: var(--tab-active); }
}

.tab .icon {
  font-size: 14px;
}

.tab .name {
  font-size: 13px;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-secondary);
}

.tab.active .name {
  color: var(--text-primary);
}

.tab .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

/* Shape modifiers for accessibility (not just color) */
.tab .status-dot--diamond {
  border-radius: 1px;
  transform: rotate(45deg);
}

/* Ring shape for pr-ready (accessibility: distinct from circle) */
.tab .status-dot--ring {
  box-shadow: inset 0 0 0 1.5px currentColor;
  background: transparent !important;
  color: var(--status-waiting);
}

/* Distinct animations per status category (spec 0019) */
@keyframes status-pulse {
  /* Pulsing: Active/working (spawning, implementing) */
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.9); }
}

@keyframes status-blink-slow {
  /* Slow blink: Idle/waiting (pr-ready) */
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@keyframes status-blink-fast {
  /* Fast blink: Error/blocked */
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

.tab .status-dot--pulse {
  animation: status-pulse 2s ease-in-out infinite;
}

.tab .status-dot--blink-slow {
  animation: status-blink-slow 3s ease-in-out infinite;
}

.tab .status-dot--blink-fast {
  animation: status-blink-fast 0.8s ease-in-out infinite;
}

/* Respect reduced motion preference (WCAG 2.3.3) */
/* Motion-independent differentiators remain: diamond for blocked, ring for pr-ready */
@media (prefers-reduced-motion: reduce) {
  .tab .status-dot--pulse,
  .tab .status-dot--blink-slow,
  .tab .status-dot--blink-fast {
    animation: none;
  }
}

.tab .close {
  opacity: 0.6;  /* Always clearly visible */
  margin-left: 6px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
  min-width: 24px;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab:hover .close {
  opacity: 0.9;
}

.tab .close:hover {
  opacity: 1;
  background: rgba(239, 68, 68, 0.2);  /* Red tint on hover */
  color: #ef4444;
}

/* Add buttons */
.add-buttons {
  display: flex;
  gap: 4px;
  padding: 0 8px;
  flex-shrink: 0;
}

.add-btn {
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.add-btn:hover {
  border-style: solid;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
}

/* Overflow indicator */
.overflow-btn {
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  display: none;  /* Hidden by default, shown via JS */
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.overflow-btn:hover {
  background: var(--tab-hover);
}

.overflow-btn:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.overflow-count {
  font-size: 11px;
  background: var(--accent);
  color: white;
  padding: 1px 5px;
  border-radius: 8px;
}

/* Overflow menu dropdown */
.overflow-menu {
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  max-height: 300px;
  overflow-y: auto;
  min-width: 200px;
  z-index: 100;
}

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

.overflow-menu-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.overflow-menu-item:hover,
.overflow-menu-item:focus {
  background: var(--tab-hover);
  outline: none;
}

.overflow-menu-item.active {
  background: var(--tab-active);
  border-left: 2px solid var(--accent);
}

.overflow-menu-item .icon {
  font-size: 14px;
}

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

.overflow-menu-item .open-external {
  opacity: 0.5;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 12px;
  border-radius: 3px;
}

.overflow-menu-item .open-external:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

/* Tab content */
.tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative; /* For absolute positioning of stacked iframes (Spec 0064) */
}

.tab-content iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: #000;
}

/* Cached tab iframes - stacked and hidden by default (Spec 0064) */
.tab-iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: #000;
}

/* Inline content wrapper for dashboard/activity tabs (Spec 0064) */
/* Allows inline tab content to coexist with cached iframes */
.inline-tab-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  flex-direction: column;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 12px;
}

.empty-state .hint {
  font-size: 13px;
  text-align: center;
  max-width: 300px;
}

/* Projects tab without close button */
.tab.tab-uncloseable .close {
  display: none;
}
