/* Bottle Catalogue – scoped to avoid theme conflicts */

/*
 * Inquiry modal: script moves the dialog to document.body while open (see app.js) so it is not
 * trapped under sticky headers by ancestor stacking contexts. body.bottle-catalogue-inquiry-active
 * lifts Bootstrap’s backdrop and the shell above aggressive theme z-index (e.g. Avada sticky).
 * DOM-fallback dimmer (.bottle-catalogue-inquiry-scrim) stays inside .fusion-modal for hit-testing.
 */
.bottle-catalogue-embed {
  display: block;
}

.bottle-catalogue-embed--modal-open {
  position: relative;
}

.bottle-catalogue-embed--modal-open > .bottle-catalogue-wrapper {
  pointer-events: none;
  user-select: none;
}

/* Near-max z-index: must beat theme headers that use multi-million values */
body.bottle-catalogue-inquiry-active .modal-backdrop {
  z-index: 2147483645 !important;
}

body.bottle-catalogue-inquiry-active .modal-backdrop.show,
body.bottle-catalogue-inquiry-active .modal-backdrop.fade {
  z-index: 2147483645 !important;
}

body.bottle-catalogue-inquiry-active .bottle-catalogue-inquiry-modal-root.fusion-modal.modal.show,
body.bottle-catalogue-inquiry-active .bottle-catalogue-inquiry-modal-root.fusion-modal.modal.in {
  position: fixed;
  inset: 0;
  z-index: 2147483646 !important;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Modest inset so centered dialog is not flush to viewport edges */
  padding: max(0.75rem, env(safe-area-inset-top, 0px)) 1rem max(0.75rem, env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  pointer-events: auto;
}

body.bottle-catalogue-inquiry-active .bottle-catalogue-inquiry-modal-root .bottle-catalogue-inquiry-scrim {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-color: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

/* Fallback when a theme leaves the modal inside .bottle-catalogue-embed (no body class) */
.bottle-catalogue-embed--modal-open > .bottle-catalogue-fusion-modal .bottle-catalogue-inquiry-scrim,
.bottle-catalogue-embed--modal-open > .fusion-modal .bottle-catalogue-inquiry-scrim {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-color: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.bottle-catalogue-embed--modal-open > .bottle-catalogue-fusion-modal.modal.show,
.bottle-catalogue-embed--modal-open > .bottle-catalogue-fusion-modal.modal.in,
.bottle-catalogue-embed--modal-open > .fusion-modal.modal.show,
.bottle-catalogue-embed--modal-open > .fusion-modal.modal.in {
  position: fixed;
  inset: 0;
  z-index: 2147483646 !important;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(0.75rem, env(safe-area-inset-top, 0px)) 1rem max(0.75rem, env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  pointer-events: auto;
}

.bottle-catalogue-embed > .fusion-modal.modal.show,
.bottle-catalogue-embed > .fusion-modal.modal.in,
.bottle-catalogue-embed > .bottle-catalogue-fusion-modal.modal.show,
.bottle-catalogue-embed > .bottle-catalogue-fusion-modal.modal.in {
  z-index: 2147483646 !important;
}

/* Injected inquiry modal: Avada/Fusion-like shell when markup is plugin-rendered */
.bottle-catalogue-embed > .bottle-catalogue-fusion-modal .modal-dialog,
.bottle-catalogue-embed > .fusion-modal .modal-dialog {
  margin: 1.75rem auto;
  max-width: min(800px, calc(100vw - 2rem));
  pointer-events: auto;
}

.bottle-catalogue-embed--modal-open > .bottle-catalogue-fusion-modal .modal-dialog,
.bottle-catalogue-embed--modal-open > .fusion-modal .modal-dialog,
body.bottle-catalogue-inquiry-active .bottle-catalogue-inquiry-modal-root .modal-dialog,
body.bottle-catalogue-inquiry-active .bottle-catalogue-inquiry-modal-root .fusion-modal-dialog {
  position: relative;
  z-index: 1;
  margin: 0 auto !important;
  max-height: min(90vh, calc(100vh - 2.5rem));
  overflow-x: hidden;
  overflow-y: auto;
  pointer-events: auto;
}

/*
 * When the script reparents the modal to body, selectors under .bottle-catalogue-embed no longer
 * match; Avada .fusion-close / Bootstrap .close margins then misalign the ×. Scope the same
 * header layout to .bottle-catalogue-inquiry-modal-root.
 */
body.bottle-catalogue-inquiry-active .bottle-catalogue-inquiry-modal-root .modal-header.fusion-modal-header,
body.bottle-catalogue-inquiry-active .bottle-catalogue-inquiry-modal-root .fusion-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e6e6e6;
  background: #f7f7f7;
  min-height: 0;
}

body.bottle-catalogue-inquiry-active .bottle-catalogue-inquiry-modal-root .modal-header.bottle-catalogue-modal-header-slim {
  justify-content: flex-end;
  min-height: 3rem;
}

body.bottle-catalogue-inquiry-active .bottle-catalogue-inquiry-modal-root .modal-title.fusion-modal-title,
body.bottle-catalogue-inquiry-active .bottle-catalogue-inquiry-modal-root .fusion-modal-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--bc-text, #333);
  flex: 1 1 auto;
}

body.bottle-catalogue-inquiry-active .bottle-catalogue-inquiry-modal-root .modal-header .close,
body.bottle-catalogue-inquiry-active .bottle-catalogue-inquiry-modal-root .modal-header .fusion-close,
body.bottle-catalogue-inquiry-active .bottle-catalogue-inquiry-modal-root .modal-header .fusion-close-icon {
  flex: 0 0 auto;
  align-self: center;
  float: none;
  position: relative;
  top: auto;
  right: auto;
  margin: 0;
  padding: 0.125rem 0.45rem;
  min-height: 0;
  font-size: 1.75rem;
  line-height: 1;
  font-weight: 300;
  color: #666;
  background: transparent;
  border: 0;
  opacity: 0.75;
  cursor: pointer;
  transition: opacity 0.15s ease;
  box-sizing: border-box;
}

body.bottle-catalogue-inquiry-active .bottle-catalogue-inquiry-modal-root .modal-header .close:hover,
body.bottle-catalogue-inquiry-active .bottle-catalogue-inquiry-modal-root .modal-header .close:focus,
body.bottle-catalogue-inquiry-active .bottle-catalogue-inquiry-modal-root .modal-header .fusion-close:hover,
body.bottle-catalogue-inquiry-active .bottle-catalogue-inquiry-modal-root .modal-header .fusion-close:focus {
  opacity: 1;
  outline: none;
}

body.bottle-catalogue-inquiry-active .bottle-catalogue-inquiry-modal-root .modal-header .close span,
body.bottle-catalogue-inquiry-active .bottle-catalogue-inquiry-modal-root .modal-header .fusion-close span {
  display: block;
  line-height: 1;
}

.bottle-catalogue-embed > .bottle-catalogue-fusion-modal .modal-content {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.bottle-catalogue-embed > .bottle-catalogue-fusion-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e6e6e6;
  background: #f7f7f7;
}

.bottle-catalogue-embed > .bottle-catalogue-fusion-modal .modal-header.bottle-catalogue-modal-header-slim {
  justify-content: flex-end;
  min-height: 3rem;
}

.bottle-catalogue-embed > .bottle-catalogue-fusion-modal .modal-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--bc-text, #333);
  flex: 1 1 auto;
}

.bottle-catalogue-embed > .bottle-catalogue-fusion-modal .modal-header .close {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.25rem 0.5rem;
  font-size: 1.75rem;
  line-height: 1;
  font-weight: 300;
  color: #666;
  background: transparent;
  border: 0;
  opacity: 0.75;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.bottle-catalogue-embed > .bottle-catalogue-fusion-modal .modal-header .close:hover,
.bottle-catalogue-embed > .bottle-catalogue-fusion-modal .modal-header .close:focus {
  opacity: 1;
  outline: none;
}

.bottle-catalogue-embed > .bottle-catalogue-fusion-modal .modal-body {
  padding: 1.25rem 1.5rem;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--bc-text, #333);
}

/* Baseline form controls inside injected modal (Avada Forms may override) */
.bottle-catalogue-embed > .bottle-catalogue-fusion-modal .modal-body input[type="text"],
.bottle-catalogue-embed > .bottle-catalogue-fusion-modal .modal-body input[type="email"],
.bottle-catalogue-embed > .bottle-catalogue-fusion-modal .modal-body input[type="tel"],
.bottle-catalogue-embed > .bottle-catalogue-fusion-modal .modal-body input[type="number"],
.bottle-catalogue-embed > .bottle-catalogue-fusion-modal .modal-body input[type="url"],
.bottle-catalogue-embed > .bottle-catalogue-fusion-modal .modal-body textarea,
.bottle-catalogue-embed > .bottle-catalogue-fusion-modal .modal-body select {
  max-height: none;
  line-height: 1.4;
  padding: 0.5rem 0.65rem;
  box-sizing: border-box;
}

.bottle-catalogue-wrapper {
  --bc-brand: #65b1eb;
  --bc-border: #e0e0e0;
  --bc-bg-light: #f9f9f9;
  --bc-text: #333;
  --bc-text-muted: #666;
}

.bottle-catalogue-wrapper h1 {
  color: var(--bc-text);
  margin: 0 0 1rem 0;
  font-weight: 600;
}

/* Filter area */
.bottle-catalogue-wrapper .filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 1.5rem;
}

.bottle-catalogue-wrapper .table-filter {
  background-color: var(--bc-bg-light);
  border: 1px solid var(--bc-border);
  border-radius: 0;
  color: var(--bc-text);
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  min-width: 120px;
  min-height: 2.5rem;
  box-sizing: border-box;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M2 4L6 8L10 4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}

.bottle-catalogue-wrapper .table-filter:focus {
  outline: none;
  border-color: var(--bc-brand);
}

/* Filter / Clear — shared box model (button vs link UA/theme differences) */
.bottle-catalogue-wrapper .btn-filter,
.bottle-catalogue-wrapper .btn-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: inherit;
  line-height: 1.25;
  min-height: 2.5rem;
  padding: 0.5rem 1.25rem;
  box-sizing: border-box;
  border-radius: 0;
  cursor: pointer;
  text-decoration: none;
}

