/**
 * Shared Tab Navigation Styles
 * Provides consistent tab styling and animations across all tab interfaces
 */

.tb-tab-nav {
  display: flex;
  border-bottom: 1px solid var(--header-background-color, #f0f0f0);
}

.tb-tab-nav-item {
  position: relative;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-color-label, #555);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  /* Sync color transition with indicator animation for cohesive feel */
  transition: color 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.tb-tab-nav-item::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: -1px; /* Extend to cover left padding */
  right: -1px; /* Extend to cover right padding */
  width: auto; /* Let left/right define the width */
  height: 3px;
  background-color: var(--primary-color, #007bff);
  transform: scaleX(0);
  transform-origin: left; /* Default: grows from left */
  /* Balanced easing for sequential animations: smooth acceleration & deceleration */
  /* Better visual continuity between overlapping steps */
  transition: transform var(--tab-transition-duration, 0.16s) cubic-bezier(0.4, 0.0, 0.6, 1);
  /* GPU acceleration hint for smooth 60fps animation */
  will-change: transform;
}

/* Respect user accessibility preferences */
@media (prefers-reduced-motion: reduce) {
  .tb-tab-nav-item::after {
    transition: none;
  }
}

.tb-tab-nav-item.active::after {
  transform: scaleX(1);
}

/* Modifier for right-origin shrinking (adjacent tabs) */
.tb-tab-nav-item.shrink-right::after,
.tb-tab-nav-item.grow-right::after {
  transform-origin: right;
}

/* Center-based transitions for teleport effect (non-adjacent tabs) */
.tb-tab-nav-item.shrink-center::after,
.tb-tab-nav-item.grow-center::after {
  transform-origin: center;
}

.tb-tab-nav-item.active,
.tb-tab-nav-item:hover {
  color: var(--primary-color, #007bff);
}

.tb-tab-content {
  display: none;
  padding-top: 30px;
}

.tb-tab-content.active {
  display: block;
}

/* Tab Dropdown Styles */
.tb-tab-nav-item {
  display: flex;
  align-items: center;
}

.tb-tab-label {
  /* Allow label to shrink if needed */
  flex-shrink: 1;
}

.tb-tab-dropdown {
  position: relative;
  margin-left: auto; /* Push to right side */
  flex-shrink: 0;
}

.tb-tab-dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  color: inherit;
  transition: transform 0.2s ease;
}

.tb-tab-dropdown-trigger:hover {
  color: var(--primary-color, #007bff);
}

/* Hovering over tab also highlights the chevron */
.tb-tab-nav-item:hover .tb-tab-dropdown-trigger {
  color: var(--primary-color, #007bff);
}

/* Active tab chevron inherits primary color */
.tb-tab-nav-item.active .tb-tab-dropdown-trigger {
  color: var(--primary-color, #007bff);
}

/* Rotate chevron when dropdown is open */
.tb-tab-dropdown.open .tb-tab-dropdown-trigger {
  transform: rotate(180deg);
}

.tb-tab-dropdown-trigger i {
  font-size: 10px;
  pointer-events: none;
}

.tb-tab-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  min-width: 180px;
  background: #ffffff;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  z-index: 1000;
}

.tb-tab-dropdown.open .tb-tab-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateX(-70%) translateY(0);
}

.tb-tab-dropdown-item {
  display: block;
  width: 100%;
  padding: 8px 16px;
  text-align: left;
  font-size: 13px;
  font-weight: 400;
  color: #333;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background-color 0.15s ease;
  position: relative;
}

.tb-tab-dropdown-item:first-child {
  border-radius: 4px 4px 0 0;
}

.tb-tab-dropdown-item:last-child {
  border-radius: 0 0 4px 4px;
}

.tb-tab-dropdown-item:hover {
  background-color: #f5f5f5;
}

.tb-tab-dropdown-item.selected {
  background-color: transparent;
  color: var(--primary-color, #007bff);
}

.tb-tab-dropdown-item.selected:hover {
  background-color: #f5f5f5;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .tb-tab-dropdown-menu {
    min-width: 160px;
  }
  
  .tb-tab-dropdown-item {
    padding: 8px 12px;
    font-size: 13px;
  }
}

/* Prevent dropdown trigger from affecting tab animations */
.tb-tab-nav-item[data-has-dropdown] .tb-tab-dropdown {
  /* Exclude from width calculations during animations */
  position: relative;
}
