/* ═══════════════════════════════════════════════════════════
   Apparel Category Sidebar — left filter rail
═══════════════════════════════════════════════════════════ */

/* Layout wrapper around sidebar + product grid.
   !important is used here defensively — Avada and other themes set width: 100%
   on shop loop children, which collapses flex layouts unless we win specificity. */
.tac-cat-layout {
  display: flex !important;
  align-items: flex-start !important;
  gap: 28px !important;
  max-width: 100% !important;
  width: 100% !important;
  margin: 0 0 24px !important;
  clear: both;
}

.tac-cat-sidebar {
  flex: 0 0 240px !important;
  width: 240px !important;
  max-width: 240px !important;
  position: relative;
  background: #fff;
  border: 1px solid #ececec;
  border-radius: 10px;
  padding: 20px 16px;
  font-size: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
  box-sizing: border-box;
}

/* The main area takes the remaining space.
   width: auto important — themes often set width: 100% on UL.products which
   ignores its flex sibling and overflows. */
.tac-cat-main {
  flex: 1 1 0% !important;
  width: auto !important;
  min-width: 0 !important; /* prevents grid blowout */
  max-width: 100% !important;
}

/* Sections */
.tac-cat-section {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid #f0f0f0;
}
.tac-cat-section:last-child {
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}
.tac-cat-section-title {
  font-size: 11px;
  font-weight: 700;
  color: #333;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 0 0 10px;
  padding: 0;
}

/* Search box */
.tac-cat-search {
  display: flex;
  gap: 4px;
}
.tac-cat-search-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  width: 100%;
}
.tac-cat-search-input:focus {
  outline: none;
  border-color: #1a73e8;
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.15);
}
.tac-cat-search-btn {
  background: #1a1a1a;
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  cursor: pointer;
  font-size: 14px;
}
.tac-cat-search-btn:hover { background: #333; }

/* Category tree */
.tac-cat-tree,
.tac-cat-tree-sub {
  list-style: none;
  padding: 0;
  margin: 0;
}
.tac-cat-tree-sub {
  margin-left: 14px;
  margin-top: 4px;
  padding-left: 8px;
  border-left: 1px solid #eee;
}
.tac-cat-tree-item {
  margin: 2px 0;
}
.tac-cat-tree-item a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  color: #333;
  text-decoration: none;
  border-radius: 5px;
  font-size: 13px;
  transition: background .12s, color .12s;
}
.tac-cat-tree-item a:hover {
  background: #f5f5f5;
  color: #1a1a1a;
}
.tac-cat-tree-current > a {
  background: #1a1a1a;
  color: #fff;
  font-weight: 600;
}
.tac-cat-tree-current > a:hover {
  background: #1a1a1a;
  color: #fff;
}
.tac-cat-count {
  color: #999;
  font-size: 11px;
  font-weight: 400;
  margin-left: 8px;
}
.tac-cat-tree-current > a .tac-cat-count {
  color: rgba(255,255,255,0.7);
}

/* Filter checkboxes */
.tac-cat-filter-list {
  max-height: 240px;
  overflow-y: auto;
  padding-right: 4px;
}
.tac-cat-filter-list::-webkit-scrollbar { width: 6px; }
.tac-cat-filter-list::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 3px;
}
.tac-cat-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
  transition: background .1s;
}
.tac-cat-filter-row:hover { background: #f8f8f8; }
.tac-cat-filter-row input[type="checkbox"] {
  flex-shrink: 0;
  margin: 0;
  cursor: pointer;
}
.tac-cat-filter-label {
  flex: 1;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tac-cat-filter-count {
  font-size: 11px;
  color: #999;
  background: #f4f4f4;
  padding: 1px 7px;
  border-radius: 10px;
  flex-shrink: 0;
}

/* Action buttons */
.tac-cat-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tac-cat-apply-btn {
  width: 100%;
  padding: 10px 14px;
  background: #1a1a1a;
  color: #fff;
  border: 0;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.tac-cat-apply-btn:hover { background: #333; }
.tac-cat-clear-btn {
  display: block;
  text-align: center;
  padding: 8px;
  font-size: 12px;
  color: #c33;
  text-decoration: none;
  border: 1px solid #f0f0f0;
  border-radius: 999px;
  background: #fff;
}
.tac-cat-clear-btn:hover {
  background: #fee;
  border-color: #c33;
}

/* Close button (mobile only) */
.tac-cat-sidebar-close {
  display: none;
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: 0;
  font-size: 26px;
  line-height: 1;
  color: #888;
  cursor: pointer;
  padding: 4px 10px;
}

/* Mobile filter toggle button (hidden on desktop) */
.tac-cat-filter-toggle {
  display: none;
  position: relative;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #1a1a1a;
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 16px;
}
.tac-cat-active-pill {
  background: #f9c02e;
  color: #1a1a1a;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
}

/* ─── Mobile (≤ 900px) ─── */
@media (max-width: 900px) {
  .tac-cat-layout {
    display: block !important;
  }
  .tac-cat-filter-toggle {
    display: inline-flex;
  }
  .tac-cat-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    z-index: 9999;
    transform: translateX(-100%);
    transition: transform .25s ease;
    overflow-y: auto;
    border-radius: 0;
    box-shadow: 4px 0 16px rgba(0,0,0,0.15);
    padding-top: 50px;
  }
  .tac-cat-sidebar.tac-cat-sidebar-open {
    transform: translateX(0);
  }
  .tac-cat-sidebar-close {
    display: block;
  }
  body.tac-cat-sidebar-backdrop {
    overflow: hidden;
  }
  body.tac-cat-sidebar-backdrop::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 9998;
  }
  .tac-cat-main {
    width: 100%;
  }
}
