/* Hebrew RTL Support */
.archive-container.he,
.archive-container.he .filter-sidebar,
.archive-container.he .main-content {
  direction: rtl;
  text-align: right;
}

.archive-container.he .search-bar input {
  text-align: right;
  padding: 10px 40px 10px 15px;
  box-sizing: border-box;
}

.archive-container.he .search-bar .search-icon {
  left: 12px;
  right: auto;
  z-index: 10;
  pointer-events: none;
}

.archive-container.he .record-header {
  flex-direction: row-reverse;
}

.archive-container.he .record-header-right {
  order: -1;
  /* Move to the left side in RTL */
}

.archive-container.he .record-title-section {
  text-align: right;
}

.archive-container.he .modal-content {
  text-align: right;
  direction: rtl;
}

.archive-container.he .modal-link-button {
  flex-direction: row-reverse;
}

.archive-container.he .filter-sidebar {
  border-right: none;
  border-left: 1px solid #eee;
  padding-right: 0;
  padding-left: 20px;
}

/* Fix suggestions dropdown for RTL */
.archive-container.he .search-suggestions {
  text-align: right;
  direction: rtl;
}

.archive-container.he .suggestion-item {
  text-align: right;
  flex-direction: row-reverse;
}

.archive-container.he .suggestion-label {
  margin-right: 0;
  margin-left: 8px;
}

/* Fix filter headers and content for RTL */
.archive-container.he .filter-header {
  text-align: right;
  /*                 flex-direction: row-reverse; */
}

.archive-container.he .filter-option {
  flex-direction: row-reverse;
  text-align: right;
}

.archive-container.he .filter-option input {
  margin-right: 0;
  margin-left: 8px;
  order: 2;
}

.archive-container.he .filter-option label {
  order: 1;
  text-align: right;
  flex: 1;
}

.archive-container.he .filter-content {
  text-align: right;
}

.archive-container.he .subcategory-header {
  text-align: right;
  flex-direction: row-reverse;
}

.archive-container.he .subcategory-content {
  text-align: right;
}

/* Comprehensive CSS adapted from new.php for visual consistency */
.archive-container {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 25px;
  width: 100%;
  margin-left: 0;
  color: #5C5A5A;
}

/* Center English layout within the theme content area to avoid left anchoring */
.archive-container.en {
  margin: 0 auto;
  direction: ltr;
}

.doctors-header {
  display: flex;
  flex-direction: column;
  margin-top: 1em;
  margin-bottom: 2em;
  margin-inline-start: 3rem;
  /* 				font-family:var(--bodyfontfamily),var(--nv-fallback-ff); */
  color: #5C5A5A;
}

.filters-toggle { display: none; margin-bottom: 10px; }

.doctors-header p {
  font-size: 1rem;
  margin: 0 0 1rem 0;
  color: #5C5A5A;
  font-style: italic;
}

.doctors-header a {
  text-decoration: underline;
  color: #5C5A5A;
  font-style: italic;
  width: fit-content;
  color: inherit;
}

/* Hide mobile filter toggle on desktop */
#mobile-filters-toggle {
  display: none;
}

.filter-sidebar {
  padding-right: 20px;
}

.filter-sidebar h2 {
  font-size: 1.2em;
  margin-top: 0;
}

.filter-actions {
  margin-bottom: 15px;
}

.filter-section {
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 15px;
  box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.3);
  padding: 1px 0.5rem;
}

.filter-content.date-filters-wrapper {
  gap: 1rem;
}

.filter-content.date-filters-wrapper .date-filter input {
  border: 1px solid #aaa;
  border-radius: 3px;
}

.filter-header {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
}

.filter-header i {
  transition: transform 0.3s ease;
}

.filter-header.active i {
  transform: rotate(180deg);
}

.filter-content {
  display: none;
  padding: 5px;
  padding-top: 10px;
}

.filter-option {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.9em;
}

.filter-option input {
  margin-right: 8px;
}

