@import '../../utils/shared-styles.scss';

.container {
  width: 100%;
  max-width: 1000px;
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

.faq {
  padding-block: 2rem 3rem;
}

/* ===== INTRO ===== */

.faq-intro {
  margin-bottom: 3rem;

  h2 {
    font-size: clamp(1.75rem, 3vw + 1rem, 2.25rem);
    font-weight: 800;
    color: $color-text-primary;
    margin: 0 0 0.5rem;
  }

  p {
    font-size: 1.0625rem;
    color: $color-text-secondary;
    margin: 0 0 2rem;
  }
}

/* ===== TOOLS ===== */

.faq-tools {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;

  @media (max-width: 640px) {
    flex-direction: column;
    align-items: stretch;
  }
}

.search-wrapper {
  position: relative;
  flex: 1;
  max-width: 520px;

  @media (max-width: 640px) {
    max-width: 100%;
  }

  .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: $color-text-secondary;
    font-size: 20px;
    pointer-events: none;
  }

  input {
    width: 100%;
    height: 48px;
    padding: 0 1rem 0 3rem;
    border: 2px solid $color-gray-200;
    border-radius: $radius-md;
    background: $color-white;
    color: $color-text-primary;
    font-size: 0.9375rem;
    transition: all 0.3s ease;

    &::placeholder {
      color: $color-gray-400;
    }

    &:focus {
      outline: none;
      border-color: $color-brand-primary;
      box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    }
  }
}

.tool-buttons {
  display: flex;
  gap: 0.5rem;

  @media (max-width: 640px) {
    width: 100%;

    .btn {
      flex: 1;
    }
  }
}

/* ===== FAQ LIST ===== */

.faq-list {
  display: grid;
  gap: 1rem;
  margin-bottom: 3rem;
}

.faq-item {
  background: $glass-bg;
  backdrop-filter: blur(10px);
  border: 1px solid $glass-border;
  border-radius: $radius-lg;
  padding: 1.25rem;
  box-shadow: $shadow-md;
  transition: all 0.3s ease;

  &:hover {
    box-shadow: $shadow-lg;
    border-color: rgba(37, 99, 235, 0.2);
  }

  summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    color: $color-text-primary;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: $radius-sm;
    transition: background 0.2s ease;

    &::-webkit-details-marker {
      display: none;
    }

    .faq-icon {
      color: $color-brand-primary;
      font-size: 24px;
      flex-shrink: 0;
    }

    .faq-question {
      flex: 1;
      font-size: 1.0625rem;
    }

    .faq-arrow {
      color: $color-text-secondary;
      font-size: 24px;
      flex-shrink: 0;
      transition: transform 0.3s ease;
    }

    &:hover {
      background: rgba(37, 99, 235, 0.04);
    }

    &:focus-visible {
      outline: none;
      box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
    }
  }

  &[open] summary .faq-arrow {
    transform: rotate(180deg);
  }

  .faq-answer {
    padding: 1rem 0 0 3rem;
    color: $color-text-secondary;
    line-height: 1.6;

    @media (max-width: 640px) {
      padding-left: 0;
    }

    p {
      margin: 0.75rem 0;
      font-size: 0.9375rem;

      &:first-child {
        margin-top: 0;
      }

      &:last-child {
        margin-bottom: 0;
      }
    }

    ul {
      margin: 0.75rem 0;
      padding-left: 1.5rem;

      li {
        margin-bottom: 0.5rem;
        font-size: 0.9375rem;
      }
    }
  }
}

/* ===== NO HITS ===== */

.faq-nohits {
  text-align: center;
  padding: 3rem 2rem;

  .nohits-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1.5rem;
    background: $color-gray-100;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;

    .material-symbols-outlined {
      font-size: 36px;
      color: $color-text-secondary;
    }
  }

  p {
    font-size: 1rem;
    color: $color-text-secondary;
    margin: 0;

    a {
      color: $color-brand-primary;
      text-decoration: none;
      font-weight: 600;
      cursor: pointer;

      &:hover {
        text-decoration: underline;
      }
    }
  }
}

/* ===== CTA ===== */

.faq-cta {
  .cta-card {
    background: $gradient-subtle;
    border: 1px solid rgba(37, 99, 235, 0.15);
    border-radius: $radius-2xl;
    padding: 3rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;

    &::before {
      content: '';
      position: absolute;
      inset: 0;
      background: 
        radial-gradient(circle at 20% 50%, rgba(37, 99, 235, 0.06), transparent 50%),
        radial-gradient(circle at 80% 50%, rgba(59, 130, 246, 0.04), transparent 50%);
      pointer-events: none;
    }

    > * {
      position: relative;
      z-index: 1;
    }

    .cta-icon {
      width: 72px;
      height: 72px;
      margin: 0 auto 1.5rem;
      background: $gradient-primary;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: $shadow-brand;

      .material-symbols-outlined {
        font-size: 36px;
        color: white;
      }
    }

    h3 {
      font-size: clamp(1.5rem, 3vw + 1rem, 1.75rem);
      font-weight: 800;
      color: $color-text-primary;
      margin: 0 0 0.75rem;
    }

    p {
      font-size: 1.0625rem;
      color: $color-text-secondary;
      margin: 0 0 2rem;
      max-width: 500px;
      margin-inline: auto;
    }

    .btn {
      @media (max-width: 640px) {
        width: 100%;
      }
    }
  }
}

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

.faq-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  gap: 1rem;
  
  .loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba($color-brand-primary, 0.2);
    border-top-color: $color-brand-primary;
    border-radius: 50%;
    animation: spin 1s linear infinite;
  }
  
  p {
    color: $color-text-secondary;
    font-size: 1rem;
    margin: 0;
  }
}

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

/* ===== MESSAGE STATES (Error / Empty) ===== */

.faq-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  background: $color-background-elevated;
  border-radius: 1.5rem;
  border: 1px solid $color-gray-200;
  
  .message-icon {
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba($color-brand-primary, 0.1);
    border-radius: 50%;
    margin-bottom: 1.5rem;
    
    .material-symbols-outlined {
      font-size: 36px;
      color: $color-brand-primary;
    }
    
    &.message-icon--construction {
      background: rgba(#f59e0b, 0.15);
      
      .material-symbols-outlined {
        color: #f59e0b;
      }
    }
  }
  
  h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: $color-text-primary;
    margin: 0 0 0.75rem;
  }
  
  p {
    font-size: 1.0625rem;
    color: $color-text-secondary;
    margin: 0 0 1rem;
    max-width: 400px;
  }
  
  .message-sub {
    font-size: 0.9375rem;
    margin-bottom: 1.5rem;
  }
  
  .btn {
    margin-top: 0.5rem;
  }
}

/* ===== MOTION ===== */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}