/* ============================================================
   FAQ Styles (Aesthetics based on "Услуга сборщика")
   ============================================================ */

:root {
  /* Progressive enhancement: enable native height transitions */
  interpolate-size: allow-keywords;
}

/* ------------------------------------------------------------
   1. FAQ Modal Overlay & Layout
   ------------------------------------------------------------ */
.faq-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: faqFadeIn 0.2s ease;
}

.faq-modal-overlay[hidden] {
  display: none !important;
}

@keyframes faqFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.faq-modal {
  background: #fff;
  border-radius: 24px;
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
  animation: faqSlideUp 0.25s ease;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #ddd transparent;
}

.faq-modal::-webkit-scrollbar {
  width: 4px;
}

.faq-modal::-webkit-scrollbar-track {
  background: transparent;
}

.faq-modal::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 2px;
}

@keyframes faqSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Close button inside modal */
.faq-modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f3f4f6;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  transition: background 0.15s;
  z-index: 10;
}

.faq-modal-close:hover {
  background: #e5e5e5;
}

.faq-modal-close svg {
  width: 12px;
  height: 12px;
}

.faq-modal-title {
  font-size: 20px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 20px;
  padding-right: 40px;
  line-height: 1.3;
}

/* Modal Search Bar */
.faq-modal-search-wrap {
  position: relative;
  width: 100%;
  margin-bottom: 20px;
}

.faq-modal-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: #999;
  pointer-events: none;
}

.faq-modal-search-input {
  width: 100%;
  padding: 12px 110px 12px 40px;
  border: 1.5px solid #e0e0e0;
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  color: #1a1a1a;
  background-color: #fff;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.faq-modal-search-input:focus {
  border-color: #1F9356;
}

.faq-modal-search-input::-webkit-search-cancel-button {
  display: none;
}

/* ------------------------------------------------------------
   2. Accordion Group & Items inside Modal
   ------------------------------------------------------------ */
.faq-modal-accordion-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

details.faq-item {
  background-color: #fff;
  border: 1.5px solid #e5e7eb;
  border-radius: 16px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

details.faq-item[hidden] {
  display: none !important;
}

details.faq-item:hover {
  border-color: #1F9356;
  box-shadow: 0 4px 16px rgba(31, 147, 86, 0.04);
}

details.faq-item[open],
details.faq-item.is-open {
  border-color: #1F9356;
  box-shadow: 0 6px 18px rgba(31, 147, 86, 0.06);
}

summary.faq-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  cursor: pointer;
  list-style: none;
  user-select: none;
  box-sizing: border-box;
}

summary.faq-question::-webkit-details-marker {
  display: none;
}

summary.faq-question:hover {
  color: #1F9356;
}

.faq-question-text {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}

.faq-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  transition: color 0.2s, transform 0.25s ease;
  flex-shrink: 0;
}

summary.faq-question:hover .faq-icon {
  color: #1F9356;
}

details.faq-item[open] .faq-icon,
details.faq-item.is-open .faq-icon {
  color: #1F9356;
  transform: rotate(180deg);
}

.faq-icon svg {
  width: 12px;
  height: 12px;
}

/* Accordion Content */
.faq-answer {
  box-sizing: border-box;
}

.faq-answer-inner {
  padding: 0 20px 16px 20px;
  font-size: 13.5px;
  line-height: 1.55;
  color: #555;
}

.faq-answer-inner p {
  margin: 0 0 10px;
}

.faq-answer-inner p:last-child {
  margin-bottom: 0;
}

.faq-answer-inner strong {
  color: #1a1a1a;
}

/* Lists formatting */
.faq-answer-inner ul,
.faq-answer-inner ol {
  margin: 10px 0;
  padding-left: 20px;
}

.faq-answer-inner li {
  margin-bottom: 6px;
}

.faq-answer-inner li:last-child {
  margin-bottom: 0;
}

.faq-answer-inner ul {
  list-style: none;
  padding-left: 0;
}

.faq-answer-inner ul li {
  position: relative;
  padding-left: 18px;
}

.faq-answer-inner ul li::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 8px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: #1F9356;
}

