/* ============================================
   Reels Module — OpenCart
   Визуальный аналог star-tex.ru Reels
   ============================================ */

/* ---------- Container ---------- */
.reels-module-container {
  margin: 0 0 30px;
  padding: 10px 0 30px;
}

.reels-heading {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 24px;
  color: #222;
}

/* ---------- Grid ---------- */
.reels-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  column-gap: 18px;
  row-gap: 22px;
}

.reels-item {
  cursor: pointer;
  min-width: 0;
}

.reels-item-content {
  min-width: 0;
}

.reels-item.hidden-reel {
  display: none;
}

/* Poster wrapper */
.reels-item-poster {
  position: relative;
  display: block;
  width: 100%;
  padding-top: 177.7777%;
  border-radius: 2px;
  overflow: hidden;
  background: #f4f4f4;
  border: 5px solid rgb(225 225 225);
}

.reels-item-image,
.reels-item-hover-video,
.reels-item-hover-embed {
  position: absolute;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  object-position: center center !important;
}

.reels-item-hover-video {
  opacity: 0;
  transition: opacity .18s ease;
  /* Removed background: #000 so the poster is visible while loading */
}

.reels-item-hover-embed {
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transition: opacity .18s ease;
}

.reels-item-hover-embed iframe,
.reels-item-hover-embed object,
.reels-item-hover-embed embed {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border: 0 !important;
  pointer-events: none !important;
}

/* Only show video when it's ready to play */
.reels-item.is-video-ready .reels-item-hover-video,
.reels-item.is-video-ready .reels-item-hover-embed {
  opacity: 1;
}

/* Hover loader overlay, like the donor reel cards */
.reels-item-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32%;
  min-width: 76px;
  max-width: 112px;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.62);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
  transition: opacity 0.18s ease;
  pointer-events: none;
  z-index: 2;
}

.reels-item.is-video-loading .reels-item-loader {
  opacity: 1;
}

.reels-item.is-video-ready .reels-item-loader {
  opacity: 0;
}

.reels-item-loader span {
  position: relative;
  width: 54%;
  height: 54%;
  display: block;
  animation: reelsLoaderSpin .78s linear infinite;
}

.reels-item-loader span:before,
.reels-item-loader span:after {
  content: "";
  position: absolute;
  inset: 0;
  border: 4px solid transparent;
  border-radius: 50%;
}

.reels-item-loader span:before {
  border-top-color: rgba(24, 35, 43, 0.82);
  transform: rotate(38deg);
}

.reels-item-loader span:after {
  border-bottom-color: rgba(24, 35, 43, 0.82);
  transform: rotate(38deg);
}

@keyframes reelsLoaderSpin {
  to { transform: rotate(360deg); }
}

/* Caption under poster */
.reels-item-caption {
  padding: 10px 0 0;
}

.reels-item-title {
  font-size: 13px;
  font-weight: 400;
  color: #222;
  line-height: 17px;
  display: block;
  overflow: visible;
}

.reels-item-count {
  font-size: 13px;
  color: #8d8d8d;
  margin-top: 5px;
}

/* ---------- Show More Button ---------- */
.reels-show-more {
  text-align: center;
  margin-top: 24px;
}

.btn-reels-more {
  display: inline-block;
  min-width: 178px;
  padding: 11px 34px;
  font-size: 15px;
  font-weight: 500;
  color: #444;
  background: #fff;
  border: 1px solid #d7d7d7;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.btn-reels-more:hover {
  border-color: #bdbdbd;
  color: #222;
  background: #fafafa;
}

/* ============================================
   Popup / Modal (Bootstrap 3 based)
   ============================================ */

/* Modal Backdrop */
.reels-modal.modal {
  padding: 0 !important;
  background: rgba(0, 0, 0, 0.58) !important;
}

.reels-modal .modal-dialog {
  position: fixed !important;
  inset: 0 !important;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  transform: none !important;
}

.reels-modal .modal-content {
  position: relative !important;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.reels-modal .modal-body {
  position: relative !important;
  width: 100% !important;
  height: 100% !important;
  padding: 0 !important;
  overflow: hidden !important;
  background: transparent !important;
}

.reels-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.72);
  color: #fff;
  cursor: pointer;
  font-size: 30px;
  font-weight: 300;
  line-height: 34px;
  text-align: center;
  z-index: 10005;
  outline: none !important;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
  transition: background-color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.reels-modal-close:hover {
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  transform: scale(1.04);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.24);
}

.reels-modal-close:focus {
  color: #fff;
  background: rgba(17, 24, 39, 0.92);
}

