/* KaFra Shoppers Page Styles */
.kafra-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Page Header */
.page-header {
  text-align: center;
  margin-bottom: 40px;
  padding: 20px;
  background-color: #f9f9f9;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.page-header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  color: #333;
}

.page-header p {
  color: #666;
  margin-bottom: 30px;
  font-size: 1.1rem;
}

/* Filter Controls */
.filter-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  align-items: center;
  margin-top: 20px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.filter-group label {
  font-weight: 600;
  color: #555;
  font-size: 0.9rem;
}

.filter-select {
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 1rem;
  min-width: 200px;
  background-color: white;
  transition: border-color 0.3s;
}

.filter-select:focus {
  border-color: #4CAF50;
  outline: none;
}

.reset-btn {
  padding: 10px 20px;
  background-color: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s;
  align-self: flex-end;
}

.reset-btn:hover {
  background-color: #e9e9e9;
}

/* Loading State */
.loading-container {
  text-align: center;
  padding: 60px 20px;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #f3f3f3;
  border-top: 5px solid #4CAF50;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

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

/* Products Grid */
.products-grid {
  margin-top: 30px;
}

.products-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.products-header h2 {
  font-size: 1.8rem;
  color: var(--forest);
}

.search-box {
  display: flex;
  align-items: center;
  border: 1px solid #ddd;
  border-radius: 999px;
  overflow: hidden;
  width: 300px;
  background: white;
}

#product-search {
  flex: 1;
  padding: 12px 15px;
  border: none;
  font-size: 1rem;
}

#search-btn {
  padding: 12px 20px;
  background-color: var(--forest);
  color: white;
  border: none;
  cursor: pointer;
  transition: background-color 0.3s;
}

#search-btn:hover {
  background-color: var(--bronze);
}

.products-grid-inner {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

/* Product Card */
.product-card {
  background-color: white;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: transform 0.3s, box-shadow 0.3s;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100%;
}

.product-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
}

.product-card-link {
  display: block;
  color: inherit;
  text-decoration: none;
  height: 100%;
}

.product-image-container {
  position: relative;
  width: 100%;
  height: 200px;
  overflow: hidden;
  background: #f7f3ed;
}

.product-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.product-card:hover .product-image {
  transform: scale(1.04);
}