.filter-option label {
  word-break: break-word;
  line-height: 1.4;
}

.filter-count {
  font-size: 0.9em;
  color: #666;
  font-weight: normal;
}

.view-more-button {
  display: block;
  margin: 8px 0;
  padding: 5px;
  text-align: center;
  background-color: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85em;
}

.hidden-filter {
  display: none !important;
}

.search-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.search-bar-container {
  position: relative;
  flex-grow: 1;
}

.search-bar {
  display: flex;
  align-items: center;
  position: relative;
}

.search-bar .search-icon {
  position: absolute;
  left: 12px;
  color: #aaa;
  z-index: 10;
  pointer-events: none;
}

.search-bar input {
  width: 100%;
  padding: 10px 15px 10px 40px;
  border-radius: 5px;
  border: 1px solid #ccc;
  box-sizing: border-box;
}

.control-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 2rem;
  height: 48px;
  background-color: #fff !important;
  color: black !important;
  border: 1px solid #ddd;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.3s;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 400;
}

.control-button#reset-filters-doctors {
  font-family: var(--bodyfontfamily), var(--nv-fallback-ff);
}

.control-button:hover {
  border: 2px solid #ddd;
}

.record-count {
  margin-bottom: 15px;
  color: #555;
  font-size: 0.9em;
}

.results-container {
  column-count: 2;
  column-gap: 1rem;
}

.record-doctors {
  background: #fff;
  padding: 2rem 1.5rem 1rem 1.5rem;
  margin-bottom: 0.5rem;
  margin-inline-end: 0.75rem;
  cursor: pointer;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  height: fit-content;
  break-inside: avoid;
}

.record-doctors:hover {
  background-color: #F4F1ED;
}

.testimony-tags-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block: 2rem;
}

.testimony-tag {
  border: 1px solid #5C5A5A;
  padding: 0 10px;
  border-radius: 1rem;
  font-size: 0.75rem;
}

.record-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.record-title-section {
  flex: 1;
}

.record-header h3 {
  margin: 0;
  font-size: 1.2em;
  line-height: 1.4;
  font-style: italic;
  line-height: 1.8rem;
}

