/* ---- Horizontal scroll card list (spot show page) ---- */
.alert-card-list {
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  gap: 0.625rem;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  align-items: stretch;
}

.alert-card {
  position: relative;
  flex-shrink: 0;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.55rem 0.75rem;
  min-width: 130px;
  max-width: 200px;
  border: 2px solid #d1d5db;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.12s, background 0.12s;

  &.alert-card--selected {
    background: #eff6ff;
    border-color: #3b82f6;

    & .alert-card__name { color: #1d4ed8; }
    & .alert-card__condition { color: #3b82f6; }
  }

  &:not(.alert-card--selected):hover {
    border-color: #9ca3af;
  }
}

.alert-card__edit {
  position: absolute;
  top: 0.3rem;
  right: 0.5rem;
  font-size: 0.7rem;
  color: #6b7280;
  text-decoration: underline;
  opacity: 0;
  transition: opacity 0.12s;
}

.alert-card:hover .alert-card__edit {
  opacity: 1;
}

.alert-card__name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alert-card__condition {
  font-size: 0.75rem;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-theme="dark"] .alert-card {
  border-color: #374151;

  & .alert-card__name { color: #f1f5f9; }
  & .alert-card__condition { color: #94a3b8; }

  &.alert-card--selected {
    background: #1e3a5f;
    border-color: #3b82f6;
    & .alert-card__name { color: #93c5fd; }
    & .alert-card__condition { color: #60a5fa; }
  }
}

.home-content {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.home-content__alerts {
  width: 400px;
  flex-shrink: 0;
}

.home-content__sessions {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.alert-list--home {
  & .alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
  }

  & .alert:last-child {
    border-bottom: none;
  }

  & .alert__filter-checkbox {
    flex-shrink: 0;
  }

  & .alert__name {
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
  }

  & .alert__conditions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
    font-size: 0.8rem;
    color: var(--secondary-text-color);
  }

  & .alert__link {
    display: none;
  }

  & .alert:has(.alert__filter-checkbox input:not(:checked)) {
    & .alert__name {
      opacity: 0.4;
    }
    & .alert__conditions {
      opacity: 0.55;
    }
  }
}

.alert-list {
  & .alert {
    margin-bottom: 1rem;
  }

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

  & .alert__name {
    font-weight: bold;
  }
}

.alert-list--grid {
  --grid-space: 1rem;
  --item-min-width: 200px;

  display: grid;
  gap: var(--grid-space);
  grid-template-columns: 1fr;

  @media (min-width: 640px) {
    grid-template-columns: repeat(3, 1fr);
  }

  @media (min-width: 1024px) {
    grid-template-columns: repeat(auto-fit, minmax(var(--item-min-width), 1fr));
  }
}

.alert-list--style-1 {
  & .alert {
    border: 1px solid #dddddd;
    border-radius: 1rem;
    padding: 1rem;
    background-color: white;
  }

  & .alert__name {
    font-weight: 700;
  }
}

.alert-list--table {
  display: table;
  width: 100%;
  /* border-collapse: collapse; */
  border: 1px solid #dddddd;
  border-radius: 1rem;
  /* padding: 1rem; */
  background-color: white;

  & .alert {
    display: table-row;
    border-bottom: 1px solid #dddddd;
  }

  & .alert:last-child {
    border-color: transparent;
  }

  & .alert__name {
    display: table-cell;
    font-weight: bold;
    padding: 1rem;
  }

  & .alert__conditions {
    display: contents; /* let children participate in the table layout */
  }

  & .alert__wind-conditions {
    display: table-cell;
    padding: 1rem;
  }

  & .alert__wind-direction {
    display: table-cell;
    padding: 1rem;
  }

  & .alert__wave-conditions {
    display: table-cell;
    padding: 1rem;
  }

  & .alert__wave-period-conditions {
    display: table-cell;
    padding: 1rem;
  }

  & .alert__wave-direction-conditions {
    display: table-cell;
    padding: 1rem;
  }

  & .alert__filter-checkbox {
    display: table-cell;
    padding: 0.75rem 0.5rem 0.75rem 1rem;
    vertical-align: middle;
    width: 56px;
  }

  & .alert__actions {
    text-align: right;
    padding-right: 1rem;
  }

  & .alert__subscribe-btn {
    display: table-cell;
    vertical-align: middle;
    padding: 0.75rem 1rem;
  }

  & .alert:has(.alert__filter-checkbox input:not(:checked)) {
    opacity: 0.4;
  }

  @media (max-width: 768px) {
    display: block;

    & .alert {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      column-gap: 0.5rem;
      row-gap: 0.25rem;
      padding: 0.75rem 1rem;
      border-bottom: 1px solid #dddddd;
    }

    & .alert:last-child {
      border-bottom-color: transparent;
    }

    & .alert__filter-checkbox {
      display: flex;
      padding: 0;
      flex-shrink: 0;
      vertical-align: unset;
    }

    & .alert__name {
      display: block;
      flex: 1;
      padding: 0;
    }

    & .alert__conditions {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 0.375rem 0.75rem;
      width: 100%;
      font-size: 0.8125rem;
      color: var(--secondary-text-color);
    }

    & .alert__wind-conditions,
    & .alert__wind-direction,
    & .alert__wave-conditions,
    & .alert__wave-period-conditions,
    & .alert__wave-direction-conditions {
      display: flex;
      align-items: center;
      padding: 0;
    }
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .alert-list--table {
    border-color: transparent;

    & .alert__name,
    & .alert__wind-conditions,
    & .alert__wind-direction,
    & .alert__wave-conditions,
    & .alert__wave-period-conditions,
    & .alert__wave-direction-conditions {
      color: #1f2937;
    }
  }
}

[data-theme="dark"] .alert-list--table {
  border-color: transparent;

  & .alert__name,
  & .alert__wind-conditions,
  & .alert__wind-direction,
  & .alert__wave-conditions,
  & .alert__wave-period-conditions,
  & .alert__wave-direction-conditions {
    color: #1f2937;
  }
}

.alert-list--table .alert--muted {
  display: none;
}

.alert-list--table.alert-list--expanded .alert--muted {
  /* display: table-row; */
  display: flex;
}

.alert-list__more-toggle {
  display: block;
  margin-top: 0.5rem;
  padding: 0;
  font-size: 1.25rem;
  color: #6b7280;
  cursor: pointer;
  background: none;
  border: none;
  user-select: none;

  &:hover {
    color: #374151;
  }
}

.alert-list__headers {
  display: table-row;
  font-weight: bold;
  background-color: #f0f0f0;

  & .alert-list__header {
    display: table-cell;
    padding: 1rem;
  }
}

.alert-list__spot-group {
  margin-bottom: 1rem;
}