/* public/assets/css/sidebarComponent.css */

/* =========================================================
   Sidebar component wrapper
   ========================================================= */

.sidebar-component-outer {
  margin-top: 2.5rem;
  margin-bottom: 2.5rem;
}

.sidebar-component {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0;
  min-height: 400px;
}

/* Contained width — respects the page's content wrapper */
.sidebar-component.sidebar-layout-contained {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Full-width — breaks out to browser edges */
.sidebar-component.sidebar-layout-full-width {
  max-width: 100%;
  padding: 0;
}

/* =========================================================
   Section nav (left column — desktop)
   ========================================================= */

.sidebar-section-nav {
  border-right: 1px solid #e9ecef;
  padding: 16px 0;
  position: relative;
}

/* Sticky nav — stays visible while content scrolls */
.sidebar-section-nav.sidebar-sticky-nav {
  position: sticky;
  top: 80px; /* adjust if your navbar height differs */
  align-self: start;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.sidebar-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 20px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  font-size: 0.95rem;
  color: #555;
  border-left: 3px solid transparent;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}

.sidebar-tab:hover {
  background: #f8f9fa;
  color: #333;
}

.sidebar-tab.is-active {
  background: #fff5f5;
  border-left-color: var(--sidebar-accent, #4f215c);
  color: var(--sidebar-accent, #4f215c);
  font-weight: 600;
}

.sidebar-tab i {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  font-size: 1rem;
}

/* =========================================================
   Content area (right column)
   ========================================================= */

.sidebar-content-area {
  padding: 24px 28px;
  min-width: 0; /* prevents grid blowout */
}

.sidebar-panel {
  display: none;
}

.sidebar-panel.is-active {
  display: block;
}

/* =========================================================
   Search bar
   ========================================================= */

.sidebar-search-bar {
  margin-bottom: 14px;
}

.sidebar-search-input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border: 1px solid #ddd;
  border-radius: 24px;
  font-size: 0.95rem;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23aaa' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E")
    no-repeat 14px center;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.sidebar-search-input:focus {
  outline: none;
  border-color: var(--sidebar-accent, #4f215c);
  box-shadow: 0 0 0 3px rgba(202, 7, 19, 0.1);
}

/* =========================================================
   Filter bar
   ========================================================= */

.sidebar-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.sidebar-filter-select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
  background: white;
  cursor: pointer;
  min-width: 140px;
  transition: border-color 0.2s;
}

.sidebar-filter-select:focus {
  outline: none;
  border-color: var(--sidebar-accent, #4f215c);
}

/* =========================================================
   Items grid
   ========================================================= */

.sidebar-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.sidebar-item {
  background: white;
  border-radius: 10px;
  border: 1px solid #eee;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}

.sidebar-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.sidebar-item-media {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #f0f0f0;
}

.sidebar-item-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sidebar-item-body {
  padding: 16px;
}

.sidebar-item-title {
  margin: 0 0 8px 0;
  font-size: 1rem;
  font-weight: 600;
  color: #222;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sidebar-item-desc {
  margin: 0 0 12px 0;
  font-size: 0.88rem;
  color: #666;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sidebar-item-link {
  display: inline-block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--sidebar-accent, #4f215c);
  text-decoration: none;
  transition: opacity 0.15s;
}

.sidebar-item-link:hover {
  opacity: 0.75;
  text-decoration: underline;
}

/* =========================================================
   Pagination
   ========================================================= */

.sidebar-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 8px 0 4px;
}

.sidebar-pagination button {
  padding: 7px 18px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: white;
  font-size: 0.9rem;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}

.sidebar-pagination button:hover:not(:disabled) {
  background: #f8f9fa;
  border-color: var(--sidebar-accent, #4f215c);
}

.sidebar-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.sidebar-page-indicator {
  font-size: 0.88rem;
  color: #666;
}

/* =========================================================
   Empty state
   ========================================================= */

.sidebar-empty {
  text-align: center;
  padding: 48px 20px;
  color: #aaa;
  font-size: 0.95rem;
}

/* =========================================================
   Loading overlay (shown during AJAX)
   ========================================================= */

.sidebar-loading {
  text-align: center;
  padding: 40px;
  color: #aaa;
  font-size: 0.95rem;
}

.sidebar-loading::after {
  content: "";
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #ddd;
  border-top-color: var(--sidebar-accent, #4f215c);
  border-radius: 50%;
  animation: sidebar-spin 0.7s linear infinite;
  vertical-align: middle;
  margin-left: 10px;
}

@keyframes sidebar-spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================================================
   Mobile — horizontal scrollable tabs  (<768px)
   ========================================================= */

@media (max-width: 767px) {
  .sidebar-component {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar-section-nav {
    border-right: none;
    border-bottom: 1px solid #e9ecef;
    padding: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Fade shadow on right edge to hint at scrollability */
    -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
    mask-image: linear-gradient(to right, black 85%, transparent 100%);
  }

  .sidebar-section-nav::-webkit-scrollbar {
    display: none;
  }

  /* Lay tabs out in a horizontal row */
  .sidebar-section-nav {
    display: flex;
    flex-direction: row;
    white-space: nowrap;
  }

  .sidebar-tab {
    flex-shrink: 0;
    padding: 12px 18px;
    border-left: none;
    border-bottom: 3px solid transparent;
    font-size: 0.9rem;
    white-space: nowrap;
  }

  .sidebar-tab.is-active {
    background: #fff5f5;
    border-bottom-color: var(--sidebar-accent, #4f215c);
    border-left-color: transparent;
  }

  .sidebar-content-area {
    padding: 16px;
  }

  .sidebar-items-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   Component title + inner panel title
   ========================================================= */

.sidebar-component-title {
  font-size: 1.6rem;
  text-align: center;
  font-weight: 700;
  margin: 0 0 1rem;
  color: #222;
}

.sidebar-inner-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 12px;
  color: #333;
}

/* =========================================================
   Tag badges
   ========================================================= */

.sidebar-item-tags {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.sidebar-tag {
  font-size: 0.72rem;
  background: #f0f0f0;
  padding: 4px 8px;
  border-radius: 8px;
  color: #555;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  row-gap: 2px;
  max-width: 100%;
  min-width: 0;
}

.sidebar-tag-label {
  font-weight: 600;
  color: #444;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.sidebar-tag-value {
  display: block;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* =========================================================
   Video card
   ========================================================= */

.sidebar-item-video {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
  cursor: pointer;
}

.sidebar-item-video img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.85;
  display: block;
}

.sidebar-play-btn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: white;
  pointer-events: none;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

/* =========================================================
   Video modal
   ========================================================= */

.sidebar-video-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

.sidebar-video-modal.is-open {
  display: flex;
}

.sidebar-video-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
}

.sidebar-video-modal-box {
  position: relative;
  width: min(90vw, 960px);
  z-index: 1;
}

.sidebar-video-modal-close {
  position: absolute;
  top: -2.25rem;
  right: 0;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.8;
  transition: opacity 0.15s;
}

.sidebar-video-modal-close:hover {
  opacity: 1;
}

.sidebar-video-modal-content {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}

.sidebar-video-modal-content iframe,
.sidebar-video-modal-content video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* =========================================================
   Reduced motion
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  .sidebar-item,
  .sidebar-tab,
  .sidebar-search-input,
  .sidebar-filter-select,
  .sidebar-pagination button {
    transition: none;
  }

  .sidebar-loading::after {
    animation: none;
  }
}