.record-header h3 span {
  padding: 1px 5px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.record-header-right {
  display: flex;
  align-items: center;
  gap: 15px;
  padding-inline-start: 0.5rem;
}

.record-link-icon {
  font-size: 0.8rem;
  color: #5C5A5A;
  text-decoration: none;
}

.record-link-icon:hover {
  color: #5C5A5A;
}

.record-author {
  font-size: 0.9em;
  color: #444;
  margin-bottom: 5px;
  padding: 1rem 0.8rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.record-author h4.witness-name {
  color: #A65C5B;
  margin: 0;
  font-weight: 600;
  font-family: var(--bodyfontfamily);
  font-size: 0.9rem;
}

.record-author .witness-details {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.record-author .witness-details img {
  height: 1rem;
}

.record-divider {
  border: 0;
  border-top: 1px solid #f0f0f0;
  margin: 12px 0;
}

.record-footer {
  font-size: 0.85em;
  color: #666;
}

.modal {
  display: none;
  position: fixed;
  z-index: 1001;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.6);
}

.modal-content {
  background-color: #fff;
  margin: 8% auto;
  padding: 25px 35px;
  border: 1px solid #888;
  width: 90%;
  max-width: 800px;
  border-radius: 8px;
  position: relative;
  box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
}

.modal .close {
  position: absolute;
  top: 15px;
  right: 25px;
  color: #aaa;
  font-size: 30px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
}

.archive-container.he .modal .close {
  right: auto;
  left: 25px;
}

.modal h2 {
  margin-top: 0;
}

.modal-content-doctors p {
  line-height: 1.6;
  border-bottom: 1px solid #eee;
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.modal-content-doctors p:last-child {
  border-bottom: none;
}

.modal-content-doctors strong {
  color: #333;
}

.active-filters {
  margin-bottom: 15px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-tag {
  display: inline-flex;
  align-items: center;
  background-color: #007bff;
  color: #fff;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.9em;
}

.filter-tag .term-text {
  margin-inline-end: 6px;
}

.filter-tag .remove-term {
  cursor: pointer;
  font-size: 1.1em;
  font-weight: bold;
  line-height: 1;
  color: #fff;
}

.filter-tag:not(:last-child) {
  position: relative;
  margin-inline-end: 40px;
}

.filter-tag:not(:last-child)::after {
  content: "AND";
  position: absolute;
  inset-inline-end: -35px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75em;
  color: #666;
  font-weight: 600;
  pointer-events: none;
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-bottom: 10px;
}

.modal-chip {
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 0.85em;
  font-weight: 500;
  background-color: #f0f0f0;
  color: #333;
  border: 1px solid #ddd;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.modal-chip.themes {
  background-color: #e7f3ff;
  color: #005a9e;
  border-color: #b3d7ff;
}

.modal-chip.orgs {
  background-color: #e6f7f4;
  color: #00645a;
  border-color: #b3e6e0;
}

.modal-chip.locations {
  background-color: #fff4e6;
  color: #995400;
  border-color: #ffdcb3;
}

.modal-chip.figures {
  background-color: #f3e6f7;
  color: #5a0064;
  border-color: #dcb3e6;
}

.modal-chip:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Tag subcategory styles */
.tag-subcategory {
  margin-bottom: 10px;
  border-bottom: 1px solid #f0f0f0;
  padding-bottom: 5px;
}

.subcategory-header {
  font-weight: 500;
  cursor: pointer;
  padding: 5px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9em;
  background-color: #f8f9fa;
  border-radius: 4px;
  margin-bottom: 2px;
  color: #333;
}

.subcategory-header.active {
  background-color: #e9ecef;
}

.subcategory-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.2s ease, transform 0.2s ease;
  padding-left: 10px;
  opacity: 0;
  transform: translateY(-5px);
  background-color: #f8f9fa;
  border-radius: 0 0 4px 4px;
}

.subcategory-content.active {
  max-height: 500px;
  overflow-y: auto;
  opacity: 1;
  transform: translateY(0);
  padding: 8px 10px;
  margin-bottom: 8px;
}

.disturbing-content-warning {
  background-color: #ffebee;
  /* Light red background */
  color: #c62828;
  /* Darker red text */
  padding: 8px 12px;
  border-radius: 4px;
  margin-top: 10px;
  font-size: 0.9em;
  font-weight: bold;
  text-align: center;
  border: 1px solid #ef9a9a;
  /* Lighter red border */
}

.modal-publication-info {
  margin-top: 10px;
  font-size: 0.9em;
  color: #555;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
}

.modal-link-button {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.modal-link-button a {
  background-color: #f5f5f5;
  border: 1px solid #ccc;
  padding: 8px 12px;
  border-radius: 4px;
  text-decoration: none;
  color: #333;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.9em;
}

.modal-link-button a:hover {
  background-color: #e0e0e0;
  border-color: #bbb;
}

.modal-link-button a i {
  font-size: 0.9em;
}

/* Suggestions dropdown */
.search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: none;
  max-height: 220px;
  overflow-y: auto;
}

.suggestion-item {
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f5f5f5;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.selected {
  background-color: #f5f9ff;
}

.suggestion-label {
  font-size: 0.8em;
  color: #777;
  background: #f0f0f0;
  padding: 2px 8px;
  border-radius: 10px;
  margin-right: 8px;
  flex-shrink: 0;
}

.suggestion-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mobile responsiveness */
@media only screen and (max-width: 1200px) {
  .results-container {
    column-count: 1;
  }
}

@media only screen and (max-width: 768px) {

  /* Hebrew mobile RTL adjustments */
  .archive-container.he {
    left: auto !important;
    right: 50% !important;
    margin-left: 0 !important;
    margin-right: -50vw !important;
  }

  .archive-container.he .search-bar input {
    text-align: right !important;
    padding: 8px 32px 8px 8px !important;
    box-sizing: border-box !important;
  }

  .archive-container.he .search-icon {
    left: 8px !important;
    right: auto !important;
    z-index: 10 !important;
    pointer-events: none !important;
  }

  .archive-container.he .record-header {
    flex-direction: column-reverse !important;
  }

  .archive-container.he .filter-option {
    flex-direction: row-reverse !important;
  }

  .archive-container.he .filter-option input {
    order: 2 !important;
    margin-left: 6px !important;
    margin-right: 0 !important;
  }

  .archive-container.he .filter-option label {
    order: 1 !important;
    text-align: right !important;
  }

  /* Layout adjustments */
  .archive-container {
    grid-template-columns: 1fr !important;
    display: block !important;
    position: relative !important;
    width: 100vw !important;
    left: 50% !important;
    right: 50% !important;
    margin-left: -50vw !important;
    margin-right: -50vw !important;
    box-sizing: border-box !important;
    padding: 0 5vw !important;
    gap: 15px !important;
  }

  .filters-toggle { display: inline-flex !important; align-items: center; gap: 6px; }

  .doctors-header {
    margin-inline-start: 1rem;
  }

  .doctors-header h2 {
    margin: 0.5rem 0 1rem 0;
    line-height: 1.8rem;
  }

  .testimony-tags-wrapper {
    margin-block: 1.4rem 1rem;
  }

  .filter-sidebar {
    position: relative !important;
    height: auto !important;
    top: 0 !important;
    left: 0 !important;
    margin-bottom: 20px !important;
    border-right: none !important;
    border-bottom: 1px solid #eaeaea !important;
    width: 100% !important;
    padding: 0 !important;
  }

  /* Mobile filter collapse system */
  #mobile-filters-toggle {
    display: block;
  }

  .mobile-filter-toggle:hover {
    background-color: #e9ecef !important;
  }

  .mobile-filter-toggle i {
    margin-left: 8px !important;
    transition: transform 0.3s ease !important;
  }

  /* Hebrew RTL mobile filter toggle adjustments */
  .archive-container.he .mobile-filter-toggle i {
    margin-left: 0 !important;
    margin-right: 8px !important;
  }

  .mobile-filter-toggle.active i {
    transform: rotate(180deg) !important;
  }

  .mobile-filter-content.active {
    display: block !important;
  }

  .main-content {
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Search controls - keep on same line */
  .search-controls {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 5px !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    margin: 15px 0 !important;
    padding: 0 !important;
  }

  .search-bar-container {
    flex: 1 !important;
    min-width: 0 !important;
  }

  .search-bar input {
    font-size: 14px !important;
    padding: 8px 8px 8px 32px !important;
  }

  .search-icon {
    left: 8px !important;
  }

  .control-buttons {
    display: flex !important;
    flex-shrink: 0 !important;
    gap: 5px !important;
    white-space: nowrap !important;
    justify-content: flex-end !important;
    width: 35% !important;
  }

  /* Override for text-containing buttons on mobile */
  #reset-filters-doctors {
    padding: 10px 15px !important;
    height: auto !important;
    min-height: 38px !important;
    border: 3px solid #666;
    border-radius: 3px;
    font-family: var(--bodyfontfamily), var(--nv-fallback-ff);
  }

  #about-button-doctors {
    width: auto !important;
    padding: 8px 15px !important;
    height: auto !important;
    min-height: 38px !important;
    min-width: 60px !important;
  }

  .control-button {
    padding: 8px !important;
    height: 38px !important;
    min-width: 38px;
    font-size: 14px !important;
    min-width: 0 !important;
    border-radius: 5px !important;
  }

  .control-button span {
    display: none !important;
  }

  /* Active filters mobile adjustments */
  .active-filters {
    margin: 10px 0 !important;
    gap: 6px !important;
  }

  .filter-tag {
    font-size: 0.85em !important;
    padding: 3px 8px !important;
    margin-right: 35px !important;
    margin-bottom: 8px !important;
  }

  .filter-tag:not(:last-child)::after {
    right: -30px !important;
    font-size: 0.7em !important;
  }

  /* Record layout mobile adjustments */
  .record-doctors {
    padding: 12px 15px !important;
    margin-bottom: 12px !important;
  }

  .record-header {
    flex-direction: row;
    align-items: flex-start !important;
    gap: 8px !important;
  }

  /* Modal adjustments for mobile */
  .modal-content {
    width: 95% !important;
    margin: 5% auto !important;
    padding: 15px 20px !important;
  }

  .modal-tags {
    gap: 5px !important;
  }

  .modal-chip {
    padding: 4px 8px !important;
    font-size: 0.8em !important;
  }

  /* Filter sections mobile adjustments */
  .filter-section {
      box-shadow: none;
      margin-bottom: 15px;
      border: none;
      border-radius: 0;
      overflow: hidden;
      will-change: max-height;
      transform: translateZ(0);
  }

  .filter-header {
      padding: 10px 0;
      background-color: transparent;
      cursor: pointer;
      font-weight: 500;
      display: flex;
      justify-content: space-between;
      align-items: center;
      color: #333;
      border-bottom: 1px solid #f0f0f0;
  }

  .filter-option {
    margin-bottom: 6px !important;
    font-size: 0.85em !important;
  }

  .subcategory-header {
    font-size: 0.85em !important;
    padding: 6px 8px !important;
  }

  .subcategory-content {
    padding: 6px 8px !important;
  }

  /* Archive title mobile improvements */
  #archive-title-doctors {
    font-size: 1.4rem !important;
    margin: 0 !important;
    line-height: 1.2 !important;
    text-align: left !important;
  }

  /* Title container improvements for mobile */
  .archive-container>div:first-child {
    margin: 10px 0 !important;
    padding: 0 !important;
  }

  /* Hebrew title mobile adjustments */
  .archive-container.he #archive-title-doctors {
    text-align: center !important;
    direction: rtl !important;
  }

  /* Hide mobile filter toggle on mobile since we use full-width sidebar */
  #mobile-filter-toggle {
    display: none !important;
  }

  /* Fix: Prevent left-side cutoff on English mobile by disabling full-bleed offsets */
  .archive-container.en {
    width: 100% !important;
    left: 0 !important;
    right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 0 !important;
    /* allow content to occupy entire width */
  }

  /* Remove default body margin so content can truly span the viewport */
  body {
    margin: 0 !important;
  }
}

/* Apple iPhone and other mobile device specific adjustments */
@media only screen and (max-device-width: 812px) and (-webkit-min-device-pixel-ratio: 2) {
  .search-controls {
    display: flex !important;
    flex-direction: row !important;
  }

  .control-buttons {
    width: 30% !important;
    display: flex !important;
  }
}

/* Special adjustments for very small screens */
@media only screen and (max-width: 480px) {
  .control-buttons {
    width: 25% !important;
  }

  .control-buttons .control-button span {
    display: none !important;
  }

  .control-buttons .control-button {
    padding: 0 !important;
    width: 38px !important;
    justify-content: center !important;
  }

  .filter-tag {
    font-size: 0.8em !important;
    padding: 2px 6px !important;
    margin-right: 30px !important;
  }

  .filter-tag:not(:last-child)::after {
    right: -25px !important;
    font-size: 0.65em !important;
  }

  .modal-content {
    width: 98% !important;
    padding: 10px 15px !important;
  }
}

/* Large screen adjustments */
@media (min-width: 1200px) {
  .archive-container {
    margin-left: 0;
    width: 100%;
  }

  .main-content {
    padding-left: 20px;
  }
}