/**
 * Custom Shop - Product Grid Styles
 * Location: /wp-content/themes/blocksy/custom-loop/custom-shop.css
 */

/* ========================================
   Grid Container
   ======================================== */

#custom-product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin: 30px 0;
  min-height: 400px;
  position: relative;
}

#custom-product-grid.loading {
  opacity: 0.5;
  pointer-events: none;
}

/* ========================================
   Product Card
   ======================================== */

/* Wrapper link - makes entire card clickable */
.product-card-link {
  display: block;
  text-decoration: none !important;
  color: inherit;
  transition: all 0.3s ease;
}

.product-card-link:hover,
.product-card-link:focus,
.product-card-link:active,
.product-card-link:visited {
  text-decoration: none !important;
  color: inherit;
  outline: none;
}

.product-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 15px;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  position: relative;
}

.product-card-link:hover .product-card {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
  border-color: #4AA424;
}

/* ========================================
   Product Image
   ======================================== */

.product-image {
  position: relative;
  overflow: hidden;
  margin-bottom: -30px;
  border-radius: 4px;
  background-color: transparent;
  line-height: 0;
}

.product-image img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.3s ease;
}

.product-card-link:hover .product-image img {
  transform: scale(1.05);
}

/* ========================================
   Badge
   ======================================== */

.badge {
  position: absolute;
  top: 0;
  right: 0;
  background: #4AA424;
  color: white;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: bold;
  border-radius: 0 0 0 8px;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Acowebs Product Labels - Position wrapper relative to product-card */
.product-card .acoplw-badge {
  position: absolute !important;
  top: 10px !important;
  right: 10px !important;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  width: 65px !important;
  height: 65px !important;
  z-index: 10 !important;
}

/* Hide badge decorative pseudo-elements and shape elements */
.product-image .acoplw-badge::before,
.product-image .acoplw-badge::after,
.product-image .acoplw-badge-icon::before,
.product-image .acoplw-badge-icon::after,
.product-image .acoplw-shape,
.product-image .acoplw-badge-shape,
.product-image .acoplw-badge .shape {
  display: none !important;
}

/* Override badge style decorations */
.product-image .acoplw-bsseven::before,
.product-image .acoplw-bsseven::after {
  content: none !important;
  display: none !important;
}

/* Badge icon - 65x65px badge - OVERRIDE PLUGIN VISIBILITY */
.product-card .acoplw-badge-icon,
#custom-product-grid .product-card .acoplw-badge .acoplw-badge-icon,
#custom-product-grid .product-card .acoplw-badge-icon,
.product-card .product-image .acoplw-badge-icon,
.product-card .acoplw-badge-icon.acoplw-bsseven {
  /* Size - exactly 65x65px */
  width: 65px !important;
  height: 65px !important;
  min-width: 65px !important;
  max-width: 65px !important;
  min-height: 65px !important;
  max-height: 65px !important;

  /* Position - fills the wrapper */
  position: relative !important;
  top: 0 !important;
  right: 0 !important;
  left: 0 !important;
  bottom: 0 !important;

  /* Spacing - 5px padding around text */
  padding: 5px !important;
  margin: 0 !important;
  box-sizing: border-box !important;

  /* Visual */
  background: #49a424 !important;
  background-color: #49a424 !important;
  border-radius: 8px !important;
  box-shadow: none !important;
  -webkit-box-shadow: none !important;
  -moz-box-shadow: none !important;

  /* Layout - flexbox to center text */
  display: block !important;
  align-items: center !important;
  justify-content: center !important;

  /* Reset transforms */
  transform: none !important;
  -webkit-transform: none !important;

  /* Typography */
  color: white !important;
  font-size: 9px !important;
  font-weight: 500 !important;
  line-height: 1.2 !important;
  text-align: center !important;

  /* Ensure visibility */
  opacity: 1 !important;
  visibility: visible !important;
}

.product-card .acoplw-blockText {
  display: block !important;
  line-height: 1.2 !important;
  text-align: center !important;
  white-space: normal !important;
  word-wrap: break-word !important;
  word-break: break-word !important;
  color: white !important;
  font-size: 9px !important;
  font-weight: 500 !important;
  max-width: 100% !important;
}

/* Acowebs Product Labels fallback styling */
.acoplw-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #4AA424;
  color: white;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: bold;
  border-radius: 4px;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  line-height: 1.2;
}

/* ========================================
   Product Title
   ======================================== */

