/**
 * Timing Design System - Tabs
 *
 * Tab navigation for switching between content panels.
 * Supports horizontal tabs with underline indicator.
 *
 * Structure:
 * .tabs           - Container wrapper
 * .tab-list       - Tab button container (role="tablist")
 * .tab            - Individual tab button (role="tab")
 * .tab-panels     - Content panels container
 * .tab-panel      - Individual content panel (role="tabpanel")
 *
 * Variants:
 * .tabs-bordered  - Tabs with bottom border
 * .tabs-pills     - Pill-style tabs with background
 * .tabs-sm        - Smaller tabs
 * .tabs-lg        - Larger tabs
 */

/* Tab container */
.tabs {
  display: flex;
  flex-direction: column;
}

/* Tab list (navigation) */
.tab-list {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-4);
}

/* Individual tab button */
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  transition: color var(--transition-fast), background-color var(--transition-fast);
  white-space: nowrap;
}

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

.tab:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

/* Active tab state */
.tab[aria-selected="true"],
.tab.active {
  color: var(--color-accent);
}

/* Active indicator (underline) */
.tab[aria-selected="true"]::after,
.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--color-accent);
  border-radius: 2px 2px 0 0;
}

/* Disabled tab */
.tab:disabled,
.tab[aria-disabled="true"] {
  color: var(--color-text-muted);
  cursor: not-allowed;
  opacity: 0.5;
}

.tab:disabled:hover,
.tab[aria-disabled="true"]:hover {
  background-color: transparent;
}

/* Tab with icon */
.tab-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Tab badge/count */
.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  background-color: var(--color-bg-elevated);
  border-radius: var(--radius-full);
}

.tab[aria-selected="true"] .tab-badge,
.tab.active .tab-badge {
  background-color: var(--color-accent);
  color: white;
}

/* Tab panels container */
.tab-panels {
  position: relative;
}

/* Individual tab panel */
.tab-panel {
  display: none;
}

.tab-panel[aria-hidden="false"],
.tab-panel.active {
  display: block;
}

/* Panel animation (optional) */
.tab-panel.active {
  animation: tabFadeIn var(--transition-normal) ease-out;
}

@keyframes tabFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .tab-panel.active {
    animation: none;
  }
}

/* ==========================================================================
   Variants
   ========================================================================== */

/* Bordered variant - tabs with visible border on all sides */
.tabs-bordered .tab-list {
  border-bottom: 1px solid var(--color-border);
}

.tabs-bordered .tab[aria-selected="true"],
.tabs-bordered .tab.active {
  background-color: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-bottom-color: var(--color-bg-surface);
  margin-bottom: -1px;
}

.tabs-bordered .tab[aria-selected="true"]::after,
.tabs-bordered .tab.active::after {
  display: none;
}

/* Pills variant - rounded pill-style tabs */
.tabs-pills .tab-list {
  gap: var(--space-2);
  border-bottom: none;
  background-color: var(--color-bg-elevated);
  padding: var(--space-1);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}

.tabs-pills .tab {
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
}

.tabs-pills .tab:hover {
  background-color: var(--color-bg-surface);
}

.tabs-pills .tab[aria-selected="true"],
.tabs-pills .tab.active {
  background-color: var(--color-bg-surface);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-sm);
}

.tabs-pills .tab[aria-selected="true"]::after,
.tabs-pills .tab.active::after {
  display: none;
}

/* ==========================================================================
   Sizes
   ========================================================================== */

/* Small tabs */
.tabs-sm .tab {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
}

.tabs-sm .tab-icon {
  width: 14px;
  height: 14px;
}

.tabs-sm .tab-badge {
  min-width: 16px;
  height: 16px;
  font-size: 10px;
}

/* Large tabs */
.tabs-lg .tab {
  padding: var(--space-4) var(--space-5);
  font-size: var(--text-base);
}

.tabs-lg .tab-icon {
  width: 20px;
  height: 20px;
}

.tabs-lg .tab-badge {
  min-width: 22px;
  height: 22px;
  font-size: var(--text-sm);
}

/* ==========================================================================
   Full-width tabs
   ========================================================================== */

.tabs-full .tab-list {
  width: 100%;
}

.tabs-full .tab {
  flex: 1;
  justify-content: center;
}
