/* UPDATED kelas.css - Matching shop.css styling */

/* ========== CONTAINER ========== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px;
}

/* ========== GRID KELAS: 4 CARDS PER ROW ========== */
#courses {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 1.5rem;
  justify-content: start;
  align-items: stretch;
  width: 100%;
  min-height: 320px;
}

#courses > .kelas-card {
  justify-self: stretch;
  align-self: stretch;
  height: 100%;
}

/* ===== CARD KELAS ===== */
.kelas-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  min-height: 280px;
}

.kelas-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

/* ===== GAMBAR ===== */
.kelas-card .image-container {
  position: relative;
  width: 100%;
  height: 180px;
  overflow: hidden;
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kelas-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ===== IMAGE CAROUSEL ===== */
.carousel-prev,
.carousel-next {
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
}

.image-container:hover .carousel-prev,
.image-container:hover .carousel-next {
  opacity: 1;
}

.carousel-prev:hover,
.carousel-next:hover {
  background: rgba(0,0,0,0.8) !important;
}

.carousel-indicators {
  opacity: 0;
  transition: opacity 0.2s;
}

.image-container:hover .carousel-indicators {
  opacity: 1;
}

.indicator {
  transition: background 0.2s;
}

.kelas-card .label {
  position: absolute;
  top: 8px;
  right: 8px;
  background: linear-gradient(135deg, #1a237e 0%, #3949ab 100%);
  color: #fff;
  font-size: 0.65rem;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: capitalize;
  box-shadow: 0 2px 6px rgba(26,35,126,0.3);
}

/* ===== INFORMASI KELAS ===== */
.kelas-info {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.kelas-info h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 0.15rem;
  min-height: 36px;
  line-height: 1.3;
}

.kelas-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-top: auto;
}

.kelas-footer .price {
  font-weight: 600;
  font-size: 0.85rem;
  color: #1a237e;
}

.icon-btn {
  display: flex;
  justify-content: flex-end;
}

/* ===== CTA BELI LANGSUNG ===== */
.buy-btn {
  margin-top: 6px;
  background: linear-gradient(135deg, #1a237e 0%, #3949ab 100%);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(26,35,126,0.25);
}

.buy-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(26,35,126,0.35);
}

/* ===== Cart Controls (matching shop) ===== */
.add-cart-btn {
  background: linear-gradient(135deg, #e91e63 0%, #f48fb1 100%);
  color: white;
  border: none;
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(233,30,99,0.3);
}

.add-cart-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(233,30,99,0.4);
}

.add-cart-btn:active {
  transform: scale(0.95);
}

.card-qty-control {
  display: inline-flex;
  align-items: center;
  gap: 0;
  background: #f3f4f6;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}

.card-qty-control .qty-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: #e5e7eb;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: #374151;
  transition: background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-qty-control .qty-btn:hover {
  background: #1a237e;
  color: white;
}

.card-qty-control .qty-btn:active {
  transform: scale(0.95);
}

.card-qty-control .qty-value {
  min-width: 24px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: #111827;
  padding: 0 2px;
}

/* ===== Page Header & Controls ===== */
.page-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  width: 100%;
  margin-bottom: 6px;
}

.page-header .search-bar {
  width: 100%;
  max-width: 760px;
  padding-left: 0 !important;
  margin-left: 0 !important;
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
}

/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
  transition: opacity 0.25s ease;
  overflow-y: auto;
  padding: 40px 16px;
}

.modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: white;
  border-radius: 16px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
}

.modal-body img {
  width: 100%;
  height: auto;
  max-height: 250px;
  object-fit: cover;
  border-radius: 12px;
}

/* ===== MODAL IMAGE CAROUSEL ===== */
.modal-body .image-container {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  min-height: 400px;
  max-height: 500px;
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body .image-container img {
  width: 100%;
  height: 100%;
  max-height: 500px;
  object-fit: contain;
  display: block;
}

.modal-body .carousel-prev,
.modal-body .carousel-next {
  opacity: 0.8;
}

.modal-body .carousel-prev:hover,
.modal-body .carousel-next:hover {
  opacity: 1;
  background: rgba(0,0,0,0.8) !important;
}

.modal-body .carousel-indicators {
  opacity: 1;
}

.modal-body .indicator {
  transition: background 0.2s;
}

.modal-info {
  flex: 1;
  overflow-y: auto;
}

.modal-info p {
  line-height: 1.6;
  color: #374151;
  white-space: pre-line;
}

.close-modal {
  align-self: flex-end;
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  padding: 8px 12px;
  color: #555;
}

.modal-actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-primary {
  background-color: #2563eb;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.btn-secondary {
  background-color: #e5e7eb;
  color: #111;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
}

/* Modal Cart Controls Container */
.cart-controls-container {
  margin-top: 16px;
}

.modal-qty-control {
  display: inline-flex;
  align-items: center;
  gap: 0;
  background: #f3f4f6;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}

.modal-qty-control .qty-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: #e5e7eb;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  color: #374151;
  transition: background 0.2s, color 0.2s;
}

.modal-qty-control .qty-btn:hover {
  background: #0aa678;
  color: white;
}

.modal-qty-control .qty-btn:active {
  transform: scale(0.95);
}

.modal-qty-control .qty-value {
  min-width: 50px;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  color: #111827;
  padding: 0 8px;
}

@keyframes fadeIn {
  from {opacity: 0; transform: translateY(10px);} 
  to {opacity: 1; transform: translateY(0);} 
}

/* ===== OVERRIDE: Left-align & Fixed Grid ===== */
.container {
  display: block !important;
  padding-left: 40px !important;
  padding-right: 40px !important;
}

#courses {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr) !important;
  gap: 1rem !important;
  justify-content: start !important;
  justify-items: stretch !important;
  align-items: stretch !important;
  width: 100% !important;
  box-sizing: border-box !important;
  padding-left: 120px !important;
  padding-right: 120px !important;
  padding-bottom: 40px !important;
}

