/**
 * AFEL Widgets Stylesheet
 *
 * @package AFEL
 */

/*--------------------------------------------------------------
------------------------ Widget styles -------------------------
--------------------------------------------------------------*/

/* Widget styles */

.afel-widget {
  padding: 20px;
  border: 1px solid var(--afel-border-color);
  border-radius: 6px;
}

.afel-widget.widget_media_image,
.afel-widget.widget_afel_search_post,
.afel-widget.widget_afel_search_tool,
.widget_afel_featured_tools {
  padding: 0;
  border: none;
  border-radius: 6px;
}

.afel-widget__title {
  font-size: 20px;
  margin-top: 0;
  margin-bottom: 16px;
  font-weight: 600;
}

/**
 * AFEL All Categories Widget Styles
 *
 * @package AFEL
 */

.afel-categories-accordion {
  background-color: var(--afel-body-bg);
  border-radius: 6px;
  overflow: hidden;
}

.afel-category-item:last-child {
  border-bottom: none;
}

.afel-category-header {
  display: flex;
  padding: 8px 12px;
  border-radius: 6px;
  align-items: center;
  position: relative;
}

.afel-category-header:hover {
  background-color: var(--afel-light-bg);
}

.afel-category-header.has-children {
  cursor: pointer;
}

/* Current category highlighting */
.afel-category-item.current-category .afel-category-header {
  background-color: var(--afel-light-bg);
}

.afel-category-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-right: 12px;
  color: var(--afel-brand-color);
  flex-shrink: 0;
}

.afel-category-icon .menu-icon {
  width: 20px;
  height: 20px;
}

/* Current category icon highlighting */
.afel-category-item.current-category .afel-category-icon {
  color: var(--afel-brand-color);
}

.afel-category-link {
  flex: 1;
  color: var(--afel-primary-text-color);
  text-decoration: none;
  font-weight: 600;
  font-size: 16px;
  line-height: 1.4;
  transition: color var(--afel-transition-normal) ease;
}

.afel-category-link:hover {
  color: var(--afel-brand-color);
  text-decoration: none;
}

/* Current category link highlighting */
.afel-category-link.current {
  color: var(--afel-brand-color);
  font-weight: 600;
}

.afel-category-toggle {
  display: flex;
  justify-content: center;
  align-items: center;
  border: none;
  width: 32px;
  height: 32px;
  background: transparent;
  cursor: pointer;
  color: var(--afel-secondary-text-color);
  transition: all var(--afel-transition-normal) ease;
  margin-left: 12px;
  position: relative;
}

.afel-category-toggle:hover {
  background-color: var(--afel-brand-color);
  border-color: var(--afel-brand-color);
  color: white;
}

.afel-category-toggle:focus {
  outline: 2px solid var(--afel-brand-color);
  outline-offset: 2px;
}

.afel-toggle-icon {
  width: 14px;
  height: 14px;
  transition: all var(--afel-transition-normal) ease;
  min-width: 14px;
  font-weight: 400;
  display: none;
}

.afel-toggle-icon svg {
  width: 14px;
  height: 14px;
}

.afel-toggle-icon.active {
  display: block;
}

.afel-toggle-icon-plus {
  display: block;
}

.afel-toggle-icon-minus {
  display: none;
}

.afel-category-item.expanded .afel-toggle-icon-plus {
  display: none;
}

.afel-category-item.expanded .afel-toggle-icon-minus {
  display: block;
}

.afel-category-children {
  display: none;
  border-radius: 6px;
}

/* Current child category highlighting */
.afel-child-category-item.current-child-category {
  background-color: var(--afel-body-bg);
}

.afel-child-category-link {
  display: block;
  padding: 4px 16px 4px 52px;
  color: var(--afel-secondary-text-color);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.4;
  transition: all var(--afel-transition-normal) ease;
  position: relative;
}

.afel-child-category-link:before {
  content: "";
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  background-color: var(--afel-secondary-text-color);
  border-radius: 50%;
  transition: background-color var(--afel-transition-normal) ease;
}

.afel-child-category-link:hover {
  /* background-color: var(--afel-body-bg); */
  color: var(--afel-brand-color);
  text-decoration: none;
  /* padding-left: 56px; */
}

