/* =====================================================
   FILTERS SIDEBAR - eMAG Style
   Clean, simple, professional
   ===================================================== */

:root {
  --sidebar-width: 260px;
  --sidebar-bg: #ffffff;
  --sidebar-border: #e5e5e5;
  --filter-section-bg: #fafafa;
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-muted: #999999;
  --accent-color: #e52727;
  --accent-hover: #cc2020;
  --checkbox-border: #cccccc;
  --input-border: #dddddd;
  --input-focus: #e52727;
}

/* Dark mode support */
html[data-theme="dark"] {
  --sidebar-bg: #1a1a1a;
  --sidebar-border: #333333;
  --filter-section-bg: #222222;
  --text-primary: #f0f0f0;
  --text-secondary: #bbbbbb;
  --text-muted: #888888;
  --checkbox-border: #555555;
  --input-border: #444444;
}

/* =====================================================
   SIDEBAR CONTAINER
   ===================================================== */

.filters-sidebar {
  position: fixed;
  left: 0;
  top: var(--total-header-height, 140px);
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
  transition: transform 0.3s ease;
}

/* Main content area needs margin when sidebar is visible */
.page-products .products-section {
  margin-left: var(--sidebar-width);
  transition: margin-left 0.3s ease;
}

/* =====================================================
   SIDEBAR HEADER
   ===================================================== */

.sidebar-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--sidebar-bg);
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-title i {
  color: var(--accent-color);
}

.sidebar-close {
  display: none;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}

.sidebar-close:hover {
  background: var(--filter-section-bg);
  color: var(--text-primary);
}

/* =====================================================
   SEARCH BOX
   ===================================================== */

.filter-search {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.filter-search-input {
  width: 100%;
  padding: 0.625rem 0.875rem 0.625rem 2.25rem;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  background: var(--sidebar-bg);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: all 0.2s;
}

.filter-search-input:focus {
  outline: none;
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(229, 39, 39, 0.1);
}

.filter-search-input::placeholder {
  color: var(--text-muted);
}

.filter-search-wrapper {
  position: relative;
}

.filter-search-wrapper i {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.875rem;
  pointer-events: none;
}

/* =====================================================
   LIVE SEARCH RESULTS DROPDOWN
   ===================================================== */

.live-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  max-height: 350px;
  overflow-y: auto;
  z-index: 1000;
}

.filter-search {
  position: relative;
}

.live-search-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: var(--text-primary);
  border-bottom: 1px solid var(--sidebar-border);
  transition: background 0.2s;
}

.live-search-item:hover {
  background: var(--filter-section-bg);
}

.live-search-item:last-of-type {
  border-bottom: none;
}

.live-search-image {
  width: 50px;
  height: 50px;
  object-fit: contain;
  border-radius: 4px;
  background: #fff;
  flex-shrink: 0;
}

.live-search-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.live-search-name {
  font-size: 0.8125rem;
  color: var(--text-primary);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.live-search-name strong {
  color: var(--accent-color);
  font-weight: 600;
}

.live-search-price {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-color);
}

.live-search-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.live-search-empty i {
  font-size: 1rem;
}

.live-search-all {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--filter-section-bg);
  border: none;
  color: var(--accent-color);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.live-search-all:hover {
  background: var(--accent-color);
  color: white;
}

.live-search-all i {
  font-size: 0.875rem;
}

/* =====================================================
   FILTERS CONTENT (Scrollable)
   ===================================================== */

.filters-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.filters-content::-webkit-scrollbar {
  width: 6px;
}

.filters-content::-webkit-scrollbar-track {
  background: transparent;
}

.filters-content::-webkit-scrollbar-thumb {
  background: var(--sidebar-border);
  border-radius: 3px;
}

.filters-content::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* =====================================================
   FILTER SECTION (Collapsible)
   ===================================================== */

.filter-section {
  border-bottom: 1px solid var(--sidebar-border);
}

.filter-section:last-child {
  border-bottom: none;
}

.filter-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.25rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.filter-section-header:hover {
  background: var(--filter-section-bg);
}

.filter-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.filter-section-toggle {
  color: var(--text-muted);
  font-size: 0.75rem;
  transition: transform 0.2s;
}

.filter-section.collapsed .filter-section-toggle {
  transform: rotate(-90deg);
}

.filter-section-content {
  padding: 0 1.25rem 1rem;
  display: block;
}

.filter-section.collapsed .filter-section-content {
  display: none;
}

/* =====================================================
   RADIO BUTTONS (Tip Achiziție)
   ===================================================== */

.filter-radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filter-radio {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  cursor: pointer;
  padding: 0.375rem 0;
}

.filter-radio input {
  display: none;
}

.filter-radio-mark {
  width: 18px;
  height: 18px;
  border: 2px solid var(--checkbox-border);
  border-radius: 50%;
  position: relative;
  transition: all 0.2s;
  flex-shrink: 0;
}

.filter-radio input:checked + .filter-radio-mark {
  border-color: var(--accent-color);
}

.filter-radio input:checked + .filter-radio-mark::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  background: var(--accent-color);
  border-radius: 50%;
}

.filter-radio-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: color 0.2s;
}

.filter-radio:hover .filter-radio-label {
  color: var(--text-primary);
}

.filter-radio input:checked ~ .filter-radio-label {
  color: var(--text-primary);
  font-weight: 500;
}

