/* ============================================================================
   Shared styling for product-detail modals — the "Model" pop-ups on controller
   / enclosure / sensor / power-supply / etc. pages. Anchored on both
   `.modal-header.textbkg` AND `.modal-header.bkcolor` (site uses both class
   names for the same intent) so it doesn't touch other Bootstrap modals
   (like the mobile description modal whose header is a plain `.modal-header`).
   ============================================================================ */

/* -------- Header -------- */
.modal-header.textbkg , .modal-header.bkcolor {
  background: linear-gradient(135deg, #002e57 0%, #0a4a80 100%);
  border-bottom: 3px solid #ff8c00;
  padding: 0.85rem 1.25rem;
  color: #ffffff;
}

.modal-header.textbkg h4, .modal-header.bkcolor h4,
.modal-header.textbkg h1, .modal-header.bkcolor h1,
.modal-header.textbkg .modal-title , .modal-header.bkcolor .modal-title {
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin: 0;
  text-transform: uppercase;
}

/* Close X (works when present; not required for modal to function) */
.modal-header.textbkg .btn-close , .modal-header.bkcolor .btn-close {
  filter: brightness(0) invert(1);
  opacity: 0.9;
  margin: 0;
  padding: 0.4rem;
}
.modal-header.textbkg .btn-close:hover , .modal-header.bkcolor .btn-close:hover { opacity: 1; }

/* -------- Body (immediate sibling of the styled header) -------- */
.modal-header.textbkg + .modal-body , .modal-header.bkcolor + .modal-body {
  padding: 1.25rem 1.5rem;
  background: #fbfcfd;
}

/* Hide the redundant "documentation" pre-header + first <hr> — the header
   above already tells you the model, and the section cards below label content */
.modal-header.textbkg + .modal-body > .card-title.text-uppercase:first-child , .modal-header.bkcolor + .modal-body > .card-title.text-uppercase:first-child {
  display: none;
}
.modal-header.textbkg + .modal-body > .card-title.text-uppercase + div > hr , .modal-header.bkcolor + .modal-body > .card-title.text-uppercase + div > hr {
  display: none;
}

/* Each content section becomes a white card with an orange left-border accent */
.modal-header.textbkg + .modal-body .card-body , .modal-header.bkcolor + .modal-body .card-body {
  background: #ffffff;
  border: 1px solid #e5e9ef;
  border-left: 4px solid #ff8c00;
  border-radius: 0 6px 6px 0;
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 46, 87, 0.04);
}

/* Drop the <hr> separators between sections — card borders do the job */
.modal-header.textbkg + .modal-body hr , .modal-header.bkcolor + .modal-body hr {
  display: none;
}

/* Section title (Description / Spec Sheets / Wiring Diagrams / etc.) */
.modal-header.textbkg + .modal-body .card-body h5 , .modal-header.bkcolor + .modal-body .card-body h5 {
  color: #002e57;
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: 0 0 0.6rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid #e5e9ef;
  text-align: center;
}

/* The wrapping <p> some sections use around the <h5> is invalid HTML but
   harmless — reset its margin so it doesn't add stray space above the h5 */
.modal-header.textbkg + .modal-body .card-body > p , .modal-header.bkcolor + .modal-body .card-body > p {
  margin-top: 0;
  margin-bottom: 0.4rem;
}

/* Description / body text */
.modal-header.textbkg + .modal-body .card-body p.lead, .modal-header.bkcolor + .modal-body .card-body p.lead,
.modal-header.textbkg + .modal-body .card-body P , .modal-header.bkcolor + .modal-body .card-body P {
  color: #4a5568;
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0 0 0.4rem;
  text-align: center;
}

/* File links — the label sits ABOVE its icon. No chip border, no thumbnail
   frame — just the file-type text with a plain icon underneath. */
.modal-header.textbkg + .modal-body .card-body a , .modal-header.bkcolor + .modal-body .card-body a {
  color: #002e57;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  margin: 0.4rem 0.6rem 0.4rem 0;
  padding: 0;
  border: none;
  background: transparent;
  text-align: center;
  vertical-align: top;
  line-height: 1.3;
  transition: color 0.15s ease;
}
.modal-header.textbkg + .modal-body .card-body a:hover , .modal-header.bkcolor + .modal-body .card-body a:hover {
  color: #ff8c00;
}
.modal-header.textbkg + .modal-body .card-body a:hover img , .modal-header.bkcolor + .modal-body .card-body a:hover img {
  transform: translateY(-1px);
}