.afel-child-category-link:hover:before {
  background-color: var(--afel-brand-color);
}

/* Current child category link highlighting */
.afel-child-category-link.current {
  color: var(--afel-brand-color);
  font-weight: 600;
  background-color: var(--afel-body-bg);
  /* padding-left: 56px; */
}

.afel-child-category-link.current:before {
  background-color: var(--afel-brand-color);
}

/* Focus states for accessibility */
.afel-category-link:focus,
.afel-child-category-link:focus {
  outline: 2px solid var(--afel-brand-color);
  outline-offset: 2px;
}

/* Animation for smooth transitions */
.afel-category-header,
.afel-category-link,
.afel-child-category-link,
.afel-category-toggle {
  transition: all var(--afel-transition-normal) ease;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .afel-category-icon {
    width: 18px;
    height: 18px;
    margin-right: 10px;
  }

  .afel-category-icon .menu-icon {
    width: 16px;
    height: 16px;
  }

  .afel-category-link {
    font-size: 15px;
  }

  .afel-category-toggle {
    width: 28px;
    height: 28px;
    margin-left: 8px;
  }

  .afel-toggle-icon {
    width: 12px;
    height: 12px;
  }

  .afel-child-category-link {
    padding: 10px 12px 10px 44px;
    font-size: 13px;
  }

  .afel-child-category-link:before {
    left: 24px;
  }

  .afel-child-category-link:hover {
    padding-left: 48px;
  }

  .afel-child-category-link.current {
    padding-left: 48px;
  }
}

/**
 * AFEL Advanced Search Widget Styles
 *
 * @package AFEL
 */

.afel-advanced-search-form {
  font-size: 14px;
}

.afel-advanced-search-form label {
  font-weight: 600;
}

.afel-advanced-search-form select {
  appearance: none;
  padding-right: 24px;
  margin-top: 4px;
  background-clip: border-box;
  background: var(--afel-body-bg)
    url(data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D%2220%22%20height%3D%2220%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%206l5%205%205-5%202%201-7%207-7-7%202-1z%22%20fill%3D%22%23555%22%2F%3E%3C%2Fsvg%3E)
    no-repeat right 5px top 55%;
  background-size: 16px 16px;
}

.afel-search-field-group,
.afel-search-filters,
.afel-filter-group {
  margin-bottom: 16px;
}

.afel-advanced-search-form .afel-search-button {
  font-size: 16px;
  width: 100%;
  margin-top: 8px;
}

.afel-search-field-group input.error {
  border-color: #e74c3c;
  box-shadow: 0 0 5px rgba(231, 76, 60, 0.3);
}

.afel-search-error {
  color: #e74c3c;
  font-size: 12px;
  margin-top: 5px;
  padding: 5px;
  background: #fdf2f2;
  border-radius: 3px;
}

/* Disabled Button Styles */
.afel-search-button:disabled {
  background: #6c757d !important;
  border: 1px solid #6c757d !important;
  color: #ffffff !important;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
  opacity: 0.8;
}

.afel-search-button.loading {
  background: #6c757d !important;
  cursor: not-allowed;
  pointer-events: none;
}

/* Spinner Animation */
.afel-spinner {
  margin-bottom: -4px;
  margin-left: 6px;
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: afel-spin 1s linear infinite;
  flex-shrink: 0;
}

@keyframes afel-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Loading state text */
.afel-search-button.loading .afel-button-text {
  margin-left: 4px;
}

/* Focus styles for accessibility */
.afel-search-button:focus {
  outline: 2px solid #007cba;
  outline-offset: 2px;
}

.afel-search-button:disabled:focus {
  outline: 2px solid #6c757d;
  outline-offset: 2px;
}

/* Pagination Loading Spinner (for pagination loading states) */
.afel-pagination-loading .afel-spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(73, 80, 87, 0.3);
  border-top-color: #495057;
  margin-right: 8px;
}

/* Enhanced error and loading states */
.afel-search-form-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.afel-search-form-loading::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  z-index: 10;
  border-radius: inherit;
}

