/* Data cells */
.comparison-table td {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--color-gray-200);
  color: var(--color-gray-700);
  vertical-align: top;
}

.comparison-table tbody tr:hover td,
.comparison-table tbody tr:hover th {
  background: var(--color-gray-50);
}

/* Compare list (best use cases) */
.compare-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.compare-list li {
  position: relative;
  padding-left: 1rem;
  margin-bottom: 0.25rem;
}

.compare-list li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--color-gray-400);
}

/* Language tags inside comparison cells */
.comparison-table td .lang-tag {
  white-space: nowrap;
  margin-bottom: 0.2rem;
  display: inline-block;
}

/* Category badges inside comparison cells */
.comparison-table td .cat-badge {
  white-space: nowrap;
}

/* Disabled nav button */
.nav-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.nav-btn:disabled:hover {
  background: var(--color-surface);
  border-color: var(--color-gray-300);
  color: var(--color-gray-700);
}

/* ── Touch-friendly enhancements (all breakpoints) ───────────────── */
/* Ensure all interactive elements meet minimum 44x44px tap target */
.filter-chip,
.nav-btn,
.active-filter-pill button,
.tree-choice-btn,
.tree-back-btn,
.tree-skip-btn,
.tree-results-btn,
.compare-toggle,
.compare-remove-btn,
.back-browse-btn,
.clear-filters-btn,
.empty-state .btn,
.error-state .btn {
  min-height: 44px;
}

.filter-chip {
  padding: 0.45rem 0.75rem;
}

.nav-btn {
  padding: 0.5rem 1rem;
}

.active-filter-pill button {
  width: 1.5rem;
  height: 1.5rem;
}

.compare-toggle {
  width: 40px;
  height: 40px;
}

.compare-remove-btn {
  width: 32px;
  height: 32px;
}

.tree-choice-btn {
  padding: 0.9rem 1.125rem;
}

.tree-back-btn,
.tree-skip-btn,
.tree-results-btn {
  padding: 0.625rem 1.125rem;
}

.clear-filters-btn {
  padding: 0.5rem 0.625rem;
}

.back-browse-btn {
  padding: 0.625rem 1.25rem;
}

/* ── Responsive ──────────────────────────────────────────────────── */
/* >= 1025px: 3 columns (explicit) */
@media (min-width: 1025px) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* 769px - 1024px: 2 columns */
@media (min-width: 769px) and (max-width: 1024px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── <= 768px: Tablet / Large phone ──────────────────────────────── */
@media (max-width: 768px) {
  #app-root {
    padding: 1rem;
  }

  /* Header compact */
  .app-header {
    padding: 0.75rem 1rem;
  }

  .app-header h1 {
    font-size: 1.15rem;
  }

  .app-header .subtitle {
    font-size: 0.8rem;
    max-width: 100%;
  }

  /* Nav buttons compact */
  .app-nav {
    gap: 0.5rem;
  }

  .nav-btn {
    font-size: 0.8rem;
    padding: 0.45rem 0.75rem;
  }

  .nav-btn .nav-label {
    display: none;
  }

  /* ── Filter sidebar: slide-in drawer overlay ──────────────────── */
  .app-layout {
    grid-template-columns: 1fr;
    position: relative;
  }

  .filter-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    max-width: 85vw;
    height: 100vh;
    height: 100dvh;
    z-index: 1000;
    background: var(--color-surface);
    overflow-y: auto;
    padding: 1.25rem 1rem;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.15);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid var(--color-border);
  }

  /* Drawer open state — toggled via JS class */
  .filter-sidebar.open {
    transform: translateX(0);
  }

  /* Backdrop overlay behind the drawer */
  .filter-sidebar::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: -1;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  /* Show backdrop when drawer is open */
  .filter-sidebar.open::before {
    opacity: 1;
    pointer-events: auto;
  }

  /* Close button inside the drawer */
  .filter-drawer-close {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    font-size: 1.25rem;
    color: var(--color-gray-500);
    cursor: pointer;
    border-radius: var(--radius-sm);
  }

  .filter-drawer-close:hover {
    background: var(--color-gray-100);
    color: var(--color-gray-800);
  }

  /* Filter groups stack vertically inside the drawer */
  .filter-group {
    margin-bottom: 1.25rem;
  }

  /* ── Filter toggle button (visible in top bar on mobile) ──────── */
  .filter-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.85rem;
    font-size: 0.82rem;
    font-family: var(--font-family);
    font-weight: 500;
    border: 1px solid var(--color-gray-300);
    border-radius: var(--radius-pill);
    background: var(--color-surface);
    color: var(--color-gray-700);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    min-height: 44px;
    transition: background var(--transition-fast),
                border-color var(--transition-fast);
  }

  .filter-toggle-btn:hover {
    background: var(--color-gray-100);
    border-color: var(--color-gray-400);
  }

  .filter-toggle-btn .filter-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.3rem;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--color-primary-text);
    background: var(--color-primary);
    border-radius: var(--radius-pill);
  }

  .filter-toggle-badge {
    display: inline-flex;
    width: 8px;
    height: 8px;
    background: var(--color-primary);
    border-radius: 50%;
  }

  /* Hide badge when count is zero */
  .filter-toggle-btn .filter-count-badge:empty,
  .filter-toggle-btn .filter-count-badge[data-count="0"] {
    display: none;
  }

  /* On mobile, the drawer close button is visible inside the open sidebar */
  .filter-drawer-close {
    display: flex;
  }

  /* On mobile, the filter toggle is always visible in the search bar */
  .filter-toggle-btn {
    display: inline-flex;
  }

  /* ── Card grid: 2 columns at this breakpoint ──────────────────── */
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* ── Decision tree ────────────────────────────────────────────── */
  .tree-view {
    padding: 0.5rem 0;
  }

  .tree-question-card {
    padding: 1.25rem;
  }

  .tree-question {
    font-size: 1.1rem;
  }

  .tree-choice-btn {
    width: 100%;
    min-height: 48px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }

  .tree-nav {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .tree-skip-btn {
    margin-left: 0;
    order: 3;
    width: 100%;
  }

  /* ── Comparison view ──────────────────────────────────────────── */
  .compare-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .compare-header h2 {
    font-size: 1.25rem;
  }

  .back-browse-btn {
    margin-left: 0;
  }

  .comparison-table {
    font-size: 0.8rem;
    min-width: 500px;
  }

  .compare-col-header {
    min-width: 160px;
    padding: 0.6rem 0.75rem;
  }

  .compare-row-label {
    padding: 0.6rem 0.75rem;
    min-width: 110px;
    width: 110px;
  }

  .comparison-table td {
    padding: 0.6rem 0.75rem;
  }

  /* ── Search ───────────────────────────────────────────────────── */
  .search-bar input {
    font-size: 1rem;
    padding: 0.7rem 1rem;
  }

  /* ── Active filters ───────────────────────────────────────────── */
  .active-filters {
    gap: 0.375rem;
  }

  .active-filter-pill {
    font-size: 0.78rem;
    padding: 0.35rem 0.55rem 0.35rem 0.65rem;
  }

  .active-filter-pill button {
    width: 1.5rem;
    height: 1.5rem;
  }
}