/* Filter button – primary */
.bottle-catalogue-wrapper .btn-filter {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  background-color: var(--bc-brand);
  color: #fff;
  border: 1px solid var(--bc-brand);
}

.bottle-catalogue-wrapper .btn-filter:hover {
  opacity: 0.9;
}

/* Clear button – secondary */
.bottle-catalogue-wrapper .btn-clear {
  background-color: #fff;
  color: var(--bc-brand);
  border: 1px solid var(--bc-border);
}

.bottle-catalogue-wrapper .btn-clear:hover {
  background-color: var(--bc-bg-light);
}

/* Table */
.bottle-catalogue-wrapper table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.bottle-catalogue-wrapper thead th {
  color: var(--bc-text);
  font-weight: 600;
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--bc-border);
  border-right: 1px solid var(--bc-border);
  background: #fff;
}

.bottle-catalogue-wrapper thead th:last-child {
  border-right: none;
}

.bottle-catalogue-wrapper tbody td {
  color: var(--bc-text);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--bc-border);
  border-right: 1px solid var(--bc-border);
}

.bottle-catalogue-wrapper tbody td:last-child {
  border-right: none;
}

.bottle-catalogue-wrapper tbody tr:nth-child(even) {
  background-color: var(--bc-bg-light);
}

.bottle-catalogue-wrapper tbody tr:nth-child(odd) {
  background-color: #fff;
}

