/* =========================================================
   Course Card + Popup (reutilizável: home + cursos)
   Baseado no teu courses.css — hover CSS puro, sem JS de posição
   ========================================================= */

/* Grelha de CARDS apenas — .courses-results é o wrapper da página cursos */
.courses-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  overflow: visible;
}

.courses-grid.cols-5 {
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

/* Página cursos: 3 colunas */
.courses-results > .courses-grid,
.courses-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.cg-card {
  background: #fff;
  border-radius: 12px;
  overflow: visible;
  position: relative;
  transition: all 0.3s ease;
}

.cg-card-inner {
  background: #fff;
  /* border-radius: 12px; */
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  border: 1px solid #e9ecef;
  transition: all 0.3s ease;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.cg-card:hover {
  z-index: 40;
}

.cg-card:hover .cg-card-inner {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.1);
}

.cg-card.is-hidden,
.cg-card.is-hidden-course {
  display: none !important;
}

.cg-thumb {
  position: relative;
  height: 160px;
  overflow: hidden;
  background: #f8f9fa;
}

.courses-grid.cols-5 .cg-thumb {
  height: 128px;
}

.cg-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.cg-card:hover .cg-thumb img {
  transform: scale(1.05);
}

.cg-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: #fff;
  z-index: 2;
}

.cg-badge.hot {
  background: #e74c3c;
}
.cg-badge.new {
  background: #27ae60;
}
.cg-badge.special {
  background: #6d0eb1;
}

.cg-body {
  padding: 14px 16px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.cg-category {
  font-size: 12px;
  color: #6d0eb1;
  font-weight: 600;
  margin-bottom: 6px;
}

.cg-title {
  font-size: 15px;
  font-weight: 600;
  color: #212529;
  line-height: 1.4;
  margin: 0 0 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 42px;
}

.cg-stats {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.cg-stat {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #f8f9fa;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  color: #6c757d;
}

.cg-stat i {
  font-size: 11px;
  opacity: 0.7;
}

.cg-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
}

.cg-rating {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 13px;
  color: #495057;
}

.cg-rating i {
  color: #f1c40f;
  font-size: 12px;
}

.cg-rating i.empty,
.cg-rating .empty {
  color: #dee2e6;
}

.cg-rating span {
  margin-left: 4px;
}

.cg-price {
  font-size: 15px;
  font-weight: 700;
  color: #212529;
}

.cg-price.free {
  color: #27ae60;
}

.cg-price .old {
  font-size: 12px;
  color: #adb5bd;
  text-decoration: line-through;
  font-weight: 400;
  margin-right: 4px;
}

/* Popup CSS puro — centrado no card */
.cg-popup {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  width: 320px;
  background: #fff;
  /* border-radius: 12px; */
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  padding: 20px;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.25s ease,
    visibility 0.25s ease,
    transform 0.25s ease;
  text-align: left;
}

.cg-card:hover .cg-popup {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

/* Página cursos — 3 colunas */
.courses-results .cg-card:nth-child(3n) .cg-popup {
  left: auto;
  right: 0;
  transform: translateX(0) translateY(10px);
}

.courses-results .cg-card:nth-child(3n):hover .cg-popup {
  transform: translateX(0) translateY(0);
}

/* 4 colunas */
.courses-grid:not(.cols-5) .cg-card:nth-child(4n) .cg-popup {
  left: auto;
  right: 0;
  transform: translateX(0) translateY(10px);
}

.courses-grid:not(.cols-5) .cg-card:nth-child(4n):hover .cg-popup {
  transform: translateX(0) translateY(0);
}

/* 5 colunas (home) */
.courses-grid.cols-5 .cg-card:nth-child(5n) .cg-popup,
.courses-grid.cols-5 .cg-card:nth-child(5n-1) .cg-popup {
  left: auto;
  right: 0;
  transform: translateX(0) translateY(10px);
}

.courses-grid.cols-5 .cg-card:nth-child(5n):hover .cg-popup,
.courses-grid.cols-5 .cg-card:nth-child(5n-1):hover .cg-popup {
  transform: translateX(0) translateY(0);
}

.cg-popup-instructor {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.cg-popup-instructor img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.cg-popup-instructor span {
  font-size: 13px;
  font-weight: 500;
  color: #495057;
}

.cg-popup-title {
  font-size: 16px;
  font-weight: 700;
  color: #212529;
  line-height: 1.35;
  margin: 0 0 10px;
}

.cg-popup-desc {
  font-size: 13px;
  color: #6c757d;
  line-height: 1.55;
  margin: 0 0 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cg-popup-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 16px;
  font-size: 12px;
  color: #6c757d;
}

.cg-popup-meta span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.cg-popup-meta i {
  color: #6d0eb1;
  font-size: 12px;
}

.cg-popup .btn-preview,
.btn-preview {
  display: block;
  width: 100%;
  background: #6d0eb1;
  color: #fff;
  text-align: center;
  padding: 12px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 14px;
  transition: all 0.3s ease;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
}

.cg-popup .btn-preview:hover,
.btn-preview:hover {
  background: #550a8c;
  color: #fff;
}

.cg-popup-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.btn-wishlist {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #6c757d;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.btn-wishlist:hover {
  color: #6d0eb1;
}

.cg-popup-price {
  text-align: right;
  font-size: 16px;
  font-weight: 700;
  color: #212529;
}

.cg-popup-price .old {
  font-size: 13px;
  color: #adb5bd;
  text-decoration: line-through;
  font-weight: 400;
  margin-right: 4px;
}

.cg-popup-price .current {
  font-size: 18px;
  font-weight: 700;
  color: #6d0eb1;
}

.cg-popup-price .free {
  font-size: 18px;
  font-weight: 700;
  color: #27ae60;
}

@media (max-width: 1200px) {
  .courses-grid,
  .courses-grid.cols-5 {
    grid-template-columns: repeat(3, 1fr);
  }
  .courses-grid.cols-5 .cg-card:nth-child(5n) .cg-popup,
  .courses-grid.cols-5 .cg-card:nth-child(5n-1) .cg-popup {
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(10px);
  }
  .courses-grid.cols-5 .cg-card:nth-child(5n):hover .cg-popup,
  .courses-grid.cols-5 .cg-card:nth-child(5n-1):hover .cg-popup {
    transform: translateX(-50%) translateY(0);
  }
  .courses-grid .cg-card:nth-child(3n) .cg-popup {
    left: auto;
    right: 0;
    transform: translateX(0) translateY(10px);
  }
  .courses-grid .cg-card:nth-child(3n):hover .cg-popup {
    transform: translateX(0) translateY(0);
  }
}

@media (max-width: 1100px) {
  .courses-results > .courses-grid,
  .courses-grid.cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }
  .courses-results .cg-card:nth-child(3n) .cg-popup {
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(10px);
  }
  .courses-results .cg-card:nth-child(3n):hover .cg-popup {
    transform: translateX(-50%) translateY(0);
  }
}

@media (max-width: 900px) {
  .courses-grid,
  .courses-grid.cols-5 {
    grid-template-columns: repeat(2, 1fr);
  }
  .cg-popup {
    display: none !important;
  }
}

@media (max-width: 560px) {
  .courses-grid,
  .courses-grid.cols-5,
  .courses-results > .courses-grid,
  .courses-grid.cols-3 {
    grid-template-columns: 1fr;
  }
  .cg-thumb {
    height: 180px;
  }
}
