/* HivePress Category Modal Styles */

/* Hide original select fields when our plugin is active */
select[name="categories"],
select[name="category"],
select[name="categories"].select2-hidden-accessible,
select[name="category"].select2-hidden-accessible,
.hp-form__field--select .select2-container,
.hp-form__field .select2-container,
span.select2-container {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

/* Ensure our trigger field is visible and properly styled */
.hp-category-modal-trigger {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  width: 100% !important;
  cursor: pointer !important;
  background-color: #fff !important;
  border: 1px solid #ddd !important;
  padding: 8px 12px !important;
  border-radius: 4px !important;
  font-size: 14px !important;
  line-height: 1.4 !important;
}

.hp-category-modal-trigger:focus {
  border-color: #4285f4 !important;
  outline: none !important;
  box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2) !important;
}
.hp-category-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
}

.hp-category-modal {
  background: #fff;
  border-radius: 8px;
  width: 90%;
  max-width: 800px;
  max-height: 80vh;
  overflow: hidden;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.hp-category-modal-header {
  padding: 20px;
  border-bottom: 1px solid #e5e5e5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8f9fa;
}

.hp-category-modal-title {
  display: flex;
  align-items: center;
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.hp-category-modal-title .icon {
  margin-right: 10px;
  width: 24px;
  height: 24px;
}

.hp-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.hp-modal-close:hover {
  background-color: #f0f0f0;
}

.hp-category-modal-content {
  padding: 20px;
  max-height: 60vh;
  overflow-y: auto;
}

.hp-category-breadcrumb {
  margin-bottom: 20px;
  padding: 10px 0;
  border-bottom: 1px solid #e5e5e5;
}

.hp-breadcrumb-button {
  background: #4285f4;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
}

.hp-breadcrumb-button:hover {
  background: #3367d6;
}

.hp-breadcrumb-button .icon {
  margin-right: 5px;
}

.hp-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.hp-category-item {
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 20px 15px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #fff;
  text-decoration: none;
  color: inherit;
  display: block;
}

.hp-category-item:hover {
  border-color: #4285f4;
  box-shadow: 0 2px 8px rgba(66, 133, 244, 0.15);
  transform: translateY(-2px);
  text-decoration: none;
  color: inherit;
}

.hp-category-item.selected {
  border-color: #4285f4;
  background: #f0f7ff;
}

.hp-category-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 10px;
  background: #4285f4;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hp-category-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hp-category-icon.default {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-size: 24px;
}

.hp-category-name {
  font-weight: 500;
  font-size: 14px;
  color: #333;
  line-height: 1.3;
}

.hp-category-stats {
  padding: 15px 20px;
  background: #f8f9fa;
  border-top: 1px solid #e5e5e5;
  font-size: 14px;
  color: #666;
  text-align: center;
}

.hp-category-modal-trigger {
  cursor: pointer !important;
  background-color: #fff !important;
}

.hp-category-modal-trigger:focus {
  box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2);
}

/* Responsive Design */
@media (max-width: 768px) {
  .hp-category-modal {
    width: 95%;
    max-height: 90vh;
  }

  .hp-category-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }

  .hp-category-item {
    padding: 15px 10px;
  }

  .hp-category-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 8px;
  }

  .hp-category-name {
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .hp-category-modal-header {
    padding: 15px;
  }

  .hp-category-modal-content {
    padding: 15px;
  }

  .hp-category-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .hp-category-modal-title {
    font-size: 16px;
  }
}

/* Loading State */
.hp-category-loading {
  text-align: center;
  padding: 40px;
  color: #666;
}

.hp-category-loading::after {
  content: "";
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #e5e5e5;
  border-radius: 50%;
  border-top-color: #4285f4;
  animation: spin 1s ease-in-out infinite;
  margin-left: 10px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Animation */
.hp-category-modal-overlay.show {
  display: flex;
  animation: fadeIn 0.3s ease;
}

.hp-category-modal-overlay.show .hp-category-modal {
  animation: slideIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
