/**
 * Modal Desktop CSS - Styles for desktop product grid system
 * Optimized for desktop modal split-layout view
 */

/* Desktop Product Grid Wrapper */
.desktop-product-grid-wrapper {
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  background: white;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
}

.desktop-content-area {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* Product Grid View */
.product-grid-view {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.product-grid-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e5e5e5;
  background: #f8f9fa;
  flex-shrink: 0;
}

.grid-title {
  font-size: 20px;
  font-weight: 700;
  color: #333;
  margin: 0;
}

.product-count {
  font-size: 14px;
  color: #666;
  font-weight: 500;
}

.count-number {
  font-weight: 700;
  color: #033465;
  font-size: 16px;
}

/* Product Grid Container */
.product-grid-container {
  flex: 1;
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  align-content: start;
}

/* Single product layout */
.product-grid-container.single-product {
  display: flex;
  justify-content: center;
  align-items: center;
}

.product-grid-container.single-product .product-grid-card {
  max-width: 350px;
  height: 450px;
}

/* Product Card Styles */
.product-grid-card {
  background: white;
  border: 1px solid #e5e5e5;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  height: 400px;
  cursor: pointer;
}

.product-grid-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  border-color: #033465;
}

.product-card-image {
  width: 100%;
  height: 180px;
  margin: 0 auto 16px;
  border-radius: 8px;
  overflow: hidden;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.product-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.product-grid-card:hover .product-card-image img {
  transform: scale(1.05);
}

.product-card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.product-card-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin: 0 0 8px 0;
  line-height: 1.4;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.product-card-price {
  font-size: 20px;
  font-weight: 700;
  color: #033465;
  margin: 0 0 16px 0;
}

.view-more-btn {
  background: #033465;
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
  margin-top: auto;
}

.view-more-btn:hover {
  background: #022345;
  transform: translateY(-1px);
}

/* Product Detail View */
.product-detail-view {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: white;
}

.detail-header {
  padding: 20px 24px;
  border-bottom: 1px solid #e5e5e5;
  background: #f8f9fa;
  flex-shrink: 0;
}

.back-to-grid-btn {
  background: none;
  border: 1px solid #ddd;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.back-to-grid-btn:hover {
  background: #033465;
  color: white;
  border-color: #033465;
}

.detail-content {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
  display: flex;
  justify-content: center;
}

.product-detail {
  max-width: 600px;
  width: 100%;
}

.product-detail-image {
  width: 100%;
  max-width: 400px;
  height: 400px;
  margin: 0 auto 32px;
  border-radius: 12px;
  overflow: hidden;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.product-detail-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-detail-title {
  font-size: 32px;
  font-weight: 700;
  color: #333;
  margin: 0 0 16px 0;
  line-height: 1.3;
  text-align: center;
}

.product-detail-price {
  font-size: 36px;
  font-weight: 700;
  color: #033465;
  margin: 0 0 32px 0;
  text-align: center;
}

.product-detail-description {
  font-size: 16px;
  line-height: 1.6;
  color: #555;
  margin: 0 0 40px 0;
  text-align: center;
}

.product-detail-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}

/* Action Buttons */
.detail-more-info-btn,
.detail-add-to-cart-btn {
  padding: 16px 32px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 160px;
}

.detail-more-info-btn {
  background: #6c757d;
  color: white;
}

.detail-more-info-btn:hover {
  background: #5a6268;
  text-decoration: none;
  color: white;
  transform: translateY(-2px);
}

.detail-add-to-cart-btn {
  background: #033465;
  color: white;
}

.detail-add-to-cart-btn:hover:not(:disabled) {
  background: #022345;
  transform: translateY(-2px);
}

.detail-add-to-cart-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Button Loading States */
.detail-add-to-cart-btn.loading {
  position: relative;
  color: transparent;
}

.detail-add-to-cart-btn.loading::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.detail-add-to-cart-btn.success {
  background: #28a745;
}

.detail-add-to-cart-btn.error {
  background: #dc3545;
}

/* Loading, Error, Empty States */
.desktop-grid-loading,
.desktop-grid-error,
.desktop-grid-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  text-align: center;
  color: #666;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #033465;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

.error-icon,
.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.error-icon {
  color: #dc3545;
}

.empty-icon {
  color: #6c757d;
}

/* Animations */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Integration with existing modal styles */
@media (min-width: 992px) {
  /* Hide cart button from video controls on desktop */
  #playlist-video-modal .cart-btn {
    display: none !important;
  }

  /* Ensure desktop container takes full height */
  #desktop-product-details-container {
    height: 100%;
    overflow: hidden;
  }

  /* Override any existing desktop product styles */
  #desktop-product-details-container .desktop-product-details {
    height: auto;
  }
}

/* Responsive Design */
@media (min-width: 992px) and (max-width: 1200px) {
  .product-grid-container {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    padding: 20px;
  }

  .product-grid-card {
    height: 350px;
    padding: 16px;
  }

  .product-card-image {
    height: 150px;
  }

  .product-detail-actions {
    flex-direction: column;
  }

  .detail-more-info-btn,
  .detail-add-to-cart-btn {
    flex: none;
    min-width: auto;
  }
}

@media (min-width: 1400px) {
  .product-grid-container {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
  }

  .product-grid-card {
    height: 420px;
  }

  .product-card-image {
    height: 200px;
  }
}

/* Focus states for accessibility */
.view-more-btn:focus,
.detail-more-info-btn:focus,
.detail-add-to-cart-btn:focus,
.back-to-grid-btn:focus {
  outline: 2px solid #033465;
  outline-offset: 2px;
}

/* Smooth transitions for view changes */
.product-grid-view,
.product-detail-view {
  transition: opacity 0.3s ease;
}

/* Hover effects for cards */
.product-grid-card {
  will-change: transform;
}

.product-grid-card:active {
  transform: translateY(-2px);
}

/* Text overflow handling */
.product-card-title {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