.product-category {
  font-size: 0.76rem;
  color: var(--bronze);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.product-info {
  padding: 16px;
  flex: 1;
  display: grid;
  gap: 10px;
}

.product-name {
  font-size: 1.05rem;
  margin: 0;
  color: var(--forest);
  line-height: 1.3;
  font-weight: 600;
  min-height: 2.6em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.product-description {
  color: #666;
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.4;
  flex: 1;
  min-height: 2.8em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.product-price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: auto;
}

.product-price {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--forest);
}

.product-price-original {
  font-size: 0.9rem;
  color: #888;
  text-decoration: line-through;
}

.product-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.product-stock {
  font-size: 0.82rem;
  margin: 0;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}

.product-stock.in-stock {
  background: rgba(40, 167, 69, 0.1);
  color: #28a745;
}

.product-stock.low-stock {
  background: rgba(255, 193, 7, 0.14);
  color: #d97706;
}

.product-stock.out-of-stock {
  background: rgba(220, 53, 69, 0.1);
  color: #dc3545;
}

.product-rating {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #666;
  font-size: 0.82rem;
}

.product-rating-stars {
  color: #ffc107;
  display: inline-flex;
  gap: 2px;
}

.product-rating-count {
  color: #666;
}

.product-actions {
  display: block;
  padding: 0 16px 16px;
}

.add-cart-btn {
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.3s, transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.92rem;
}

.add-cart-btn {
  background-color: var(--forest);
  color: white;
}

.add-cart-btn:hover:not(:disabled) {
  background-color: var(--bronze);
  transform: translateY(-1px);
}

.add-cart-btn:disabled {
  background-color: #9ca3af;
  cursor: not-allowed;
}

.product-card.is-unavailable {
  opacity: 0.94;
}

/* No Products Message */
.no-products {
  text-align: center;
  padding: 60px 20px;
  color: #666;
}

.no-products i {
  font-size: 4rem;
  margin-bottom: 20px;
  color: #ddd;
}

.no-products h3 {
  font-size: 1.8rem;
  margin-bottom: 10px;
}

/* Error State */
.error-container {
  text-align: center;
  padding: 60px 20px;
  color: #666;
}

.error-container i {
  font-size: 4rem;
  margin-bottom: 20px;
  color: #f44336;
}

.error-container h3 {
  font-size: 1.8rem;
  margin-bottom: 10px;
  color: #f44336;
}

.retry-btn {
  margin-top: 20px;
  padding: 12px 30px;
  background-color: #4CAF50;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.3s;
}

.retry-btn:hover {
  background-color: #45a049;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-top: 40px;
}

.pagination-btn {
  padding: 10px 20px;
  background-color: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-btn:hover:not(:disabled) {
  background-color: #e9e9e9;
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#page-info {
  font-weight: 600;
  color: #333;
}

/* Responsive Styles - Updated for progressive grid columns */
@media (max-width: 768px) {
  .products-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-box {
    width: 100%;
  }
  
  .filter-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .filter-group {
    width: 100%;
  }
  
  .filter-select {
    width: 100%;
    min-width: unset;
  }
  
  /* 2 products per row on tablets */
  .products-grid-inner {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  .product-image-container {
    height: 160px;
  }
}

@media (max-width: 480px) {
  /* 2 products per row on mobile (iPhone 11 and similar) */
  .products-grid-inner {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
  }
  
  .product-image-container {
    height: 150px;
  }
  
  .product-info {
    padding: 12px;
  }
  
  .product-name {
    font-size: 1rem;
    min-height: 2.4em;
  }
  
  .product-description {
    font-size: 0.75rem;
    min-height: 2.6em;
  }
  
  .product-price {
    font-size: 1.1rem;
  }
  
  .product-stock {
    font-size: 0.75rem;
  }
  
  .product-category {
    font-size: 0.65rem;
  }

  .add-cart-btn {
    padding: 8px 10px;
    font-size: 0.85rem;
    gap: 4px;
  }
  
  .page-header h1 {
    font-size: 2rem;
  }
}

/* For very small phones (below 350px) - 1 product per row */
@media (max-width: 350px) {
  .products-grid-inner {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .product-image-container {
    height: 180px;
  }
}

/* For larger screens - progressive increase */
@media (min-width: 769px) {
  .products-grid-inner {
    grid-template-columns: repeat(3, 1fr); /* 3 per row on small laptops */
  }
  
  .product-image-container {
    height: 200px;
  }
  
  .product-name {
    font-size: 1.2rem;
  }
  
  .product-price {
    font-size: 1.3rem;
  }
}

@media (min-width: 992px) {
  .products-grid-inner {
    grid-template-columns: repeat(4, 1fr); /* 4 per row on desktops */
  }
  
  .product-image-container {
    height: 220px;
  }
}

@media (min-width: 1200px) {
  .products-grid-inner {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); /* Auto-fit on large screens */
    max-width: 1200px;
    margin: 0 auto 40px;
  }
  
  .product-image-container {
    height: 240px;
  }
}

/* Admin Controls */
.admin-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 20px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #4CAF50;
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.admin-label {
  font-weight: 600;
  color: #333;
  font-size: 0.9rem;
}

.admin-controls {
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 30px;
  border-left: 5px solid #4CAF50;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.admin-controls-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.admin-controls-header h3 {
  color: #333;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-btn {
  padding: 10px 20px;
  background: white;
  border: 2px solid #4CAF50;
  color: #4CAF50;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s;
  cursor: pointer;
}

.admin-btn:hover {
  background: #4CAF50;
  color: white;
  transform: translateY(-2px);
}

/* Product Card Admin Overlay */
.product-card.admin-mode {
  position: relative;
}

.product-card.admin-mode::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(76, 175, 80, 0.1);
  border: 2px solid #4CAF50;
  border-radius: 10px;
  z-index: 1;
  pointer-events: none;
}

.admin-actions-overlay {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 5px;
  z-index: 2;
}

.admin-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: all 0.3s;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.admin-action-btn.edit {
  background: #2196F3;
  color: white;
}

.admin-action-btn.delete {
  background: #f44336;
  color: white;
}

.admin-action-btn.status {
  background: #ff9800;
  color: white;
}

.admin-action-btn.quick {
  background: #9c27b0;
  color: white;
}

.admin-action-btn:hover {
  transform: scale(1.1);
}

/* Product Status Badge */
.product-status-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  z-index: 2;
}

.product-status-badge.published {
  background: #4CAF50;
  color: white;
}

.product-status-badge.unpublished {
  background: #ff9800;
  color: white;
}

/* Quick Edit Form */
.quick-edit-form {
  position: absolute;
  top: 50px;
  left: 10px;
  right: 10px;
  background: white;
  padding: 15px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  z-index: 10;
  display: none;
}

.quick-edit-form.active {
  display: block;
  animation: slideDown 0.3s ease;
}

.quick-edit-form input {
  width: 100%;
  padding: 8px;
  margin-bottom: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
}

.quick-edit-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Stock Warnings */
.product-stock.warning {
  color: #ff9800;
  font-weight: 600;
}

.product-stock.danger {
  color: #f44336;
  font-weight: 600;
}

/* Admin Stats */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.admin-stat {
  background: white;
  padding: 15px;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.admin-stat .stat-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: #667eea;
  margin-bottom: 5px;
}

.admin-stat .stat-label {
  font-size: 0.9rem;
  color: #666;
}

.clickable {
  cursor: pointer;
  transition: all 0.3s ease;
}

.clickable:hover {
  color: #667eea;
}

.product-image-container.clickable:hover .product-image {
  transform: scale(1.05);
}


/* Badge styles for products */
.product-badges {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 2;
}

.badge-featured, .badge-deal, .badge-new {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 3px;
}

.badge-featured {
    background-color: var(--bronze);
    color: white;
}

.badge-deal {
    background-color: #dc3545;
    color: white;
}

.badge-new {
    background-color: #28a745;
    color: white;
}

/* Animation for notifications */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}