#courses > .kelas-card,
section#courses > .kelas-card {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  justify-self: stretch !important;
  align-self: stretch !important;
  box-sizing: border-box !important;
  height: 100% !important;
}

main .container,
main > .container {
  display: block !important;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 0 40px 0 !important; /* Add bottom padding for footer spacing */
  box-sizing: border-box !important;
}

.page-header,
.controls {
  display: block !important;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box !important;
}

/* force search / controls area tetap di atas dan tidak dipengaruhi */
.page-header { 
  padding-bottom: 12px !important; 
  padding-left: 120px !important; 
  padding-right: 120px !important; 
  padding-top: 60px !important;
  text-align: left !important;
}
.page-header h1 {
  text-align: left !important;
  padding-left: 0 !important;
  margin: 0 0 16px 0 !important;
}
.page-header .search-bar {
  margin-left: 0 !important;
  margin-right: auto !important;
}
.controls { display:flex !important; justify-content: space-between !important; align-items:center !important; }

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
  #courses {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

@media (max-width: 768px) {
  #courses {
    grid-template-columns: repeat(2, 1fr) !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
  
  .page-header {
    padding-left: 16px !important;
    padding-right: 16px !important;
    padding-top: 20px !important;
  }
  
  .page-header h1 {
    font-size: 1.3rem !important;
  }
  
  .page-header .search-bar {
    max-width: 100% !important;
  }
  
  .controls {
    flex-wrap: wrap;
    gap: 8px !important;
  }
  
  .filters {
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .filter-btn {
    font-size: 11px !important;
    padding: 6px 10px !important;
  }
  
  .sorting {
    width: 100%;
  }
  
  .sorting select {
    width: 100%;
  }
}

@media (max-width: 480px) {
  #courses {
    grid-template-columns: repeat(2, 1fr) !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
    gap: 8px !important;
    align-items: stretch !important;
  }
  
  #courses > .kelas-card {
    align-self: stretch !important;
    height: 100% !important;
  }
  
  .page-header {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  
  .page-header h1 {
    font-size: 1.1rem !important;
  }
  
  .kelas-card {
    min-height: 240px !important;
  }
  
  .kelas-card .image-container {
    height: 150px !important;
  }
  
  .modal-body .image-container {
    min-height: 300px !important;
    max-height: 400px !important;
  }
  
  .kelas-info {
    padding: 0.5rem !important;
  }
  
  .kelas-info h4 {
    font-size: 0.75rem !important;
    min-height: 28px !important;
  }
  
  /* Mobile: Reorganize footer layout */
  .kelas-footer {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 6px !important;
  }
  
  .kelas-footer .price {
    font-size: 0.75rem !important;
    text-align: left !important;
    width: 100% !important;
  }
  
  /* icon-btn contains either add-cart-btn or card-qty-control */
  .kelas-footer .icon-btn {
    width: 100% !important;
    display: flex !important;
    justify-content: flex-end !important;
  }
  
  /* When showing add-cart-btn, keep compact and right-aligned */
  .kelas-footer .icon-btn .add-cart-btn {
    width: auto !important;
    font-size: 9px !important;
    padding: 6px 10px !important;
    text-align: center !important;
  }
  
  /* When showing qty control, keep it compact and right-aligned */
  .kelas-footer .icon-btn .card-qty-control {
    margin-left: auto !important;
  }
  
  .buy-btn {
    font-size: 0.7rem !important;
    padding: 0.4rem !important;
    width: 100% !important;
  }
  
  .card-qty-control .qty-btn {
    width: 24px !important;
    height: 24px !important;
    font-size: 14px !important;
  }
  
  .card-qty-control .qty-value {
    min-width: 22px !important;
    font-size: 11px !important;
  }
}
