/**
 * Hi-Kataloog™ Phase 2 Features Styles
 * 
 * @package Hi-Kataloog
 * @version 0.7.0
 * @author HiCare OÜ
 * @copyright Copyright (c) 2024 HiCare OÜ
 * @license Proprietary - All Rights Reserved
 */

/* ============================================================================
   11. CATEGORY FILTERS
   ============================================================================ */

.hk-filter-bar {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.hk-filter-bar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.hk-filter-bar__label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 16px;
  color: #333;
}

.hk-filter-icon {
  color: #2196F3;
}

.hk-filter-clear {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: #f5f5f5;
  color: #666;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.hk-filter-clear:hover {
  background: #e0e0e0;
  color: #333;
}

.hk-filter-bar__options {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

/* Filter Dropdown */
.hk-filter-dropdown {
  position: relative;
  min-width: 200px;
}

.hk-filter-dropdown__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  cursor: pointer;
  transition: all 0.2s;
}

.hk-filter-dropdown__toggle:hover {
  border-color: #2196F3;
}

.hk-filter-dropdown__toggle svg {
  transition: transform 0.2s;
}

.hk-filter-dropdown__menu.is-open .hk-filter-dropdown__toggle svg {
  transform: rotate(180deg);
}

.hk-filter-dropdown__menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 250px;
  max-height: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  opacity: 0;
}

.hk-filter-dropdown__menu.is-open {
  max-height: 400px;
  overflow-y: auto;
  opacity: 1;
}

.hk-filter-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.hk-filter-option:hover {
  background: #f5f5f5;
}

.hk-filter-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.hk-filter-option span {
  font-size: 14px;
  color: #333;
}

/* Filter Badges */
.hk-filter-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
}

.hk-filter-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #2196F3;
  color: #fff;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  animation: badgeSlideIn 0.3s ease;
}

.hk-filter-badge button {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(255,255,255,0.2);
  color: #fff;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s;
}

.hk-filter-badge button:hover {
  background: rgba(255,255,255,0.3);
}

@keyframes badgeSlideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* No Results */
.hk-no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.hk-no-results svg {
  opacity: 0.5;
  margin-bottom: 16px;
}

.hk-no-results h3 {
  font-size: 20px;
  margin-bottom: 8px;
  color: #666;
}

.hk-no-results p {
  font-size: 14px;
}

/* ============================================================================
   12. VERSION CONTROL
   ============================================================================ */

.hk-version-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 4px 8px;
  background: rgba(33, 150, 243, 0.9);
  color: #fff;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  z-index: 10;
}

.hk-changelog-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: #fff;
  color: #666;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.hk-changelog-btn:hover {
  background: #f5f5f5;
  border-color: #2196F3;
  color: #2196F3;
}

/* Changelog Modal */
.hk-changelog-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.hk-changelog-modal.is-open {
  opacity: 1;
}

.hk-changelog-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}

.hk-changelog-modal__content {
  position: relative;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.hk-changelog-modal.is-open .hk-changelog-modal__content {
  transform: scale(1);
}

.hk-changelog-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #e0e0e0;
}

.hk-changelog-modal__header h2 {
  margin: 0;
  font-size: 20px;
  color: #333;
}

.hk-changelog-modal__close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: #f5f5f5;
  color: #666;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s;
}

.hk-changelog-modal__close:hover {
  background: #e0e0e0;
  color: #333;
}

.hk-changelog-modal__body {
  padding: 24px;
  max-height: calc(80vh - 80px);
  overflow-y: auto;
}

.hk-changelog-modal__body h3 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 16px;
  color: #2196F3;
}

.hk-changelog-modal__body li {
  margin-bottom: 8px;
  padding-left: 20px;
  position: relative;
  color: #666;
  font-size: 14px;
  line-height: 1.6;
}

.hk-changelog-modal__body li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #2196F3;
  font-weight: bold;
}

/* ============================================================================
   13. BULK OPERATIONS (Admin)
   ============================================================================ */

