/**
 * AUTOMOTO.AI - Articles Catalog Styles
 * Стилі для сторінки каталогу статей (/articles)
 * 
 * Залежності:
 * - shared/css/base.css
 * - shared/css/nav-footer.css
 */

/* ============================================
   Page Container
   ============================================ */
.main-content {
  padding-top: 80px;
}

.page-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-lg);
}

/* ============================================
   Breadcrumb
   ============================================ */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.875rem;
  color: var(--md-sys-color-outline);
  margin-bottom: var(--space-lg);
}

.breadcrumb a {
  color: var(--md-sys-color-outline);
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb a:hover {
  color: var(--md-sys-color-primary);
}

.breadcrumb span:last-child {
  color: var(--md-sys-color-on-surface);
}

/* ============================================
   Page Header
   ============================================ */
.page-header {
  text-align: center;
  margin-bottom: var(--space-2xl);
}

.page-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: var(--space-md);
}

.page-subtitle {
  font-size: 1.125rem;
  color: var(--md-sys-color-outline);
}

/* ============================================
   Search & Filters
   ============================================ */
.search-section {
  margin-bottom: var(--space-xl);
}

.search-box {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.search-input-wrapper {
  flex: 1;
  position: relative;
}

.search-input {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  padding-left: 48px;
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--radius-full);
  color: var(--md-sys-color-on-surface);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px rgba(168, 199, 250, 0.2);
}

.search-input::placeholder {
  color: var(--md-sys-color-outline);
}

.search-icon {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--md-sys-color-outline);
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--md-sys-color-outline);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
}

.search-clear:hover {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
}

.search-input:not(:placeholder-shown) + .search-icon + .search-clear {
  display: flex;
}

/* ============================================
   Filter Tabs
   ============================================ */
.filter-tabs {
  display: none; /* Using unified tags instead */
}

.filter-tab {
  padding: 8px 16px;
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--radius-full);
  color: var(--md-sys-color-on-surface);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.filter-tab:hover {
  background: var(--md-sys-color-surface-container-high);
  border-color: var(--md-sys-color-primary);
}

.filter-tab.active {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-color: var(--md-sys-color-primary);
}

/* ============================================
   Tags Cloud
   ============================================ */
.tags-section {
  margin-bottom: var(--space-xl);
}

.tags-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.tags-title {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.tags-toggle {
  background: none;
  border: none;
  color: var(--md-sys-color-primary);
  cursor: pointer;
  font-size: 0.875rem;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 4px;
}

.tags-toggle:hover {
  text-decoration: underline;
}

.tags-clear {
  background: none;
  border: none;
  color: var(--md-sys-color-error, #ff6b6b);
  cursor: pointer;
  font-size: 0.875rem;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 4px;
}

.tags-clear:hover {
  text-decoration: underline;
}

.tags-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  max-height: 44px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.tags-cloud.expanded {
  max-height: 500px;
}

.tag-btn {
  padding: 6px 12px;
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--radius-full);
  color: var(--md-sys-color-on-surface);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 4px;
}

.tag-btn:hover {
  background: var(--md-sys-color-surface-container-high);
  border-color: var(--md-sys-color-primary);
}

.tag-btn.active {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-color: var(--md-sys-color-primary);
}

.tag-btn .tag-count {
  font-size: 0.6875rem;
  opacity: 0.7;
}

/* ============================================
   Results Counter & No Results
   ============================================ */
.results-counter {
  font-size: 0.875rem;
  color: var(--md-sys-color-outline);
  margin-bottom: var(--space-lg);
  display: none;
}

.no-results {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--md-sys-color-outline);
  display: none;
}

.no-results.visible {
  display: block;
}

.no-results .material-symbols-rounded {
  font-size: 64px;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

/* ============================================
   Articles Grid
   ============================================ */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-lg);
}

/* ============================================
   Article Card
   ============================================ */
.article-card {
  background: var(--md-sys-color-surface-container);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}

.article-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  text-decoration: none;
}

.article-card:hover * {
  text-decoration: none;
}

.article-card.hidden {
  display: none;
}

.article-card-image {
  height: 160px;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
}

.article-card-image .material-symbols-rounded {
  font-size: 64px;
  color: white;
  opacity: 0.9;
}

.article-card-content {
  padding: var(--space-lg);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.article-card-category {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 500;
  margin-bottom: var(--space-sm);
  width: fit-content;
}

.article-card-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: var(--space-sm);
  line-height: 1.4;
}

.article-card-desc {
  font-size: 0.875rem;
  color: var(--md-sys-color-outline);
  flex: 1;
  margin-bottom: var(--space-md);
}

.article-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: var(--space-md);
}

.article-card-tags .tag {
  padding: 2px 8px;
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  color: var(--md-sys-color-outline);
  cursor: pointer;
  transition: all 0.2s;
}

.article-card-tags .tag:hover {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.article-card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: 0.75rem;
  color: var(--md-sys-color-outline);
  flex-wrap: wrap;
}

.article-card-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.article-card-meta .material-symbols-rounded {
  font-size: 16px;
}

.article-stats {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-left: auto;
}