/* Responsive Design */
@media (max-width: 768px) {
  .afel-advanced-search-widget {
    padding: 15px;
  }

  .afel-search-button {
    font-size: 14px;
    padding: 10px 16px;
  }

  .afel-spinner {
    width: 14px;
    height: 14px;
    border-width: 2px;
  }

  .afel-pagination-loading .afel-spinner {
    width: 16px;
    height: 16px;
    border-width: 2px;
  }
}

@media (max-width: 480px) {
  .afel-search-button {
    font-size: 13px;
    padding: 8px 12px;
  }

  .afel-spinner {
    width: 12px;
    height: 12px;
    border-width: 1px;
  }
}

/**
 * AFEL Search Posts Widget Styles
 *
 * @package AFEL
 */

.widget_afel_search_post .afel-post-search {
  position: relative;
}

.widget_afel_search_post .afel-search-field {
  margin-top: 0;
  padding-right: 48px;
}

.widget_afel_search_post .afel-search-submit {
  position: absolute;
  top: 1px;
  right: 0;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: var(--afel-brand-color);
  border-radius: 0 6px 6px 0;
}

.widget_afel_search_post .afel-search-submit:hover {
  color: #fff;
  background-color: var(--afel-brand-color);
}

.widget_afel_search_post .afel-search-submit svg {
  width: 20px;
  height: 20px;
}

/**
 * AFEL Search Tools Widget Styles
 *
 * @package AFEL
 */

.widget_afel_search_tool .afel-tool-search {
  position: relative;
}

.widget_afel_search_tool .afel-search-field {
  margin-top: 0;
  padding-right: 48px;
}

.widget_afel_search_tool .afel-search-submit {
  position: absolute;
  top: 1px;
  right: 0;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: var(--afel-brand-color);
  border-radius: 0 6px 6px 0;
}

.widget_afel_search_tool .afel-search-submit:hover {
  color: #fff;
  background-color: var(--afel-brand-color);
}

.widget_afel_search_tool .afel-search-submit svg {
  width: 20px;
  height: 20px;
}

/* Featured Post Widget */

.afel-featured-post-item {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.afel-featured-post-item .afel-post-thumbnail img {
  width: 68px;
  height: 68px;
  object-fit: cover;
  overflow: hidden;
  border-radius: 6px;
  margin-top: 4px;
}

.afel-featured-post-item .afel-post-thumbnail {
  flex: 1;
}

.afel-featured-post-item .afel-post-content {
  flex: 3;
}

.afel-featured-post-item .afel-post-content .afel-post-title {
  margin: 0;
}

.afel-featured-post-item .afel-post-content a {
  font-size: 16px;
  font-weight: 400;
  color: var(--afel-primary-text-color);
}

.afel-featured-post-item .afel-post-category .category-link,
.afel-featured-post-item .afel-post-author {
  font-size: 12px;
  color: var(--afel-secondary-text-color);
}

.afel-featured-post-item .afel-post-author {
  margin-top: 4px;
}

@media (max-width: 768px) {
  .afel-featured-posts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
  }
  .afel-featured-post-item .afel-post-thumbnail img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    overflow: hidden;
    border-radius: 6px;
    margin-top: 4px;
  }

  .afel-featured-post-item .afel-post-thumbnail {
    flex: 1;
  }

  .afel-featured-post-item .afel-post-content {
    flex: 4;
  }
}

/* Feature Tool Widget */

.afel-featured-tools .afel-tool-card {
  margin-bottom: 20px;
}

.afel-featured-tools .afel-tool-card__header {
  margin-bottom: 10px;
}

.afel-featured-tools .afel-favorite-tool-btn {
  padding: 6px;
}

.afel-featured-tools .afel-favorite-tool-btn svg {
  width: 16px;
  height: 16px;
}

.afel-featured-tools .afel-tool-card__price-type {
  margin: 0;
}

.afel-featured-tools .afel-tool-card__visit-link {
  padding: 0;
  color: var(--afel-brand-color);
  background: transparent;
}

.afel-featured-tools .afel-tool-card__visit-link:hover {
  padding: 0;
  color: var(--afel-secondary-color);
  background: transparent;
  text-decoration: underline;
}

@media (max-width: 768px) {
  .afel-featured-tools {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
  }
}
