/**
 * Feeding Guidelines Modal Styles (Task 2.9)
 */

/* Modal Container */
.snw-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Overlay */
.snw-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

/* Modal Wrapper */
.snw-modal-wrapper {
  position: relative;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  z-index: 2;
  animation: snwModalFadeIn 0.3s ease-out;
}

@keyframes snwModalFadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Modal Content */
.snw-modal-content {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

/* Close Button */
.snw-modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0a2137;
  padding: 0;
  transition: opacity 0.2s ease;
}

.snw-modal-close:hover {
  opacity: 0.6;
}

/* Header */
.snw-modal-header {
  padding: 32px 32px 24px;
  text-align: center;
}

.snw-modal-header h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  color: #0a2137;
  font-family: "IBM Plex Sans", "IBM Plex Sans", sans-serif;
}

/* Body */
.snw-modal-body {
  padding: 0 32px 32px;
  overflow-y: auto;
  flex: 1;
  text-align: center;
}

/* ---- Custom Dropdown ---- */
.snw-feeding-dropdown {
  position: relative;
  margin-bottom: 28px;
}

.snw-feeding-dropdown__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 16px 20px;
  background: #f8f8f8;
  border: 1.5px solid #e0e0e0;
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
  color: #0a2137;
  text-align: left;
  transition:
    border-color 0.2s ease,
    background 0.2s ease;
}

.snw-feeding-dropdown__toggle:hover,
.snw-feeding-dropdown.open .snw-feeding-dropdown__toggle {
  border-color: #0a2137;
  background: #fff;
}

.snw-feeding-dropdown__label strong {
  font-weight: 700;
  font-size: 17px;
  color: #0a2137;
}

.snw-feeding-dropdown__chevron {
  flex-shrink: 0;
  transition: transform 0.2s ease;
  color: #0a2137;
}

.snw-feeding-dropdown.open .snw-feeding-dropdown__chevron {
  transform: rotate(180deg);
}

.snw-feeding-dropdown__menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1.5px solid #e0e0e0;
  border-radius: 12px;
  list-style: none;
  margin: 0;
  padding: 6px 0;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  max-height: 260px;
  overflow-y: auto;
}

.snw-feeding-dropdown.open .snw-feeding-dropdown__menu {
  display: block;
}

.snw-feeding-dropdown__item {
  padding: 12px 20px;
  cursor: pointer;
  font-size: 15px;
  color: #0a2137;
  transition: background 0.15s ease;
  text-align: left;
}

.snw-feeding-dropdown__item:hover {
  background: #f5f5f5;
}

.snw-feeding-dropdown__item.active {
  background: #f0f0f0;
  font-weight: 600;
  color: #0a2137;
}

/* ---- Product image & name ---- */
.snw-feeding-product {
  margin-bottom: 16px;
}

.snw-feeding-product img {
  width: 160px;
  height: auto;
  object-fit: contain;
}

.snw-feeding-product-name {
  font-size: 20px;
  font-weight: 700;
  color: #0a2137;
  margin: 0 0 24px;
  font-family: "IBM Plex Sans", "IBM Plex Sans", sans-serif;
}

/* ---- Tier content panels ---- */
.snw-feeding-tier-content {
  display: none;
  text-align: left;
}

.snw-feeding-tier-content.active {
  display: block;
}

/* Table styling matching reference design */
.snw-feeding-tier-content table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 8px;
  margin: -8px 0 12px;
}

.snw-feeding-tier-content th,
.snw-feeding-tier-content td {
  padding: 14px 20px;
  text-align: center;
  font-size: 15px;
  color: #0a2137;
  border: none;
}

.snw-feeding-tier-content thead th {
  font-weight: 600;
  color: #0a2137;
  font-size: 16px;
}

.snw-feeding-tier-content tbody tr {
  background: #f5f5f5;
}

.snw-feeding-tier-content tbody td {
  font-weight: 600;
  color: #0a2137;
  line-height: 1.5;
}

.snw-feeding-tier-content p {
  font-size: 14px;
  line-height: 1.7;
  color: #555;
  margin: 16px 0;
  text-align: center;
}

.snw-feeding-empty {
  text-align: center;
  padding: 24px 0;
  color: #999;
  font-style: italic;
}

/* Note below tier content */
.snw-feeding-note {
  font-size: 14px;
  color: #555;
  text-align: center;
  margin-top: 20px;
  line-height: 1.6;
}

/* ---- Fallback table ---- */
.snw-feeding-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 20px 0;
  text-align: left;
  overflow: hidden;
}

.snw-feeding-table thead {
  background: #0a2137;
  color: #fff;
}

.snw-feeding-table th,
.snw-feeding-table td {
  padding: 14px 20px;
  text-align: left;
}

.snw-feeding-table th {
  font-weight: 600;
  font-size: 14px;
  border: none;
}

.snw-feeding-table tbody tr {
  background: #f5f5f5;
}

.snw-feeding-table tbody tr:nth-child(even) {
  background: #fff;
}

.snw-feeding-table td {
  font-size: 14px;
  color: #0a2137;
  font-weight: 500;
  border: none;
}

/* ---- Trigger Link (next to Pet Size label) ---- */
.snw-feeding-link-wrapper {
  margin: 0;
}

.snw-feeding-guidelines-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #438fdc;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: color 0.2s ease;
  white-space: nowrap;
}

.snw-feeding-guidelines-link:hover {
  color: #0a2137;
  text-decoration: underline;
}

.snw-feeding-guidelines-link .snw-icon {
  font-size: 14px;
}

/* When positioned inline with Pet Size label */
table.variations .label.snw-has-feeding-link {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

table.variations .label.snw-has-feeding-link .snw-label-group {
  display: flex;
  align-items: center;
  gap: 0;
  white-space: nowrap;
}

table.variations .label.snw-has-feeding-link .snw-selected-attribute {
  font-weight: 700;
  color: #0a2137;
  font-size: 16px;
}

table.variations .label.snw-has-feeding-link .snw-feeding-link-wrapper {
  margin: 0;
  flex-shrink: 0;
}

table.variations .label.snw-has-feeding-link .selected-attribute {
  display: none;
}

/* Hide the swatches plugin's duplicate selected label in the value cell */
table.variations .value.snw-hide-plugin-label > span,
table.variations .value.snw-hide-plugin-label > .vsg-selected-label,
table.variations .value.snw-hide-plugin-label > p {
  display: none !important;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .snw-modal-wrapper {
    width: 95%;
    max-height: 95vh;
  }

  .snw-modal-header {
    padding: 24px 20px 18px;
  }

  .snw-modal-header h2 {
    font-size: 22px;
  }

  .snw-modal-body {
    padding: 0 20px 24px;
  }

  .snw-modal-close {
    top: 14px;
    right: 14px;
  }

  .snw-feeding-product img {
    width: 120px;
  }

  .snw-feeding-product-name {
    font-size: 18px;
  }

  table.variations .label.snw-has-feeding-link {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .snw-feeding-tier-content th,
  .snw-feeding-tier-content td {
    padding: 10px 12px;
    font-size: 13px;
  }

  .snw-feeding-dropdown__toggle {
    font-size: 14px;
    padding: 12px 14px;
  }

  .snw-feeding-dropdown__label strong {
    font-size: 15px;
  }
}
