/* ============================================================================
 * TC-TABS — Einheitliche Tab-Navigation
 * ----------------------------------------------------------------------------
 * Varianten:
 *   .tc-tabs                    Standard (underline-style, gold-Akzent)
 *   .tc-tabs--pills             Pill-Style (gefüllte Buttons)
 *   .tc-tabs--system            System-Tabs mit Logo-Support (Dashboard)
 *   .tc-tabs--vertical          Vertikal-Layout
 *
 * Größen:
 *   .tc-tabs--sm                Kompaktere Tabs
 *   .tc-tabs--lg                Größere Tabs
 *
 * HTML-Pattern:
 *   <div class="tc-tabs" role="tablist">
 *     <button class="tc-tab is-active" role="tab" data-tab="overview">Übersicht</button>
 *     <button class="tc-tab" role="tab" data-tab="details">Details</button>
 *   </div>
 *   <div class="tc-tab-panels">
 *     <div class="tc-tab-panel is-active" data-panel="overview">...</div>
 *     <div class="tc-tab-panel" data-panel="details" hidden>...</div>
 *   </div>
 *
 * JS-API (tc-ui.js):
 *   TC.Tabs.init(container)     → Auto-init eines .tc-tabs
 *   TC.Tabs.initAll()           → Init aller .tc-tabs[data-auto-tabs] auf der Seite
 *
 * Version: 1.0 (29. Mai 2026, Phase 3)
 * ============================================================================ */

/* ============================================================================
 * CONTAINER
 * ============================================================================ */