/* =====================================================
   PRICE INPUTS
   ===================================================== */

.filter-price-inputs {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.filter-price-field {
  flex: 1;
}

.filter-price-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.filter-price-input {
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--sidebar-bg);
  transition: all 0.2s;
}

.filter-price-input:focus {
  outline: none;
  border-color: var(--input-focus);
}

.filter-price-input::placeholder {
  color: var(--text-muted);
}

.filter-price-separator {
  color: var(--text-muted);
  font-size: 0.875rem;
  padding-top: 1rem;
}

/* =====================================================
   CHECKBOXES (Brands)
   ===================================================== */

.filter-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  cursor: pointer;
  padding: 0.375rem 0;
}

.filter-checkbox input {
  display: none;
}

.filter-checkbox-mark {
  width: 18px;
  height: 18px;
  border: 2px solid var(--checkbox-border);
  border-radius: 4px;
  position: relative;
  transition: all 0.2s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.filter-checkbox input:checked + .filter-checkbox-mark {
  background: var(--accent-color);
  border-color: var(--accent-color);
}

.filter-checkbox-mark i {
  color: white;
  font-size: 0.7rem;
  opacity: 0;
  transform: scale(0);
  transition: all 0.15s;
}

.filter-checkbox input:checked + .filter-checkbox-mark i {
  opacity: 1;
  transform: scale(1);
}

.filter-checkbox-label {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: color 0.2s;
}

.filter-checkbox:hover .filter-checkbox-label {
  color: var(--text-primary);
}

.filter-checkbox input:checked ~ .filter-checkbox-label {
  color: var(--text-primary);
}

.filter-checkbox-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--filter-section-bg);
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
}

/* Show more brands button */
.filter-show-more {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.5rem;
  padding: 0.375rem 0;
  background: none;
  border: none;
  color: var(--accent-color);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s;
}

.filter-show-more:hover {
  color: var(--accent-hover);
}

.filter-show-more i {
  font-size: 0.75rem;
  transition: transform 0.2s;
}

.filter-show-more.expanded i {
  transform: rotate(180deg);
}

/* =====================================================
   SIDEBAR FOOTER (Buttons)
   ===================================================== */

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--sidebar-border);
  background: var(--sidebar-bg);
  flex-shrink: 0;
}

.filter-apply-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--accent-color);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.filter-apply-btn:hover {
  background: var(--accent-hover);
}

.filter-apply-btn:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
}

.filter-clear-btn {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.5rem 1rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--sidebar-border);
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-clear-btn:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

/* =====================================================
   RESULTS COUNTER
   ===================================================== */

.sidebar-results {
  padding: 0.75rem 1.25rem;
  background: var(--filter-section-bg);
  text-align: center;
  flex-shrink: 0;
}

.sidebar-results-text {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0;
}

.sidebar-results-count {
  font-weight: 700;
  color: var(--accent-color);
}

/* =====================================================
   MOBILE OVERLAY
   ===================================================== */

.filters-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s;
}

.filters-overlay.visible {
  opacity: 1;
}

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

/* Tablets and smaller desktops */
@media (max-width: 1200px) {
  :root {
    --sidebar-width: 240px;
  }
}

@media (max-width: 1024px) {
  :root {
    --sidebar-width: 220px;
  }
}

/* Mobile - hide sidebar, show as overlay */
@media (max-width: 900px) {
  :root {
    --sidebar-width: 0px;
  }

  /* Hide sidebar by default on mobile */
  .filters-sidebar {
    transform: translateX(-100%);
    width: 300px;
    top: 0;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 1001;
  }

  .filters-sidebar.open,
  .filters-sidebar.active {
    transform: translateX(0);
  }

  /* Remove margin on mobile */
  .page-products .products-section {
    margin-left: 0 !important;
  }

  /* Show close button in header */
  .sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Show overlay when sidebar is open */
  .filters-sidebar.open ~ .filters-overlay,
  .filters-sidebar.active ~ .filters-overlay,
  body.filters-open .filters-overlay {
    display: block;
  }
}

@media (max-width: 480px) {
  .filters-sidebar {
    width: 100%;
    max-width: 320px;
  }
}

/* =====================================================
   LOADING STATE
   ===================================================== */

.filter-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: var(--text-muted);
}

.filter-loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--sidebar-border);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =====================================================
   NO BRANDS MESSAGE
   ===================================================== */

.filter-no-brands {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0.5rem 0;
}

/* =====================================================
   CATEGORY SECTION STYLES
   ===================================================== */

#sectionCategory .filter-section-title {
  display: flex;
  align-items: center;
}

#sectionCategory .filter-section-title i {
  font-size: 1rem;
}

.filter-no-subcats {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0.5rem 0;
  margin: 0;
}

/* Category section highlight when active */
#sectionCategory {
  background: linear-gradient(135deg, rgba(229, 39, 39, 0.03) 0%, transparent 100%);
}

#sectionCategory .filter-checkbox-label {
  font-size: 0.875rem;
}

/* First checkbox (Vezi toate) styling */
#sectionCategory .filter-checkbox:first-child {
  padding-bottom: 0.5rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px dashed var(--sidebar-border);
}

#sectionCategory .filter-checkbox:first-child .filter-checkbox-label {
  font-weight: 500;
}