/* Row hover image preview (fixed layer; below inquiry modal z-index) */
.bottle-catalogue-row-preview {
  position: fixed;
  z-index: 2147483000;
  max-width: min(420px, calc(100vw - 24px));
  max-height: min(360px, calc(100vh - 24px));
  padding: 6px;
  margin: 0;
  box-sizing: border-box;
  pointer-events: none;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.06);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease-out, visibility 0.12s ease-out;
}

.bottle-catalogue-row-preview.is-visible {
  opacity: 1;
  visibility: visible;
}

.bottle-catalogue-row-preview img {
  display: block;
  max-width: 100%;
  max-height: min(348px, calc(100vh - 36px));
  width: auto;
  height: auto;
  object-fit: contain;
}

/* View details link */
.bottle-catalogue-wrapper .details a {
  color: var(--bc-brand);
  text-decoration: none;
}

.bottle-catalogue-wrapper .details a:hover {
  text-decoration: underline;
}

.bottle-catalogue-wrapper .details .bottle-catalogue-inquiry {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: var(--bc-brand);
  text-decoration: none;
  cursor: pointer;
}

.bottle-catalogue-wrapper .details .bottle-catalogue-inquiry:hover {
  text-decoration: underline;
}

/* Result count */
.bottle-catalogue-wrapper .catalogue-result-count {
  margin: 0 0 1rem 0;
  color: var(--bc-text-muted);
  font-size: 0.9rem;
}

/* Sortable volume column */
.bottle-catalogue-wrapper .volume-header.sort {
  cursor: pointer;
  user-select: none;
}

.bottle-catalogue-wrapper .volume-header.sort:hover {
  background-color: var(--bc-bg-light);
}

/* Empty state */
.bottle-catalogue-wrapper .catalogue-empty-state td {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--bc-text-muted);
  font-style: italic;
}