.hk-bulk-panel {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
}

.hk-bulk-panel h2 {
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 20px;
  color: #333;
}

.hk-bulk-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

.hk-bulk-action {
  padding: 20px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background: #f9f9f9;
}

.hk-bulk-action h3 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 16px;
  color: #333;
}

.hk-bulk-action p {
  margin-bottom: 16px;
  font-size: 14px;
  color: #666;
}

.hk-bulk-action input[type="file"],
.hk-bulk-action select {
  width: 100%;
  margin-bottom: 12px;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.hk-bulk-progress {
  margin-top: 16px;
}

.hk-progress-bar {
  width: 100%;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.hk-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2196F3, #21CBF3);
  border-radius: 4px;
  width: 0;
  transition: width 0.3s ease;
}

.hk-progress-text {
  font-size: 13px;
  color: #666;
  font-weight: 600;
}

/* ============================================================================
   14. STATS DASHBOARD (Admin)
   ============================================================================ */

.hk-stats-dashboard {
  padding: 20px;
}

.hk-stats-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.hk-stat-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  transition: transform 0.2s, box-shadow 0.2s;
}

.hk-stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.hk-stat-card h3 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 500;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hk-stat-value {
  font-size: 36px;
  font-weight: 700;
  color: #2196F3;
  line-height: 1;
}

.hk-top-catalogues {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 30px;
}

.hk-top-catalogues h3 {
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 18px;
  color: #333;
}

.hk-top-catalogues table {
  width: 100%;
}

.hk-top-catalogues th {
  text-align: left;
  padding: 12px;
  background: #f5f5f5;
  font-weight: 600;
  color: #666;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hk-top-catalogues td {
  padding: 12px;
  border-bottom: 1px solid #e0e0e0;
  color: #666;
}

.hk-top-catalogues tr:last-child td {
  border-bottom: none;
}

/* ============================================================================
   15. LAZY LOADING ENHANCEMENTS
   ============================================================================ */

.hk-catalog-card__image img {
  opacity: 0;
  transition: opacity 0.5s ease;
}

.hk-catalog-card__image img.is-loaded {
  opacity: 1;
}

/* Loading placeholder */
.hk-catalog-card__image img[data-src] {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ============================================================================
   16. RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
  .hk-filter-bar {
    padding: 16px;
  }

  .hk-filter-bar__options {
    flex-direction: column;
    align-items: stretch;
  }

  .hk-filter-dropdown {
    width: 100%;
  }

  .hk-filter-badges {
    width: 100%;
  }

  .hk-bulk-actions {
    grid-template-columns: 1fr;
  }

  .hk-stats-overview {
    grid-template-columns: repeat(2, 1fr);
  }

  .hk-changelog-modal__content {
    width: 95%;
    max-height: 90vh;
  }

  .hk-top-catalogues {
    overflow-x: auto;
  }

  .hk-top-catalogues table {
    min-width: 600px;
  }
}

@media (max-width: 480px) {
  .hk-stats-overview {
    grid-template-columns: 1fr;
  }

  .hk-filter-bar__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .hk-stat-value {
    font-size: 28px;
  }
}

/* ============================================================================
   17. ACCESSIBILITY
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  .hk-filter-badge,
  .hk-changelog-modal,
  .hk-changelog-modal__content,
  .hk-stat-card,
  .hk-catalog-card__image img {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus states */
.hk-filter-option:focus-within {
  outline: 2px solid #2196F3;
  outline-offset: 2px;
}

.hk-changelog-btn:focus,
.hk-filter-clear:focus,
.hk-filter-dropdown__toggle:focus {
  outline: 2px solid #2196F3;
  outline-offset: 2px;
}

/* ============================================================================
   18. PRINT STYLES
   ============================================================================ */

@media print {
  .hk-filter-bar,
  .hk-filter-badges,
  .hk-changelog-btn,
  .hk-version-badge {
    display: none !important;
  }

  .hk-catalog-card {
    break-inside: avoid;
  }
}