.reels-video-container {
  width: 100%;
  height: 100vh;
  padding: 64px 0 72px;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-snap-type: y proximity;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.reels-video-container::-webkit-scrollbar {
  width: 0;
  display: none;
}

.reel-slide {
  width: min(840px, calc(100vw - 72px));
  min-height: auto;
  margin: 0 auto 38px;
  display: block;
  scroll-snap-align: start;
  background: transparent;
}

.reel-slide-content {
  position: relative;
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(320px, 1fr);
  gap: 30px;
  box-sizing: border-box;
  width: 100% !important;
  max-width: none !important;
  height: auto !important;
  min-height: 0;
  padding: 30px;
  background: #fff;
  border-radius: 6px;
  overflow: visible;
  box-shadow: none;
}

.reel-slide-main {
  min-width: 0;
}

.reel-slide-video {
  flex: none !important;
  max-width: none !important;
  width: 100%;
  height: min(604px, calc(100vh - 190px));
  max-height: calc(100vh - 190px);
  min-height: 420px;
  background: #000;
  position: relative;
  overflow: hidden;
  border-radius: 16px;
}

.reel-slide-video video,
.reel-embed-container,
.reel-embed-container iframe,
.reel-embed-container object,
.reel-embed-container embed {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 100% !important;
  min-height: 100% !important;
  border: 0 !important;
}

.reel-modal-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.reel-slide-video video,
.reel-embed-container {
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 2;
  object-fit: cover;
  object-position: center center;
}

.reel-slide.is-video-ready .reel-slide-video video,
.reel-slide.is-video-ready .reel-embed-container {
  opacity: 1;
}

.reel-embed-container {
  overflow: hidden;
  pointer-events: none;
}

.reel-video-controls {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex !important;
  gap: 14px;
  z-index: 5;
  transform: translateZ(0);
}

.reel-video-controls button {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reel-video-controls button:hover {
  background: rgba(255, 255, 255, 0.42);
}

.reel-video-controls svg {
  width: 22px;
  height: 22px;
}

.reel-slide-title {
  margin: 18px 0 0;
  color: #111;
  font-size: 17px;
  font-weight: 400;
  line-height: 1.24;
}

.reel-slide-sidebar {
  min-width: 0;
  padding: 0;
  background: #fff;
  overflow: visible;
}

.reel-slide-products {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 20px 20px;
  align-items: stretch;
}

.reel-product-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  box-sizing: border-box;
  padding: 8px;
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 4px;
  background: #fff;
  color: inherit;
  text-decoration: none;
  transition: border-color .16s ease, background-color .16s ease;
}

.reel-product-card:hover,
.reel-product-card:focus {
  border-color: rgba(0, 0, 0, 0.12);
  background-color: #fafafa;
  color: inherit;
  text-decoration: none;
}

.reel-product-image {
  width: 100%;
  aspect-ratio: 1.18 / 1;
  margin: 0 0 10px;
  overflow: hidden;
  background: #f5f5f5;
  border-radius: 0;
}

.reel-product-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}

.reel-product-name {
  color: #000;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.25;
  min-height: 0;
  height: auto;
  overflow: visible;
  display: block;
}

.reel-product-price {
  margin-top: 6px;
  color: #222;
  font-size: 14px;
  font-weight: 600;
}

.reel-product-price .price-old {
  margin-left: 6px;
  color: #999;
  font-size: 12px;
  font-weight: 400;
  text-decoration: line-through;
}

.reel-product-price .price-new {
  color: #d32f2f;
}

.modal#modal-quick-order {
  z-index: 10030;
}

.modal-backdrop.in + .modal-backdrop.in {
  z-index: 10020;
}

.reel-products-loading {
  grid-column: 1 / -1;
  width: 30px;
  height: 30px;
  margin: 48px auto;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #8e24aa;
  border-radius: 50%;
  animation: reelsSpin 1s linear infinite;
}

@keyframes reelsSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ============================================
   Responsive
   ============================================ */

/* Desktop small / Tablet landscape */
@media (max-width: 1199px) {
  .reels-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .reels-modal-close {
    right: 32px;
  }
}

/* Tablet portrait */
@media (max-width: 991px) {
  .reels-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .reel-slide {
    width: calc(100vw - 36px);
  }

  .reel-slide-content {
    grid-template-columns: minmax(320px, 390px) minmax(320px, 1fr);
    gap: 24px;
  }

  .reel-slide-products {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 24px;
  }
}

/* Mobile */
@media (max-width: 767px) {
  .reels-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .reels-modal-close {
    top: 10px;
    right: 14px;
    width: 36px;
    height: 36px;
    line-height: 32px;
    font-size: 28px;
    z-index: 10006;
  }

  .reels-video-container {
    padding: 16px 0;
    scroll-snap-type: y proximity;
  }

  .reel-slide {
    width: calc(100% - 24px);
    margin: 0 auto 22px;
  }

  .reel-slide-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    height: auto;
    max-width: none;
    min-height: 0;
    padding: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
  }

  .reel-slide-main {
    background: #000;
  }

  .reel-slide-video {
    width: 100%;
    min-height: 0;
    max-height: none;
    height: 68vh;
    aspect-ratio: auto;
    border-radius: 0;
  }

  .reel-slide-sidebar {
    padding: 18px 16px 24px;
    background: #fff;
    border-radius: 0;
    margin-top: 0;
    z-index: 50;
    min-height: 32vh;
  }

  .reel-slide-title {
    margin: 14px 16px 16px;
    color: #fff;
    font-size: 18px;
  }

  .reel-slide-products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 12px;
  }
}
