/**
 * BIO-CLINIC SEARCH CSS v4.1.0
 * ==============================
 * Single stylesheet for ALL search components.
 * Replaces: search.css, unified-search.css, bio-search-pro.css, search-fix.css
 *
 * Components:
 * - .bs-dropdown        : Results dropdown
 * - .bs-header          : Results header
 * - .bs-section         : Result group (Specialita, Esami, etc.)
 * - .bs-item            : Individual result item
 * - .bs-empty           : No-results state
 * - .bs-footer          : CTA footer
 * - .bs-header-search   : Header search widget
 * - .bs-badge--*        : Type badges
 * - .unified-search-*   : Full-page search panel (homepage)
 *
 * (c) 2026 Bio-Clinic Sassari
 */

/* ═══════════════════════════════════════════════════════════════
   DROPDOWN CONTAINER
   ═══════════════════════════════════════════════════════════════ */
.bs-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-top: none;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  max-height: 480px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}

.bs-dropdown::-webkit-scrollbar {
  width: 6px;
}

.bs-dropdown::-webkit-scrollbar-track {
  background: transparent;
}

.bs-dropdown::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

/* Lab mode: wider max-height */
.bs-dropdown--lab {
  max-height: 520px;
}

/* ═══════════════════════════════════════════════════════════════
   RESULTS HEADER
   ═══════════════════════════════════════════════════════════════ */
.bs-header {
  padding: 8px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #eee;
  font-size: 0.75rem;
  color: #666;
}

.bs-header__count {
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════
   SECTIONS
   ═══════════════════════════════════════════════════════════════ */
.bs-section {
  padding: 4px 0;
}

.bs-section + .bs-section {
  border-top: 1px solid #f0f0f0;
}

.bs-section__title {
  padding: 6px 16px 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #00704A;
}

/* ═══════════════════════════════════════════════════════════════
   RESULT ITEMS
   ═══════════════════════════════════════════════════════════════ */
.bs-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background-color 0.12s ease;
  text-decoration: none;
  color: inherit;
}

.bs-item:hover,
.bs-item--active {
  background-color: #f0f7f4;
}

.bs-item__icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: #f5f5f5;
  border-radius: 8px;
}

