/**
 * Reusable UI Components
 * This file contains styles for reusable components across the application
 */

/* ============================================
   EQUAL HEIGHT CARDS
   Makes cards in a grid have equal heights
   ============================================ */

.items-grid-view {
  display: flex;
  flex-wrap: wrap;
}

.items-grid-view > [class*="col-"] {
  display: flex;
}

.items-grid-view .vidsafe_card,
.items-grid-view .card {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.items-grid-view .card-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.items-grid-view .card-body .row {
  margin-top: auto;
}

/* Course title fixed height */
.items-grid-view .course_title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 48px;
}

/* Course subtitle fixed height */
.items-grid-view .course_subtitle {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 40px;
}

/* Hidden items in grid */
.items-grid-view > .hidden {
  display: none !important;
}

/* ============================================
   VIEW TOGGLE COMPONENT
   Used for switching between grid and table views
   ============================================ */

.view-toggle-container {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: #f0f0f0;
  border-radius: 6px;
  padding: 3px;
}

.view-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 4px;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-toggle-btn:hover {
  color: #333;
  background-color: #e0e0e0;
}

.view-toggle-btn.active {
  background-color: #fff;
  color: #0d6efd;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.view-toggle-btn i {
  font-size: 16px;
}

/* ============================================
   FILTER SIDEBAR COMPONENT
   Used for filter offcanvas/sidebar
   ============================================ */

.filter-chip {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  margin: 0;
}

.filter-chip input[type="checkbox"] {
  display: none;
}

.filter-chip-label {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  background-color: #f0f0f0;
  border: 1px solid #ddd;
  color: #555;
  transition: all 0.2s ease;
  user-select: none;
}

.filter-chip-label:hover {
  background-color: #e0e0e0;
  border-color: #ccc;
}

.filter-chip input[type="checkbox"]:checked + .filter-chip-label {
  background-color: #0d6efd;
  border-color: #0d6efd;
  color: white;
}

.filter-section-title {
  font-weight: 600;
  color: #333;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-section {
  padding-bottom: 16px;
  border-bottom: 1px solid #eee;
}

.filter-section:last-child {
  border-bottom: none;
}

.offcanvas.filter-offcanvas {
  width: 360px !important;
}

.offcanvas-footer {
  background-color: #f8f9fa;
}

.filter-count-badge {
  transition: all 0.2s ease;
}

.clear-filters-btn {
  transition: all 0.2s ease;
}

/* Active filter pills displayed below search */
.active-filters-display {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0;
}

.active-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 12px;
  background-color: #e7f1ff;
  border: 1px solid #b6d4fe;
  border-radius: 20px;
  font-size: 12px;
  color: #0d6efd;
}

.active-filter-pill .remove-filter {
  cursor: pointer;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: #0d6efd;
  color: white;
  font-size: 10px;
  transition: background-color 0.2s;
}

.active-filter-pill .remove-filter:hover {
  background-color: #0b5ed7;
}

/* ============================================
   COURSE META TAGS COMPONENT
   Used for displaying course metadata (centers, tags, languages)
   ============================================ */

.course-meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.meta-tag i {
  font-size: 10px;
}

.meta-tag-center {
  background-color: #e8f4fd;
  color: #0c7cd5;
  border: 1px solid #bee5ff;
}

.meta-tag-language {
  background-color: #e8f8f0;
  color: #0a7b4e;
  border: 1px solid #a7e9c8;
}

.meta-tag-tags-group {
  background-color: #fff8e6;
  color: #b58105;
  border: 1px solid #ffe082;
  flex-wrap: wrap;
  max-width: 100%;
}

.tag-item {
  background-color: #ffc107;
  color: #000;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  margin-left: 2px;
}

.tag-hidden {
  display: none !important;
}

.tag-more-btn, .tag-less-btn {
  color: #b58105;
  font-size: 10px;
  cursor: pointer;
  text-decoration: underline;
  margin-left: 4px;
}

.tag-more-btn:hover, .tag-less-btn:hover {
  color: #8a6404;
}

.tags-expanded .tag-hidden {
  display: inline !important;
}

/* ============================================
   TABLE VIEW COMPONENT
   Styles for table/list view of items
   ============================================ */

.items-table-view {
  display: none;
}

.items-table-view.active {
  display: block;
}

.items-grid-view.hidden {
  display: none !important;
}

/* Courses table specific styles */
.courses-table {
  vertical-align: middle;
}

.courses-table th {
  font-weight: 600;
  /* font-size: 13px; */
  white-space: nowrap;
  /* background-color: #f8f9fa; */
}

.courses-table td {
  vertical-align: middle;
}

.courses-table tbody tr.hidden {
  display: none !important;
}

/* Table thumbnail image */
.table-thumbnail {
  width: 70px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  background-color: #f0f0f0;
}

/* Table course title cell */
.table-course-title {
  font-weight: 600;
  color: #333;
  text-decoration: none;
  display: block;
  margin-bottom: 2px;
}

.table-course-title:hover {
  color: #0d6efd;
  text-decoration: none;
}

.table-course-subtitle {
  font-size: 12px;
  color: #6c757d;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}

/* Table actions */
.table-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.table-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 4px;
  border: 1px solid #dee2e6;
  background: white;
  color: #495057;
  text-decoration: none;
  transition: all 0.15s ease;
}

.table-action-btn:hover {
  background-color: #e9ecef;
  border-color: #adb5bd;
  color: #212529;
  text-decoration: none;
}

.table-action-btn i {
  font-size: 13px;
}

/* Table meta tags (compact version) */
.table-meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 220px;
}

.table-meta-tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
}

.table-meta-tag.center {
  background-color: #e8f4fd;
  color: #0c7cd5;
}

.table-meta-tag.language {
  background-color: #e8f8f0;
  color: #0a7b4e;
}

.table-meta-tag.tag {
  background-color: #fff8e6;
  color: #b58105;
}

/* Price display in table */
.table-price {
  white-space: nowrap;
}

.table-price .old-price {
  text-decoration: line-through;
  color: #6c757d;
  font-size: 12px;
  margin-right: 4px;
}

.table-price .current-price {
  font-weight: 600;
  color: #198754;
}

/* Search hidden state for table rows */
.search-hidden {
  display: none !important;
}

/* Hidden state */
.data-table tbody tr.hidden {
  display: none !important;
}

@media (max-width: 992px) {
  .table-thumbnail {
    width: 60px;
    height: 34px;
  }
  
  .view-toggle-container {
    margin-top: 10px;
  }
  
  .table-meta-tags {
    max-width: 150px;
  }
}
