/* ==========================================================================
   TABS COMPONENT
   Tab navigation styles
   ========================================================================== */

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 2rem;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  justify-items: stretch;
  min-width: 0; /* Prevent grid from expanding beyond container */
  contain: layout; /* Isolate tab layout to prevent external reflow affecting widths */
}

.tablinks {
  background: #f1f5f9;
  border: 2px solid transparent;
  border-radius: 0.75rem;
  padding: 1rem 1.5rem;
  min-height: 3.25rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: none;
  text-align: center;
  width: 100%;
  min-width: 0; /* Prevent expansion beyond grid cell */
  box-sizing: border-box; /* Include padding in width */
}

.tablinks:hover:not(.active) {
  background: #e2e8f0;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

/* Accessibility: Visible focus indicator for keyboard navigation */
.tablinks:focus {
  outline: 3px solid #0f172a;
  outline-offset: 3px;
  border-color: #0f172a;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.2);
}

.tablinks:focus:not(:focus-visible) {
  outline: none; /* Remove outline for mouse users, keep for keyboard */
  box-shadow: none;
}

.tablinks:focus-visible {
  outline: 3px solid #0f172a;
  outline-offset: 3px;
  border-color: #0f172a;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.2);
}

.tablinks.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
  /* box-shadow enabled only after page is ready to avoid visual pop */
  box-shadow: none;
}

.tabs-ready .tablinks.active {
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.tab-panels {
  position: relative;
  width: 100%;
  isolation: isolate;
}

.tabcontent {
  position: relative;
  width: 100%;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.tabcontent:not(.active) {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 0;
}

.tabcontent.active {
  z-index: 1;
}

/* Mobile responsive */
@media (max-width: 666px) {
  .tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.4rem;
    width: min(520px, 100%);
    margin: 0 auto 1rem;
    padding: 0 0.35rem;
  }

  .tablinks {
    font-size: 0.85rem;
    padding: 0.75rem 0.4rem;
    min-height: 2.75rem;
  }
}