/* ── <= 480px: Small phones ──────────────────────────────────────── */
@media (max-width: 480px) {
  #app-root {
    padding: 0.75rem;
  }

  /* Header ultra-compact */
  .app-header {
    padding: 0.6rem 0.75rem;
  }

  .app-header h1 {
    font-size: 1.05rem;
  }

  .app-header .subtitle {
    font-size: 0.75rem;
    display: none;
  }

  .app-nav {
    gap: 0.35rem;
    margin-top: 0.5rem;
  }

  .nav-btn {
    font-size: 0.72rem;
    padding: 0.4rem 0.6rem;
  }

  /* ── Sidebar drawer full-width on small phones ────────────────── */
  .filter-sidebar {
    width: 100vw;
    max-width: 100vw;
  }

  /* ── Card grid: single column ─────────────────────────────────── */
  .card-grid {
    grid-template-columns: 1fr;
  }

  .db-card {
    padding: 1rem;
  }

  .db-card-name {
    font-size: 1rem;
  }

  .db-card-description {
    font-size: 0.82rem;
  }

  /* ── Search full width ────────────────────────────────────────── */
  .search-bar input {
    font-size: 1rem;
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius-md);
  }

  /* ── Decision tree ────────────────────────────────────────────── */
  .tree-intro h2 {
    font-size: 1.2rem;
  }

  .tree-question-card {
    padding: 1rem;
    border-radius: var(--radius-md);
  }

  .tree-question {
    font-size: 1rem;
  }

  .tree-help {
    font-size: 0.8rem;
  }

  .tree-choice-btn {
    min-height: 50px;
    padding: 0.75rem 0.9rem;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
  }

  .tree-choice-btn .choice-icon {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .tree-step-dot {
    width: 24px;
    height: 24px;
    font-size: 0.65rem;
  }

  .tree-step-indicators {
    gap: 0.25rem;
  }

  .tree-live-count {
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
  }

  /* ── Comparison view ──────────────────────────────────────────── */
  .comparison-table {
    font-size: 0.75rem;
    min-width: 420px;
  }

  .compare-col-header {
    min-width: 130px;
    padding: 0.5rem;
  }

  .compare-col-header-content {
    gap: 0.35rem;
  }

  .compare-db-name {
    font-size: 0.82rem;
  }

  .compare-row-label {
    padding: 0.5rem;
    min-width: 90px;
    width: 90px;
    font-size: 0.75rem;
  }

  .comparison-table td {
    padding: 0.5rem;
  }

  .compare-remove-btn {
    width: 28px;
    height: 28px;
  }

  /* ── Active filters ───────────────────────────────────────────── */
  .active-filters {
    flex-wrap: wrap;
    gap: 0.3rem;
  }

  .active-filter-pill {
    font-size: 0.75rem;
  }

  /* Footer */
  .app-footer {
    padding: 0.75rem;
    font-size: 0.78rem;
  }
}

/* ── Toast notification ───────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  z-index: 9999;
  padding: 0.625rem 1.5rem;
  font-size: 0.9rem;
  font-family: var(--font-family);
  font-weight: 500;
  color: var(--color-primary-text);
  background: var(--color-gray-800);
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal),
              transform var(--transition-normal);
}

.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
