/* MAIN SECTION */
.afmw-section {
  position: relative;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  background: #f5f5f7;
  border-radius: 24px;
  padding: 40px;
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.afmw-close-btn {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 32px;
  height: 32px;
  border: none !important;
  border-radius: 50% !important;
  background: #e8e8ed;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  color: #1d1d1f;
  opacity: 0;
  pointer-events: none;
  flex-shrink: 0 !important;
  padding: 0 !important;
  transition: all 0.3s ease;
}
.afmw-section.has-active-item .afmw-close-btn {
  opacity: 1;
  pointer-events: auto;
}
.afmw-close-btn:hover {
  background: #d2d2d7;
}

/* CONTENT GRID */
.afmw-content {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 60px;
  align-items: stretch;
  width: 100%;
  flex: 1;
}

/* LEFT PANEL & NAV */
.afmw-left-panel {
  position: relative;
  display: flex;
  align-items: center;
}

.afmw-side-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: absolute;
  left: -20px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
}

.afmw-nav-btn {
  background: #e8e8ed;
  border: none !important;
  width: 28px !important;
  height: 28px !important;
  border-radius: 50% !important;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #1d1d1f;
  flex-shrink: 0 !important;
  padding: 0 !important;
  transition: background 0.3s ease;
}
.afmw-nav-btn:hover {
  background: #d2d2d7;
}

/* ACCORDION LIST */
.afmw-accordion-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  padding-left: 30px;
}

.afmw-accordion-item {
  background: #e8e8ed;
  border-radius: 30px;
  overflow: hidden;
  transition: background-color 0.4s ease, border-radius 0.4s ease;
  width: fit-content;
}

.afmw-accordion-item.active {
  border-radius: 20px;
  width: 100%;
}

.afmw-accordion-trigger {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: transparent;
  border: none;
  padding: 12px 20px;
  cursor: pointer;
  text-align: left;
  color: #1d1d1f;
  font-family: inherit;
}

.afmw-plus-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid #1d1d1f;
  flex-shrink: 0;
  transition: opacity 0.3s ease;
}



.afmw-accordion-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}
.afmw-accordion-item.active .afmw-accordion-title {
  white-space: normal;
}



.afmw-accordion-content {
  display: none;
  padding: 24px;
  overflow: hidden;
}

.afmw-accordion-item.active .afmw-accordion-content {
  display: block;
}

.afmw-accordion-desc {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #1d1d1f;
}

/* RIGHT PANEL & MEDIA */
.afmw-right-panel {
  width: 100%;
  height: 100%;
}

.afmw-media-container {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 20px;
  overflow: hidden;
  background: transparent;
}

.afmw-media-default {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  transition: opacity 0.5s ease;
}

.afmw-section.has-active-item .afmw-media-default {
  opacity: 0;
}

.afmw-media-item {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.05);
  transition: opacity 0.6s ease, transform 0.6s ease;
  pointer-events: none;
  z-index: 1;
}

.afmw-media-item.active {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

/* RESPONSIVE */
@media (max-width: 1024px) {
  .afmw-content {
    display: flex;
    flex-direction: column-reverse;
    gap: 40px;
    width: 100%;
  }
  .afmw-media-container {
    height: 350px;
    min-height: 350px;
    width: 100%;
  }
  .afmw-right-panel {
    width: 100%;
  }
  .afmw-left-panel {
    width: 100%;
  }
  .afmw-accordion-list {
    padding-left: 0;
  }
  .afmw-side-nav {
    display: none;
  }
}

@media (max-width: 767px) {
  .afmw-left-panel {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
  }

  /* Closed State: Row of pills */
  .afmw-section:not(.has-active-item) .afmw-accordion-list {
    flex-direction: row;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 15px; /* for scrollbar */
    -webkit-overflow-scrolling: touch;
    align-items: center;
    width: 100%;
  }
  
  /* Hide scrollbar for a cleaner look */
  .afmw-section:not(.has-active-item) .afmw-accordion-list::-webkit-scrollbar {
    display: none;
  }
  .afmw-section:not(.has-active-item) .afmw-accordion-list {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  
  .afmw-section:not(.has-active-item) .afmw-accordion-item {
    flex-shrink: 0;
    width: auto !important;
    display: block !important;
  }

  /* Open State: Hide inactive pills */
  .afmw-section.has-active-item .afmw-accordion-item:not(.active) {
    display: none !important;
  }
  
  .afmw-section.has-active-item .afmw-accordion-item.active {
    width: 100% !important;
    max-width: 100% !important;
  }

  .afmw-section.has-active-item .afmw-accordion-list {
    width: calc(100% - 80px);
    margin: 0 auto;
    padding: 0;
  }

  /* Arrows: Vertically centered on the active description card */
  .afmw-section.has-active-item .afmw-side-nav {
    display: flex;
    flex-direction: row;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 0;
    right: 0;
    justify-content: space-between;
    width: 100%;
    z-index: 10;
    pointer-events: none; /* Let clicks pass through empty space */
  }

  .afmw-section.has-active-item .afmw-nav-btn {
    pointer-events: auto; /* Re-enable clicks on arrows */
    width: 32px !important;
    height: 32px !important;
    background: #e8e8ed;
    border-radius: 50% !important;
  }

  /* Rotate arrows to point Left/Right */
  .afmw-nav-prev svg {
    transform: rotate(-90deg);
  }
  .afmw-nav-next svg {
    transform: rotate(-90deg);
  }
}