.product-title {
  color: #4AA424;
  font-family: 'Roboto', sans-serif;
  font-size: 16px;
  font-weight: 400;
  text-transform: uppercase;
  line-height: 1.2;
  text-align: center;
  margin: 0;
  padding-top: 38px;
  min-height: 44px;
  flex-grow: 1;
  transition: color 0.2s ease;
}

.product-card-link:hover .product-title {
  color: #45a049;
}

/* ========================================
   Product Price
   ======================================== */

.product-price {
  font-family: 'Roboto', sans-serif;
  font-size: 15px;
  font-weight: 300;
  line-height: 1.5;
  text-align: center;
  color: #333;
  margin-top: 10px;
  padding-top: 15px;
  position: relative;
}

/* Diagonal line divider above price */
.product-price::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 5px;
  background: repeating-linear-gradient(
    30deg,
    transparent,
    transparent 3px,
    rgba(74, 164, 36, 0.25) 3px,
    rgba(74, 164, 36, 0.25) 4px
  );
}

.product-price .sale-price-amount {
  font-weight: 500;
  color: #333;
}

.product-price .regular-price-amount {
  color: #999;
  font-size: 0.87em;
  text-decoration: line-through;
  margin-left: 2px;
}

/* ========================================
   Loading Spinner
   ======================================== */

.loading-spinner {
  text-align: center;
  padding: 40px;
  font-size: 16px;
  color: #666;
  display: none;
}

.loading-spinner.show {
  display: block;
}

.spinner-icon {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #4AA424;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 10px;
}

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

/* ========================================
   Error Message
   ======================================== */

.error-message {
  background: #ffebee;
  color: #c62828;
  padding: 20px;
  border-radius: 4px;
  text-align: center;
  margin: 20px 0;
  border: 1px solid #ef5350;
}

.error-message strong {
  display: block;
  margin-bottom: 5px;
  font-size: 16px;
}

/* ========================================
   No Products Message
   ======================================== */

.no-products {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: #666;
  font-size: 18px;
  background: #f9f9f9;
  border-radius: 8px;
  border: 2px dashed #ddd;
}

/* ========================================
   Pagination
   ======================================== */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 30px 0;
  flex-wrap: wrap;
}

.pagination a {
  padding: 8px 16px;
  border: 1px solid #ddd;
  background: white;
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  min-width: 40px;
  color: #333;
  text-decoration: none;
  display: inline-block;
}

.pagination a:hover:not(.active) {
  background: #f5f5f5;
  border-color: #4AA424;
  color: #4AA424;
}

.pagination a.active {
  background: #4AA424;
  color: white;
  border-color: #4AA424;
  cursor: default;
  pointer-events: none;
}

.pagination-ellipsis {
  padding: 8px 4px;
  color: #999;
}

/* ========================================
   Product Count
   ======================================== */

.product-count {
  text-align: center;
  color: #666;
  font-size: 14px;
  margin: 20px 0 10px;
  font-weight: 500;
}

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

/* Tablets and smaller laptops */
@media (max-width: 1199px) {
  #custom-product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
  }

  .product-title {
    font-size: 15px;
    min-height: 40px;
  }

  .product-price {
    font-size: 13px;
    padding-top: 20px;
  }

  .product-price::before {
    height: 5px;
  }
}

/* Tablets portrait */
@media (max-width: 767px) {
  #custom-product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 20px 0;
  }

  .product-card {
    padding: 12px;
  }

  .product-title {
    font-size: 14px;
    min-height: 38px;
    margin: 8px 0;
  }

  .product-price {
    font-size: 12px;
    margin-top: 8px;
    padding-top: 18px;
  }

  .product-price::before {
    height: 5px;
  }

  .badge {
    font-size: 11px;
    padding: 6px 10px;
  }

  .pagination a {
    padding: 6px 12px;
    font-size: 13px;
    min-width: 36px;
  }
}

/* Mobile phones */
@media (max-width: 479px) {
  #custom-product-grid {
    grid-template-columns: 1fr;
    gap: 15px;
    margin: 15px 0;
  }

  .product-card {
    padding: 15px;
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
  }

  .product-image {
    aspect-ratio: 4 / 5;
  }

  .product-title {
    font-size: 16px;
    min-height: 44px;
  }

  .product-price {
    font-size: 14px;
  }

  .badge {
    font-size: 12px;
    padding: 8px 12px;
  }

  .pagination {
    gap: 8px;
  }

  .pagination button {
    padding: 8px 12px;
    font-size: 13px;
  }

  .no-products {
    padding: 40px 20px;
    font-size: 16px;
  }
}