/* Formulas card style */
.faq-formula {
  background-color: #f8faf9;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 16px;
  font-family: monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  color: #1F9356;
  margin: 10px 0 12px;
  display: inline-block;
}

/* No results handling */
.faq-modal-search-no-results {
  text-align: center;
  padding: 36px 16px;
  font-size: 14px;
  color: #888;
  border: 1.5px dashed #e5e7eb;
  border-radius: 12px;
  background-color: #fcfcfc;
  margin: 0;
}

/* ------------------------------------------------------------
   3. Responsive adjustments
   ------------------------------------------------------------ */
@media (max-width: 768px) {
  .faq-modal-overlay {
    padding: 0;
    display: block;
  }
  
  .faq-modal {
    max-width: 100%;
    border-radius: 24px 24px 0 0;
    position: fixed;
    top: 70px;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: calc(100vh - 70px);
    padding: 24px 20px;
    animation: faqSlideUpMobile 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  body.admin-bar .faq-modal {
    top: 116px;
    max-height: calc(100vh - 116px);
  }

  @keyframes faqSlideUpMobile {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
}

/* ------------------------------------------------------------
   4. Search Nav & Text Highlighting
   ------------------------------------------------------------ */
.faq-search-nav {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  padding-left: 8px;
  z-index: 2;
}

.faq-search-nav[hidden] {
  display: none !important;
}

.faq-search-count {
  font-size: 12px;
  color: #777;
  font-weight: 600;
  min-width: 48px;
  text-align: right;
  user-select: none;
}

.faq-search-nav-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  padding: 0;
  transition: all 0.15s ease;
}

.faq-search-nav-btn:hover {
  border-color: #1F9356;
  color: #1F9356;
  background: rgba(31, 147, 86, 0.04);
}

.faq-search-nav-btn svg {
  width: 10px;
  height: 10px;
}

/* Highlight tags */
mark.faq-match {
  background-color: #ffeb3b; /* yellow */
  color: #000;
  border-radius: 2px;
  padding: 0 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

mark.faq-match.active-match {
  background-color: #ff9800; /* active orange match */
  color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* ============================================================
   5. Standalone FAQ Page (.faq-page-content) Styles
   ============================================================ */
.faq-page-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 10px 0 40px;
}

.faq-page-title {
  font-size: 28px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 16px;
}

.faq-page-description {
  font-size: 15px;
  line-height: 1.6;
  color: #555;
  margin-bottom: 24px;
}

.faq-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 28px;
}

.faq-search-wrap {
  position: relative;
  width: 100%;
}

.faq-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: #999;
  pointer-events: none;
}

.faq-search-input {
  width: 100%;
  padding: 12px 110px 12px 40px;
  border: 1.5px solid #e0e0e0;
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  color: #1a1a1a;
  background-color: #fff;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.faq-search-input:focus {
  border-color: #1F9356;
}

.faq-search-input::-webkit-search-cancel-button {
  display: none;
}

.faq-categories-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.faq-cat-tab {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1.5px solid #e5e7eb;
  background: #fff;
  font-size: 13.5px;
  font-weight: 500;
  color: #555;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  user-select: none;
}

.faq-cat-tab:hover {
  border-color: #1F9356;
  color: #1F9356;
}

.faq-cat-tab.active {
  border-color: #1F9356;
  background: rgba(31, 147, 86, 0.08);
  color: #1F9356;
}

.faq-accordion-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.faq-no-results-msg {
  text-align: center;
  padding: 24px;
  font-size: 15px;
  color: #777;
}

.faq-search-no-results {
  text-align: center;
  padding: 36px 16px;
  font-size: 14px;
  color: #888;
  border: 1.5px dashed #e5e7eb;
  border-radius: 12px;
  background-color: #fcfcfc;
  margin: 0;
}

.faq-modal-search-no-results[hidden],
.faq-search-no-results[hidden],
.faq-no-results-msg[hidden] {
  display: none !important;
}

@media (min-width: 768px) {
  .faq-controls {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
  }

  .faq-search-wrap {
    max-width: 320px;
    margin-bottom: 0;
  }
}