.bs-item--specialty .bs-item__icon { background: #e8f5e9; }
.bs-item--procedure .bs-item__icon { background: #e3f2fd; }
.bs-item--exam .bs-item__icon      { background: #fff3e0; }
.bs-item--pack .bs-item__icon      { background: #fce4ec; }
.bs-item--pathway .bs-item__icon   { background: #f3e5f5; }
.bs-item--physician .bs-item__icon { background: #e0f7fa; }

.bs-item__body {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.bs-item__name {
  font-size: 0.875rem;
  font-weight: 500;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bs-item__name mark {
  background: #d4edda;
  color: #155724;
  border-radius: 2px;
  padding: 0 1px;
  font-weight: 700;
}

.bs-item__sub {
  font-size: 0.75rem;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

/* ═══════════════════════════════════════════════════════════════
   TYPE BADGES
   ═══════════════════════════════════════════════════════════════ */
.bs-item__badge,
[class*="bs-badge--"] {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.bs-badge--specialty  { background: #e8f5e9; color: #2e7d32; }
.bs-badge--procedure  { background: #e3f2fd; color: #1565c0; }
.bs-badge--exam       { background: #fff3e0; color: #e65100; }
.bs-badge--pack       { background: #fce4ec; color: #c62828; }
.bs-badge--pathway    { background: #f3e5f5; color: #7b1fa2; }
.bs-badge--physician  { background: #e0f7fa; color: #00838f; }

/* CTA Button for bookable items (exams, procedures) */
.bs-item__cta {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 6px;
  background: #00704A;
  color: #fff;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  transition: background-color 0.15s, transform 0.15s;
}

.bs-item:hover .bs-item__cta,
.bs-item--active .bs-item__cta {
  background: #005c3d;
  transform: scale(1.03);
}

/* ═══════════════════════════════════════════════════════════════
   EMPTY / NO RESULTS
   ═══════════════════════════════════════════════════════════════ */
.bs-empty {
  padding: 24px 20px;
  text-align: center;
}

.bs-empty__icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.bs-empty__msg {
  font-size: 0.9rem;
  color: #555;
  margin: 0 0 12px;
}

.bs-empty__hint {
  font-size: 0.8rem;
  color: #888;
  margin: 0 0 8px;
}

.bs-empty__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 16px;
}

.bs-empty__tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: #f0f7f4;
  border: 1px solid #d4edda;
  border-radius: 20px;
  font-size: 0.8rem;
  color: #00704A;
  text-decoration: none;
  transition: all 0.2s;
}

.bs-empty__tag:hover {
  background: #00704A;
  color: #fff;
  border-color: #00704A;
}

.bs-empty__cta {
  margin-top: 12px;
}

.bs-empty__cta a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #00704A;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

.bs-empty__cta a:hover {
  text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════════════
   FOOTER CTA
   ═══════════════════════════════════════════════════════════════ */
.bs-footer {
  padding: 8px 16px;
  background: #f8f9fa;
  border-top: 1px solid #eee;
  text-align: center;
  border-radius: 0 0 12px 12px;
}

.bs-footer__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #00704A;
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
}

.bs-footer__link:hover {
  text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════════════
   HEADER SEARCH WIDGET
   ═══════════════════════════════════════════════════════════════ */
.bs-header-search {
  display: flex;
  align-items: center;
  position: relative;
}

.bs-header-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background-color 0.2s;
}

.bs-header-toggle:hover {
  background: #f0f0f0;
}

.bs-header-expand {
  display: none;
  align-items: center;
  gap: 4px;
}

.bs-header-search--open .bs-header-expand {
  display: flex;
}

.bs-header-search--open .bs-header-toggle {
  display: none;
}

.bs-header-input {
  width: 200px;
  max-width: 240px;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.bs-header-input:focus {
  border-color: #00704A;
  box-shadow: 0 0 0 2px rgba(0, 112, 74, 0.15);
}

.bs-header-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: #999;
  padding: 4px;
  line-height: 1;
}

.bs-header-close:hover {
  color: #333;
}

/* Header search dropdown positioning */
.bs-header-search .bs-dropdown {
  min-width: 320px;
  right: 0;
  left: auto;
}

/* ═══════════════════════════════════════════════════════════════
   HERO SEARCH SECTION (homepage)
   ═══════════════════════════════════════════════════════════════ */
section.hero-search {
  padding-top: 100px;  /* 80px fixed-header height + 20px breathing room */
  padding-bottom: 1.5rem;
  background: linear-gradient(180deg, #f8faf9 0%, #ffffff 100%);
  text-align: center;
}

.hero-search-title {
  font-family: 'Poppins', 'Inter', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: #1a2332;
  margin: 0 0 0.35rem;
  letter-spacing: -0.01em;
}

.hero-search-subtitle {
  font-size: 0.95rem;
  color: #6b7280;
  margin: 0 0 1.5rem;
  font-weight: 400;
}

/* Search box container */
.search-box-hero {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
}

/* Input wrapper — flex row to hold input + button */
.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  /* NO overflow:hidden — dropdown is appended inside and must be visible */
}

.search-input-wrapper:focus-within {
  border-color: #00704A;
  box-shadow: 0 4px 20px rgba(0, 112, 74, 0.1), 0 0 0 3px rgba(0, 112, 74, 0.08);
}

/* The search input itself — !important to override bio-clinic-layout.css */
.search-box-hero .search-input,
.search-box-hero input[type="text"] {
  flex: 1;
  width: 100%;
  padding: 1rem 1rem 1rem 1.25rem;
  font-size: 1.05rem;
  font-family: 'Inter', sans-serif;
  color: #1a2332;
  border: none;
  background: transparent;
  outline: none;
  box-shadow: none;
}

.search-box-hero .search-input::placeholder {
  color: #9ca3af;
  font-weight: 400;
}

/* Search button (icon) */
.search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-right: 6px;
  background: #00704A;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.2s ease, transform 0.15s ease;
}

.search-btn:hover {
  background: #005c3d;
  transform: scale(1.04);
}

.search-btn:active {
  transform: scale(0.97);
}

.search-btn svg {
  width: 20px;
  height: 20px;
  color: #fff;
  stroke: #fff;
}

/* Dropdown inside hero: absolutely positioned below the input row */
.search-input-wrapper .bs-dropdown,
.search-box-hero .bs-dropdown {
  position: absolute;
  top: 100%;
  left: -2px;
  right: -2px;
  border-radius: 0 0 14px 14px;
  border: 2px solid #e2e8f0;
  border-top: 1px solid #f0f0f0;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  z-index: 9999;
  background: #fff;
}

/* Lab search box */
.lab-search-box {
  position: relative;
}

.lab-search-input-wrapper {
  position: relative;
}

.lab-search-box .bs-dropdown {
  border-radius: 0 0 12px 12px;
}

/* ═══════════════════════════════════════════════════════════════
   SUGGESTION TAGS (shared by home + lab)
   ═══════════════════════════════════════════════════════════════ */
.search-suggestions,
.lab-search-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 1.25rem;
  padding: 0 1rem;
}

.search-suggestion-tag,
.lab-suggestion-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #f0f7f4;
  border: 1px solid #d4edda;
  border-radius: 24px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
}

.search-suggestion-tag svg {
  color: #00704A;
  stroke: #00704A;
  flex-shrink: 0;
}

.search-suggestion-tag:hover,
.lab-suggestion-tag:hover {
  background: #00704A;
  color: #fff;
  border-color: #00704A;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 112, 74, 0.2);
}

.search-suggestion-tag:hover svg {
  color: #fff;
  stroke: #fff;
}

/* Lab page has dark-on-light tags */
.lab-suggestion-tag {
  background: #f3f4f6;
  border-color: #e5e7eb;
  color: #374151;
}

.lab-suggestion-tag:hover {
  background: #00704A;
  color: #fff;
  border-color: #00704A;
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  section.hero-search {
    padding-top: 86px;  /* 70px mobile header + 16px gap */
    padding-bottom: 1rem;
  }

  .hero-search-title {
    font-size: 1.25rem;
  }

  .hero-search-subtitle {
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
  }

  .search-box-hero {
    max-width: 100%;
    margin: 0 1rem;
  }

  .search-box-hero .search-input {
    font-size: 0.95rem;
    padding: 0.875rem 0.875rem 0.875rem 1rem;
  }

  .search-btn {
    width: 38px;
    height: 38px;
    margin-right: 5px;
    border-radius: 10px;
  }

  .search-btn svg {
    width: 18px;
    height: 18px;
  }

  .search-suggestions {
    gap: 8px;
    margin-top: 1rem;
  }

  .search-suggestion-tag {
    padding: 6px 12px;
    font-size: 0.8rem;
    gap: 4px;
  }

  .bs-dropdown {
    max-height: 400px;
    border-radius: 0 0 8px 8px;
  }

  .bs-item {
    padding: 8px 12px;
    gap: 8px;
  }

  .bs-item__icon {
    width: 24px;
    height: 24px;
    font-size: 0.85rem;
  }

  .bs-item__name {
    font-size: 0.82rem;
  }

  .bs-item__sub {
    font-size: 0.7rem;
  }

  .bs-item__badge,
  [class*="bs-badge--"] {
    font-size: 0.6rem;
    padding: 2px 6px;
  }

  .bs-header-input {
    width: 160px;
  }

  .bs-header-search .bs-dropdown {
    min-width: 280px;
    position: fixed;
    top: 60px;
    left: 8px;
    right: 8px;
    width: auto;
  }

  .bs-section__title {
    font-size: 0.65rem;
    padding: 4px 12px 2px;
  }
}

@media (max-width: 480px) {
  section.hero-search {
    padding-top: 82px;  /* 70px mobile header + 12px gap */
    padding-bottom: 0.75rem;
  }

  .hero-search-title {
    font-size: 1.1rem;
  }

  .search-box-hero {
    margin: 0 0.75rem;
  }

  .search-input-wrapper {
    border-radius: 12px;
  }

  .search-suggestion-tag {
    padding: 5px 10px;
    font-size: 0.78rem;
  }

  .bs-dropdown {
    max-height: 360px;
  }

  .bs-header-search .bs-dropdown {
    top: 55px;
    left: 4px;
    right: 4px;
  }

  .bs-item__badge,
  [class*="bs-badge--"] {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════════════
   ACCESSIBILITY
   ═══════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .bs-item,
  .bs-empty__tag,
  .search-suggestion-tag,
  .lab-suggestion-tag,
  .bs-header-toggle {
    transition: none;
  }
}

/* Focus visible for keyboard navigation */
.bs-item:focus-visible {
  outline: 2px solid #00704A;
  outline-offset: -2px;
}

/* High contrast mode support */
@media (forced-colors: active) {
  .bs-item--active {
    outline: 2px solid Highlight;
  }

  .bs-item__badge,
  [class*="bs-badge--"] {
    border: 1px solid currentColor;
  }
}

/* ═══════════════════════════════════════════════════════════════
   UNIFIED SEARCH PANEL (Homepage full-page results)
   Hidden by default, shown via JS .active class
   ═══════════════════════════════════════════════════════════════ */
.unified-search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.unified-search-overlay.active {
  display: block;
}

.unified-search-panel {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 720px;
  max-height: 80vh;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25);
  z-index: 10001;
  overflow: hidden;
  flex-direction: column;
}

.unified-search-panel.active {
  display: flex;
}

.unified-search-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}

.unified-search-panel-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.unified-search-panel-title svg {
  color: #00704A;
  flex-shrink: 0;
}

.unified-search-panel-title h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
}

.unified-search-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  color: #6b7280;
  transition: background 0.2s, color 0.2s;
}

.unified-search-close:hover {
  background: #f3f4f6;
  color: #1f2937;
}

.unified-search-close svg {
  width: 20px;
  height: 20px;
}

.unified-search-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  overscroll-behavior: contain;
}

.unified-search-fallback {
  text-align: center;
  padding: 2rem 1rem;
  color: #6b7280;
}

.unified-fallback-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.unified-fallback-text {
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.unified-search-panel-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  text-align: center;
  font-size: 0.85rem;
  color: #6b7280;
}

.unified-search-panel-footer a {
  color: #00704A;
  font-weight: 600;
  text-decoration: none;
}

.unified-search-panel-footer a:hover {
  text-decoration: underline;
}