/* Very small screens */
@media (max-width: 360px) {
  .product-card {
    padding: 12px;
  }

  .product-title {
    font-size: 14px;
  }

  .product-price {
    font-size: 13px;
  }

  .pagination button {
    padding: 6px 10px;
    font-size: 12px;
    min-width: 32px;
  }
}

/* ========================================
   Filter Widgets (for dynamic filtering)
   ======================================== */

.filter-widget {
  background: transparent !important;
  padding: 0 !important;
  margin-bottom: 8px !important;
  border-radius: 0 !important;
  border: none !important;
  transition: opacity 0.3s ease;
}

.filter-widget.updating {
  opacity: 0.6;
  pointer-events: none;
}

.filter-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin: 0 0 15px 0;
  padding-bottom: 10px;
  border-bottom: none;
}

.filter-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.3s ease;
}

.filter-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #555;
  transition: all 0.2s ease;
  padding: 5px 0;
}

.filter-label:hover {
  color: #4AA424;
}

.filter-label input[type="checkbox"],
.filter-label input[type="radio"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #4AA424;
}

.filter-label input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.filter-label.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.filter-label.disabled input {
  pointer-events: none;
}

/* Filter select dropdown */
.filter-select {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  background: white;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.filter-select:hover {
  border-color: #4AA424;
}

.filter-select:focus {
  outline: none;
  border-color: #4AA424;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
}

/* Price filter inputs */
.price-inputs {
  display: flex;
  align-items: center;
  gap: 10px;
}

.price-inputs input {
  flex: 1;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  transition: border-color 0.2s ease;
}

.price-inputs input:hover {
  border-color: #4AA424;
}

.price-inputs input:focus {
  outline: none;
  border-color: #4AA424;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
}

.price-separator {
  color: #999;
  font-weight: 500;
}

/* Clear filters button */
.filter-actions {
  margin-top: 20px;
}

.clear-filters {
  width: 100%;
  padding: 12px;
  background: #4AA424 !important;
  color: white !important;
  border: none !important;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.3s ease;
}

.clear-filters:hover {
  background: #3d8a1d !important;
}

.clear-filters:active {
  transform: scale(0.98);
}

/* Filter loading state */
.filter-widget::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: none;
  z-index: 10;
}

.filter-widget.loading::before {
  display: block;
}

/* Smooth filter transitions */
.filter-options {
  max-height: 400px;
  overflow-y: auto;
}

.filter-options::-webkit-scrollbar {
  width: 6px;
}

.filter-options::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.filter-options::-webkit-scrollbar-thumb {
  background: #4AA424;
  border-radius: 3px;
}

.filter-options::-webkit-scrollbar-thumb:hover {
  background: #45a049;
}

/* Responsive filter adjustments */
@media (max-width: 767px) {
  .filter-widget {
    padding: 0 !important;
    margin-bottom: 8px !important;
  }

  .filter-title {
    font-size: 15px;
    margin-bottom: 12px;
  }

  .filter-label {
    font-size: 13px;
  }

  .price-inputs {
    flex-direction: column;
    gap: 8px;
  }

  .price-separator {
    display: none;
  }
}

/* ========================================
   Collapsible Filter Sections (New Design)
   ======================================== */

/* Make filter title clickable and add chevron */
.filter-widget {
  background: transparent !important;
  padding: 0 !important;
  margin-bottom: 8px !important;
  border-radius: 0 !important;
  border: none !important;
  transition: all 0.3s ease;
}

.filter-title {
  font-size: 18px;
  font-weight: 700;
  color: #000;
  margin: 0;
  border-bottom: none;
  cursor: pointer;
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  transition: background 0.2s ease;
}

.filter-title:hover {
  background: #f9f9f9;
}

/* Chevron icon */
.filter-title::after {
  content: '\25BC'; /* Down arrow */
  font-size: 14px;
  color: #333;
  transition: transform 0.3s ease;
  display: inline-block;
}

.filter-widget.collapsed .filter-title::after {
  transform: rotate(-90deg); /* Point right when collapsed */
}

/* Filter options container */
.filter-options {
  max-height: 300px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0px 10px 0px;
  display: block;
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
}