.tc-tabs {
  display: flex;
  align-items: flex-end;
  gap: 0;
  border-bottom: 2px solid rgba(201, 169, 89, 0.2);
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

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

/* Overflow-Fade rechts als Joy-of-Use Hinweis auf weitere Tabs */
.tc-tabs::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 32px;
  background: linear-gradient(90deg, transparent, var(--tc-bg-canvas, #0d0b0a));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.tc-tabs.is-overflowing::after {
  opacity: 1;
}

/* ============================================================================
 * TAB-BUTTON (Standard — Underline)
 * ============================================================================ */

.tc-tab {
  /* Reset */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: none;
  background: transparent;
  outline: none;
  margin: 0;
  box-sizing: border-box;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;

  /* Layout */
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  white-space: nowrap;
  flex-shrink: 0;

  /* Typo */
  font-family: var(--tc-font-ui, 'Lato', sans-serif);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--tc-text-muted, #888);

  /* Underline-Indikator via box-shadow */
  border-bottom: 2px solid transparent;
  margin-bottom: -2px; /* liegt auf der Container-Border */

  transition:
    color var(--tc-motion-normal, 200ms ease),
    border-color var(--tc-motion-normal, 200ms ease),
    background var(--tc-motion-normal, 200ms ease);

  /* Touch-Target min 44px */
  min-height: 44px;
}

.tc-tab .tc-tab__icon {
  font-size: 1rem;
  line-height: 1;
}

.tc-tab .tc-tab__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(201, 169, 89, 0.2);
  color: var(--tc-accent, #c9a959);
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  min-width: 18px;
  line-height: 1.4;
}

/* Hover */
.tc-tab:hover:not([disabled]):not(.is-active) {
  color: var(--tc-text-base, #ddd);
  background: rgba(201, 169, 89, 0.05);
}

/* Active */
.tc-tab.is-active {
  color: var(--tc-accent, #c9a959);
  border-bottom-color: var(--tc-accent, #c9a959);
}

.tc-tab.is-active .tc-tab__badge {
  background: rgba(201, 169, 89, 0.3);
}

/* Disabled */
.tc-tab[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Focus-Visible für Keyboard-Navigation */
.tc-tab:focus-visible {
  outline: 2px solid var(--tc-accent, #c9a959);
  outline-offset: -2px;
  border-radius: 4px 4px 0 0;
}

/* ============================================================================
 * VARIANTE: PILLS
 * ============================================================================ */

.tc-tabs--pills {
  border-bottom: none;
  gap: 6px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  align-items: center;
}

.tc-tabs--pills::after {
  display: none;
}

.tc-tabs--pills .tc-tab {
  border-bottom: none;
  margin-bottom: 0;
  border-radius: 8px;
  padding: 8px 14px;
  min-height: 36px;
}

.tc-tabs--pills .tc-tab:hover:not([disabled]):not(.is-active) {
  background: rgba(255, 255, 255, 0.07);
}

.tc-tabs--pills .tc-tab.is-active {
  background: rgba(201, 169, 89, 0.15);
  border-bottom-color: transparent;
  box-shadow: inset 0 0 0 1px rgba(201, 169, 89, 0.35);
}

/* ============================================================================
 * VARIANTE: SYSTEM (Logo-basiert, Dashboard-Tabs)
 * ============================================================================ */

.tc-tabs--system {
  border-bottom: 2px solid rgba(255, 255, 255, 0.06);
  gap: 4px;
  padding: 8px 8px 0;
  background: var(--tc-bg-surface-0, var(--bg-secondary, #242424));
  border-radius: 12px 12px 0 0;
  border: 1px solid var(--tc-border-subtle, var(--border-color, #444));
  border-bottom: none;
}

.tc-tabs--system .tc-tab {
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 16px 12px;
  border-radius: 8px 8px 0 0;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  min-height: unset;
  min-width: 90px;
  flex: 1;
}

.tc-tabs--system .tc-tab__logo {
  width: 80px;
  height: 30px;
  object-fit: contain;
  border-radius: 4px;
  filter: grayscale(0.5) brightness(0.7);
  transition: filter var(--tc-motion-normal, 200ms ease);
}

.tc-tabs--system .tc-tab:hover .tc-tab__logo,
.tc-tabs--system .tc-tab.is-active .tc-tab__logo {
  filter: grayscale(0) brightness(1);
}

.tc-tabs--system .tc-tab__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* System-Tabs: Akzentfarbe per --tab-color inline var */
.tc-tabs--system .tc-tab.is-active {
  color: var(--tab-accent, var(--tc-accent, #c9a959));
  border-bottom-color: var(--tab-accent, var(--tc-accent, #c9a959));
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--tab-color, #8b0000) 20%, transparent),
    color-mix(in srgb, var(--tab-color, #8b0000) 8%, transparent));
  box-shadow: 0 0 12px color-mix(in srgb, var(--tab-color, #8b0000) 30%, transparent);
}

/* ============================================================================
 * VARIANTE: VERTIKAL
 * ============================================================================ */

.tc-tabs--vertical {
  flex-direction: column;
  border-bottom: none;
  border-right: 2px solid rgba(201, 169, 89, 0.2);
  align-items: flex-end;
  overflow-x: hidden;
  overflow-y: auto;
}

.tc-tabs--vertical::after {
  display: none;
}

.tc-tabs--vertical .tc-tab {
  width: 100%;
  justify-content: flex-end;
  border-bottom: none;
  border-right: 2px solid transparent;
  margin-bottom: 0;
  margin-right: -2px;
  border-radius: 4px 0 0 4px;
}

.tc-tabs--vertical .tc-tab.is-active {
  border-right-color: var(--tc-accent, #c9a959);
  border-bottom-color: transparent;
}

/* ============================================================================
 * GRÖßEN
 * ============================================================================ */

.tc-tabs--sm .tc-tab {
  font-size: 0.8rem;
  padding: 8px 12px;
  min-height: 36px;
}

.tc-tabs--lg .tc-tab {
  font-size: 0.95rem;
  padding: 12px 20px;
  min-height: 48px;
}

/* ============================================================================
 * TAB-PANELS
 * ============================================================================ */

.tc-tab-panels {
  position: relative;
}

.tc-tab-panel {
  display: block;
}

.tc-tab-panel[hidden] {
  display: none;
}

/* Sanfter Einblend-Effekt */
.tc-tab-panel.is-entering {
  animation: tcTabFadeIn var(--tc-motion-normal, 200ms ease) both;
}

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

@media (prefers-reduced-motion: reduce) {
  .tc-tab-panel.is-entering {
    animation: none;
  }
}

/* ============================================================================
 * RESPONSIVE
 * ============================================================================ */

@media (max-width: 600px) {
  .tc-tab {
    padding: 10px 12px;
    font-size: 0.82rem;
  }

  .tc-tabs--system .tc-tab {
    min-width: 58px;
    padding: 6px 10px 8px;
  }

  .tc-tabs--system .tc-tab__logo {
    width: 22px;
    height: 22px;
  }

  .tc-tabs--system .tc-tab__label {
    font-size: 0.65rem;
  }
}