.article-stats .stat {
  display: flex;
  align-items: center;
  gap: 2px;
  color: var(--md-sys-color-outline);
  font-size: 0.75rem;
}

.article-stats .stat .material-symbols-rounded {
  font-size: 14px;
}

/* ============================================
   Brands Section
   ============================================ */
.brands-section {
  margin-top: var(--space-2xl);
  padding: var(--space-xl);
  background: var(--md-sys-color-surface-container);
  border-radius: var(--radius-xl);
}

.brands-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.brands-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 1.25rem;
  font-weight: 600;
}

.brands-scroll-container {
  position: relative;
}

.brands-scroll-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.2s;
}

.brands-scroll-btn:hover {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-color: var(--md-sys-color-primary);
}

.brands-scroll-btn.prev {
  left: -20px;
}

.brands-scroll-btn.next {
  right: -20px;
}

.brands-grid {
  display: flex;
  gap: var(--space-md);
  overflow-x: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: var(--space-sm) 0;
}

.brands-grid::-webkit-scrollbar {
  display: none;
}

.brand-card {
  flex: 0 0 auto;
  width: 100px;
  height: 100px;
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  text-decoration: none;
  color: var(--md-sys-color-on-surface);
  transition: all 0.2s;
  border: 1px solid transparent;
}

.brand-card:hover {
  background: var(--md-sys-color-surface-container-highest);
  border-color: var(--md-sys-color-primary);
  transform: translateY(-2px);
}

.brand-card img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.brand-card span {
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
}

/* Mobile scroll indicator */
.brands-scroll-container::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 60px;
  background: linear-gradient(to right, transparent, var(--md-sys-color-surface-container));
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s;
}

.brands-scroll-container.scrolled-end::after {
  opacity: 0;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
  .page-title {
    font-size: 1.75rem;
  }
  
  .articles-grid {
    grid-template-columns: 1fr;
  }
  
  .brands-scroll-btn {
    display: none;
  }
  
  .brands-scroll-container::after {
    width: 40px;
  }
}

@media (max-width: 500px) {
  .page-container {
    padding: var(--space-lg) var(--space-md);
  }
  
  .search-input {
    padding: var(--space-sm) var(--space-md);
    padding-left: 40px;
    font-size: 0.9375rem;
  }
  
  .tags-cloud {
    max-height: 88px;
  }
}

/* ============================================
   Brand Card Extended Styles
   ============================================ */
.brand-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  margin-bottom: var(--space-sm);
  border-radius: 8px;
  filter: invert(1);
  opacity: 0.85;
  transition: filter 0.2s, opacity 0.2s;
}

[data-theme="light"] .brand-logo,
.light-theme .brand-logo {
  filter: invert(0);
  opacity: 0.9;
}

/* Opel yellow logo needs darkening on light backgrounds */
[data-theme="light"] [data-brand="opel"] .brand-logo,
.light-theme [data-brand="opel"] .brand-logo {
  filter: brightness(0.3) contrast(1.5);
}

.brand-card:hover .brand-logo {
  opacity: 1;
}

.brand-name {
  font-size: 0.875rem;
  font-weight: 500;
  text-align: center;
}

.brand-card.coming-soon {
  opacity: 0.5;
  pointer-events: none;
}

.brand-card:not(.coming-soon) {
  opacity: 1;
  pointer-events: auto;
  cursor: pointer;
}

.brand-card.active {
  border-color: var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-highest);
}

/* ============================================
   Section Header
   ============================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  margin-top: var(--space-2xl);
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.section-link {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--md-sys-color-primary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
}

.section-link:hover {
  text-decoration: underline;
}

/* ============================================
   Tag Chip Styles
   ============================================ */
.tag-chip {
  padding: 6px 12px;
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--radius-full);
  color: var(--md-sys-color-on-surface);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tag-chip:hover {
  background: var(--md-sys-color-primary-container);
  border-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary-container);
}

.tag-chip.active {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-color: var(--md-sys-color-primary);
}

.tag-chip.tag-category {
  font-weight: 600;
}

.tag-separator {
  color: var(--md-sys-color-outline);
  margin: 0 var(--space-xs);
  user-select: none;
}

/* ============================================
   Brands Grid Extended (3 rows layout)
   ============================================ */
.brands-grid {
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  grid-auto-flow: column;
  grid-auto-columns: 100px;
  gap: var(--space-md);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  padding-bottom: var(--space-sm);
  scrollbar-width: thin;
  scrollbar-color: var(--md-sys-color-outline-variant) transparent;
}

.brands-grid::-webkit-scrollbar {
  height: 6px;
}

.brands-grid::-webkit-scrollbar-track {
  background: transparent;
}

.brands-grid::-webkit-scrollbar-thumb {
  background: var(--md-sys-color-outline-variant);
  border-radius: 3px;
}

.brands-scroll-btn.left {
  left: -20px;
}

.brands-scroll-btn.right {
  right: -20px;
}

@media (max-width: 768px) {
  .brands-grid {
    grid-auto-columns: 90px;
  }
  
  .brands-scroll-container::after {
    animation: pulse-scroll 2s ease-in-out infinite;
  }
  
  @keyframes pulse-scroll {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
  }
}