.filter-widget.collapsed .filter-options {
  max-height: 0;
  padding: 0 20px;
  opacity: 0;
  overflow: hidden;
}

/* Price filter inputs - special handling for collapse */
.price-inputs {
  padding: 15px 20px 20px;
  display: flex;
  gap: 10px;
  align-items: center;
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
  max-height: 100px;
  overflow: hidden;
}

.filter-widget.collapsed .price-inputs {
  max-height: 0;
  padding: 0 20px;
  opacity: 0;
  overflow: hidden;
}

/* Sort filter select - special handling for collapse */
.filter-select {
  padding: 10px 20px 20px;
  display: block;
  width: calc(100% - 40px);
  margin: 0 20px;
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
  max-height: 100px;
  overflow: hidden;
}

.filter-widget.collapsed .filter-select {
  max-height: 0;
  padding: 0 20px;
  margin: 0 20px;
  opacity: 0;
  overflow: hidden;
}

/* Scrollbar styling for filters */
.filter-options::-webkit-scrollbar {
  width: 8px;
}

.filter-options::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.filter-options::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

.filter-options::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* Override theme label styles */
.filter-widget label {
  margin: 0 !important;
}

/* Filter labels */
.filter-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 15px;
  color: #000;
  transition: all 0.2s ease;
  padding: 5px 0;
  font-weight: 400;
}

.filter-label:hover {
  color: #4AA424;
}

.filter-label span {
  line-height: 1.4;
}

/* Checkboxes and radios */
.filter-label input[type="checkbox"],
.filter-label input[type="radio"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: #4AA424;
  flex-shrink: 0;
}

/* Toggle switch for наличност filter (optional) */
.наличност-filter .filter-label input[type="checkbox"] {
  position: relative;
  appearance: none;
  width: 44px;
  height: 24px;
  background: #ccc;
  border-radius: 12px;
  outline: none;
  cursor: pointer;
  transition: background 0.3s;
}

.наличност-filter .filter-label input[type="checkbox"]::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  background: white;
  transition: transform 0.3s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.наличност-filter .filter-label input[type="checkbox"]:checked {
  background: #4AA424;
}

.наличност-filter .filter-label input[type="checkbox"]:checked::before {
  transform: translateX(20px);
}

/* Price filter styling */
.price-filter .price-inputs {
  padding: 0 20px 20px;
}

.price-inputs {
  display: flex;
  align-items: center;
  gap: 10px;
}

.price-inputs input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  transition: border-color 0.2s ease;
}

.price-inputs input:hover {
  border-color: #4AA424;
}

.price-inputs input:focus {
  outline: none;
  border-color: #4AA424;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
}

.price-separator {
  color: #999;
  font-weight: 500;
}

/* Sort filter dropdown */
.sort-filter .filter-select {
  margin: 0 20px 20px;
  width: calc(100% - 40px);
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  background: white;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.sort-filter .filter-select:hover {
  border-color: #4AA424;
}

.sort-filter .filter-select:focus {
  outline: none;
  border-color: #4AA424;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
}

/* Clear filters button */
.filter-actions {
  margin-top: 20px;
  padding: 0;
}

.clear-filters {
  width: 100%;
  padding: 14px;
  background: #4AA424 !important;
  color: white !important;
  border: none !important;
  border-radius: 4px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.clear-filters:hover {
  background: #3d8a1d !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(74, 164, 36, 0.3);
}

.clear-filters:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(74, 164, 36, 0.3);
}

/* Responsive adjustments for collapsible filters */
@media (max-width: 767px) {
  .filter-widget {
    margin-bottom: 12px;
  }

  .filter-title {
    font-size: 16px;
    padding: 15px;
  }

  .filter-title::after {
    font-size: 12px;
  }

  .filter-options {
    max-height: 250px;
    padding: 12px 15px 15px;
  }

  .filter-label {
    font-size: 14px;
    padding: 5px 0;
  }

  .price-filter .price-inputs,
  .sort-filter .filter-select {
    margin-left: 15px;
    margin-right: 15px;
    width: calc(100% - 30px);
  }

  .price-inputs {
    flex-direction: column;
    gap: 8px;
  }

  .price-separator {
    display: none;
  }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
  .pagination,
  .loading-spinner,
  .filter-widget {
    display: none !important;
  }

  .product-card {
    break-inside: avoid;
    box-shadow: none !important;
    border: 1px solid #ddd !important;
  }

  .product-card:hover {
    transform: none !important;
  }
}
