/* 
 * KN Category Tabs Styles
 * Following Tailwind philosophy with pure CSS
 * Color scheme from variables.css
 * Typography scale: 2.5rem, 1.5rem, 1rem
 * Spacing: 8px grid (1rem, 1.5rem, 2rem, 2.5rem)
 * Border radius: 1rem for large elements, 0.5rem for small
 */

/* ===== CATEGORY TABS CONTAINER ===== */
.kn-category-tabs {
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
}

.kn-category-tabs-container {
  position: relative;
}

.kn-category-tabs-wrapper {
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-behavior: smooth;
  padding-bottom: 1px; /* Prevent border cutoff */
}

.kn-category-tabs-wrapper::-webkit-scrollbar {
  display: none;
}

/* ===== INDIVIDUAL TAB STYLES ===== */
.kn-category-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  color: var(--text-lighter);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  line-height: var(--line-height-tight);
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: all 0.3s ease;
  position: relative;
}

.kn-category-tab:hover {
  color: var(--secondary-color);
  background-color: rgba(76, 161, 222, 0.08);
  text-decoration: none;
}

.kn-category-tab:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
  border-radius: 0.25rem;
}

/* Active tab */
.kn-category-tab--active {
  color: var(--secondary-color);
  border-bottom-color: var(--secondary-color);
  background-color: rgba(76, 161, 222, 0.08);
  font-weight: 600;
}

.kn-category-tab--active:hover {
  color: var(--primary-color);
  background-color: rgba(76, 161, 222, 0.08);
}

/* Tab text */
.kn-category-tab-text {
  font-family: var(--font-primary);
  color: inherit;
}

/* Tab count badge */
.kn-category-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.5rem;
  background: var(--background-subtle);
  color: var(--text-lighter);
  border-radius: 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  transition: all 0.3s ease;
}

.kn-category-tab:hover .kn-category-tab-count {
  background: var(--secondary-color);
  color: #ffffff;
}

.kn-category-tab--active .kn-category-tab-count {
  background: var(--secondary-color);
  color: #ffffff;
}

/* ===== MOBILE DROPDOWN TOGGLE ===== */
.kn-category-tabs-mobile-toggle {
  display: none;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 1rem 1.5rem;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  color: var(--text-color);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.3s ease;
  margin: 0px;
}

.kn-category-tabs-mobile-toggle:hover {
  border-color: var(--primary-color);
  background-color: rgba(76, 161, 222, 0.08);
}

.kn-category-tabs-mobile-toggle:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.kn-category-tabs-mobile-text {
  flex: 1;
  text-align: left;
  color: inherit;
  font-family: var(--font-primary);
}

.kn-category-tabs-mobile-icon {
  flex-shrink: 0;
  color: var(--text-lighter);
  transition: transform 0.3s ease;
}

.kn-category-tabs-mobile-toggle[aria-expanded="true"]
  .kn-category-tabs-mobile-icon {
  transform: rotate(180deg);
}

/* ===== SCROLLBAR INDICATORS ===== */
.kn-category-tabs-wrapper::before,
.kn-category-tabs-wrapper::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2rem;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.3s ease;
  opacity: 0;
}

.kn-category-tabs-wrapper::before {
  left: 0;
  background: linear-gradient(to right, #ffffff, transparent);
}

.kn-category-tabs-wrapper::after {
  right: 0;
  background: linear-gradient(to left, #ffffff, transparent);
}

.kn-category-tabs-wrapper.kn-scroll-left::before {
  opacity: 1;
}

.kn-category-tabs-wrapper.kn-scroll-right::after {
  opacity: 1;
}

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

/* Tablet: ≤ 1024px */
@media (max-width: 1024px) {
  .kn-category-tabs-wrapper {
    gap: 0;
  }

  .kn-category-tab {
    padding: 0.875rem 1.25rem;
    font-size: 0.8125rem;
  }

  .kn-category-tab-count {
    min-width: 1.375rem;
    height: 1.375rem;
    font-size: 0.6875rem;
  }
}

/* Mobile: ≤ 768px */
@media (max-width: 768px) {
  .kn-category-tabs {
    margin-bottom: 1.5rem;
  }

  .kn-category-tabs-wrapper {
    display: none;
  }

  .kn-category-tabs-mobile-toggle {
    display: flex;
  }

  /* Show mobile dropdown when expanded */
  .kn-category-tabs-container[data-expanded="true"] .kn-category-tabs-wrapper {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 10;
    overflow: visible;
    padding-bottom: 0;
    margin-top: 10px;
  }

  .kn-category-tabs-container[data-expanded="true"] .kn-category-tab {
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    justify-content: space-between;
    padding: 0.875rem 1rem;
  }

  .kn-category-tabs-container[data-expanded="true"]
    .kn-category-tab:last-child {
    border-bottom: none;
  }

  .kn-category-tabs-container[data-expanded="true"] .kn-category-tab--active {
    background-color: rgba(76, 161, 222, 0.08);
    /* border-left: 3px solid var(--primary-color); */
    /* border-bottom-color: var(--border-color); */
  }
}

/* Mobile Small: ≤ 480px */
@media (max-width: 480px) {
  .kn-category-tabs {
    margin-bottom: 1rem;
    border-bottom: none;
  }

  .kn-category-tabs-mobile-toggle {
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
  }

  .kn-category-tabs-container[data-expanded="true"] .kn-category-tab {
    padding: 0.75rem;
    font-size: 0.8125rem;
  }

  .kn-category-tab-count {
    min-width: 1.25rem;
    height: 1.25rem;
    font-size: 0.625rem;
  }
}

/* ===== ACCESSIBILITY ===== */

/* High contrast mode support */
@media (prefers-contrast: high) {
  .kn-category-tab {
    border-bottom-width: 2px;
  }

  .kn-category-tab--active {
    border-bottom-width: 4px;
  }

  .kn-category-tabs-mobile-toggle {
    border-width: 2px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .kn-category-tab,
  .kn-category-tab-count,
  .kn-category-tabs-mobile-toggle,
  .kn-category-tabs-mobile-icon,
  .kn-category-tabs-wrapper::before,
  .kn-category-tabs-wrapper::after {
    transition: none;
  }
}

/* Focus visible support */
.kn-category-tab:focus-visible,
.kn-category-tabs-mobile-toggle:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}