/* Label text — sits above the icon */
.modal-header.textbkg + .modal-body .card-body a b, .modal-header.bkcolor + .modal-body .card-body a b,
.modal-header.textbkg + .modal-body .card-body a strong , .modal-header.bkcolor + .modal-body .card-body a strong {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  color: #002e57;
  margin-bottom: 0.3rem;
}
.modal-header.textbkg + .modal-body .card-body a:hover b, .modal-header.bkcolor + .modal-body .card-body a:hover b,
.modal-header.textbkg + .modal-body .card-body a:hover strong , .modal-header.bkcolor + .modal-body .card-body a:hover strong {
  color: #ff8c00;
}

/* Every file icon in a modal renders inside a proper thumbnail frame */
.modal-header.textbkg + .modal-body .card-body img.img-thumbnail , .modal-header.bkcolor + .modal-body .card-body img.img-thumbnail {
  max-width: 64px;
  height: auto;
  padding: 5px;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  display: inline-block;
  margin: 0.25rem 0.35rem;
  vertical-align: middle;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.modal-header.textbkg + .modal-body .card-body a:hover img.img-thumbnail , .modal-header.bkcolor + .modal-body .card-body a:hover img.img-thumbnail {
  border-color: #ff8c00;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 46, 87, 0.1);
}

/* Empty <b></b> tags collapse so icon-only anchors stay tight */
.modal-header.textbkg + .modal-body .card-body a b:empty , .modal-header.bkcolor + .modal-body .card-body a b:empty {
  display: none;
}

/* -------- Grouped file item (one document, multiple formats) --------
   Use when a single document is offered in more than one format (e.g. DWG + PDF
   of the same wiring diagram). Label sits above, format thumbnails sit below.
   Structure:
     <div class="modal-file-item">
       <div class="modal-file-label">MCS-NITROMAG-N Wiring Diagram</div>
       <a href="…dwg"><img class="img-thumbnail" src="…dwg_Icon.bmp"></a>
       <a href="…pdf"><img class="img-thumbnail" src="…pdf.png"></a>
     </div>
*/
.modal-file-item {
  display: block;
  text-align: center;
  margin: 0.4rem 0;
}

.modal-file-label {
  color: #002e57;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}

.modal-file-item a {
  display: inline-block;
  margin: 0 0.35rem;
}

/* -------- Footer (general sibling of the styled header) -------- */
.modal-header.textbkg ~ .modal-footer , .modal-header.bkcolor ~ .modal-footer {
  background: #f5f7fa;
  border-top: 1px solid #e5e9ef;
  padding: 0.75rem 1.25rem;
}

.modal-header.textbkg ~ .modal-footer .btn-danger , .modal-header.bkcolor ~ .modal-footer .btn-danger {
  background: #6c757d;      /* muted gray — Close is a low-emphasis action */
  border-color: #6c757d;
  padding: 0.4rem 1.5rem;
  font-weight: 600;
}
.modal-header.textbkg ~ .modal-footer .btn-danger:hover , .modal-header.bkcolor ~ .modal-footer .btn-danger:hover {
  background: #5a6268;
  border-color: #5a6268;
}

/* -------- Neutralize invalid nested markup without touching HTML --------
   Some sections wrap <div>s inside <table><tbody> (browser auto-recovers,
   but visual layout can shift). Force block layout only on the "scaffold"
   tables (bare <table>, no Bootstrap .table class) so real spec tables
   keep their proper row/column rendering. */
.modal-header.textbkg + .modal-body table:not(.table), .modal-header.bkcolor + .modal-body table:not(.table),
.modal-header.textbkg + .modal-body table:not(.table) > tbody , .modal-header.bkcolor + .modal-body table:not(.table) > tbody {
  display: block;
  width: 100%;
  border: 0;
  border-collapse: collapse;
}

/* Real spec tables inside modals — keep native table layout, add polish */
.modal-header.textbkg + .modal-body table.table , .modal-header.bkcolor + .modal-body table.table {
  margin: 0.4rem 0 0.8rem;
  font-size: 0.88rem;
  border: 1px solid #e5e9ef;
  background: #ffffff;
  border-radius: 4px;
  overflow: hidden;
}
.modal-header.textbkg + .modal-body table.table thead th , .modal-header.bkcolor + .modal-body table.table thead th {
  background: #0a1830;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 0.5rem 0.6rem;
  border: none;
  vertical-align: middle;
  text-align: center;
}
.modal-header.textbkg + .modal-body table.table tbody th, .modal-header.bkcolor + .modal-body table.table tbody th,
.modal-header.textbkg + .modal-body table.table tbody td , .modal-header.bkcolor + .modal-body table.table tbody td {
  padding: 0.45rem 0.6rem;
  vertical-align: middle;
  border-color: #e5e9ef;
}
.modal-header.textbkg + .modal-body table.table tbody th , .modal-header.bkcolor + .modal-body table.table tbody th {
  color: #002e57;
  font-weight: 600;
  background: #f8fafc;
}

/* Small spec tables shouldn't overflow their modal on narrow screens */
.modal-header.textbkg + .modal-body .table-responsive , .modal-header.bkcolor + .modal-body .table-responsive {
  margin: 0.4rem 0 0.8rem;
}

/* -------- Small screens -------- */
@media (max-width: 575.98px) {
  .modal-header.textbkg , .modal-header.bkcolor { padding: 0.65rem 1rem; }
  .modal-header.textbkg h4 , .modal-header.bkcolor h4 { font-size: 1rem; }
  .modal-header.textbkg + .modal-body , .modal-header.bkcolor + .modal-body { padding: 0.9rem 1rem; }
  .modal-header.textbkg + .modal-body .card-body , .modal-header.bkcolor + .modal-body .card-body { padding: 0.75rem 0.85rem; }
}

/* ==========================================================================
   Specifications block — used inside product modals to structure the
   Dimensions, Key Features, and Includes lists cleanly.
   Add class `mcs-spec-block` to the wrapper <div>.
   ========================================================================== */
.mcs-spec-block {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #e2e8f0;
  border-left: 4px solid #002e57;
  border-radius: 8px;
  padding: 1rem 1.25rem 1.1rem;
  margin: 1rem 0;
  text-align: left;
  box-shadow: 0 2px 6px rgba(0, 46, 87, 0.05);
}

/* First <b> child = block title (e.g. "Specifications:") */
.mcs-spec-block > b:first-child {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: #002e57;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-bottom: 0.55rem;
  margin-bottom: 0.85rem;
  border-bottom: 1px solid #cbd5e1;
}

/* Subsequent <b> children = subsection headers ("Key Features:", "Includes:") */
.mcs-spec-block > b:not(:first-child) {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: #0056b3;
  margin-top: 0.9rem;
  margin-bottom: 0.45rem;
}

/* Orphan <li> direct children — render as proper bullet items */
.mcs-spec-block > li {
  display: list-item;
  list-style-type: disc;
  list-style-position: outside;
  margin-left: 1.35rem;
  padding-left: 0.25rem;
  line-height: 1.55;
  color: #334155;
  font-size: 0.95rem;
}
.mcs-spec-block > li::marker {
  color: #ff8c00;
}

/* Bold labels inside list items (like "Dimensions:") */
.mcs-spec-block > li > b {
  color: #002e57;
  font-weight: 600;
  margin-right: 0.2rem;
}

/* ==========================================================================
   Info modal — structured product description with a chip strip and
   feature cards. Wrap the modal-body content with .mcs-info-modal.
   ========================================================================== */
.mcs-info-lead {
  font-size: 0.95rem;
  line-height: 1.55;
  color: #334155;
  margin: 0 0 1rem;
}
.mcs-info-lead strong {
  color: #002e57;
}

.mcs-info-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}
.mcs-info-chip {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  background: linear-gradient(135deg, #002e57 0%, #0056b3 100%);
  color: #ffffff;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.mcs-info-heading {
  font-size: 0.85rem;
  font-weight: 700;
  color: #002e57;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-bottom: 0.4rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid #cbd5e1;
}

.mcs-info-features {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.mcs-info-feature {
  display: flex;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #e2e8f0;
  border-left: 3px solid #ff8c00;
  border-radius: 8px;
}

.mcs-info-feature__icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, #002e57 0%, #0056b3 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.mcs-info-feature__body {
  flex: 1 1 auto;
  min-width: 0;
}

.mcs-info-feature__title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #002e57;
  margin-bottom: 0.2rem;
}

.mcs-info-feature__desc {
  font-size: 0.9rem;
  line-height: 1.5;
  color: #475569;
}
.mcs-info-feature__desc strong {
  color: #002e57;
}

@media (max-width: 400px) {
  .mcs-info-feature {
    padding: 0.75rem;
    gap: 0.65rem;
  }
  .mcs-info-feature__icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
}
