/* Layout */
.container-narrow { max-width: min(1100px, 90vw); margin: 0 auto; }
@media (min-width: 992px) { .container-narrow { max-width: 70vw; } }

/* Custom orange primary color */
:root {
  --bs-primary: #ff7b00;
  --bs-primary-rgb: 255, 170, 0;
}

.btn-primary {
  background-color: #ff7b00 !important;
  border-color: #ff7b00 !important;
  color: #000 !important;
}

.btn-primary:hover {
  background-color: #e69900 !important;
  border-color: #e69900 !important;
  color: #000 !important;
}

.btn-primary:focus, .btn-primary.focus {
  background-color: #e69900 !important;
  border-color: #e69900 !important;
  color: #000 !important;
  box-shadow: 0 0 0 0.2rem rgba(255, 170, 0, 0.5) !important;
}

.btn-primary:active, .btn-primary.active {
  background-color: #cc8800 !important;
  border-color: #cc8800 !important;
  color: #000 !important;
}

.btn-outline-primary {
  color: #ff7b00 !important;
  border-color: #ff7b00 !important;
}

.btn-outline-primary:hover {
  background-color: #ff7b00 !important;
  border-color: #ff7b00 !important;
  color: #000 !important;
}

.btn-outline-primary:focus, .btn-outline-primary.focus {
  box-shadow: 0 0 0 0.2rem rgba(255, 170, 0, 0.5) !important;
}

.btn-outline-primary:active, .btn-outline-primary.active {
  background-color: #ff7b00 !important;
  border-color: #ff7b00 !important;
  color: #000 !important;
}

/* Navigation improvements */
.navbar-nav .nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 0.375rem;
  transition: background-color 0.15s ease-in-out;
}

/* Responsive navigation */
@media (max-width: 768px) {
  .navbar-nav {
    flex-direction: column !important;
    gap: 0.5rem !important;
  }
  .navbar-nav .nav-link {
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
  }
  
  /* Mobile navigation bar improvements */
  .mobile-nav-header {
    width: 95vw !important;
    max-width: 95vw !important;
    padding: 0.75rem !important;
    margin: 0 auto;
  }
  
  .mobile-nav-header .d-flex {
    flex-direction: column !important;
    gap: 1rem !important;
    text-align: center;
  }
  
  .mobile-nav-header nav {
    justify-content: center !important;
    gap: 0.5rem !important;
  }
  
  .mobile-nav-header .btn-sm {
    font-size: 0.75rem !important;
    padding: 0.25rem 0.5rem !important;
  }
  
  /* Hide some less critical buttons on very small screens */
  @media (max-width: 480px) {
    .mobile-hide-xs {
      display: none !important;
    }
  }
}

/* Filter Sidebar */
.filter-sidebar {
  box-shadow: -2px 0 10px rgba(0,0,0,0.1);
}
.filter-sidebar.show {
  transform: translateX(0) !important;
}
.sidebar-overlay.show {
  opacity: 0.5 !important;
  visibility: visible !important;
}

/* Filter buttons active state */
.filter-btn-active {
  background-color: var(--bs-primary) !important;
  border-color: var(--bs-primary) !important;
  color: white !important;
}

/* Dark mode sidebar */
[data-bs-theme="dark"] .filter-sidebar {
  background-color: var(--bs-dark) !important;
  border-color: var(--bs-border-color) !important;
}

/* Recent thumbnails (card top) */
.card-img-container { 
  padding: 1rem 1rem 0;
  max-width: 200px;
  margin: 0 auto;
  width: 100%;
}
.ratio-square { 
  position: relative; 
  width: 100%;
  padding-bottom: 100%; /* Creates a square */
  background: var(--bs-secondary-bg);
  border-radius: .5rem; 
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--bs-border-color);
}
.ratio-square > img { 
  position: absolute; 
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: var(--bs-secondary-bg);
}

/* In-list card thumbs */
.thumb { width: 120px; height: 120px; border-radius: .5rem; overflow: hidden; background: #f8f9fa; display:flex; align-items:center; justify-content:center; }
.thumb > img { max-width: 100%; max-height: 100%; object-fit: cover; }

/* Image fallback style if load fails */
.img-failed { 
  background: var(--bs-secondary-bg) !important; 
  color: var(--bs-secondary-color); 
  position: relative; 
}
.img-failed::after { 
  content: "Image unavailable"; 
  font-size: .8rem; 
}

/* Modal: ~70% width on desktop, full on mobile */
.modal-dialog.viewer-70 { max-width: 70vw; }
@media (max-width: 768px){ 
  .modal-dialog.viewer-70 { 
    max-width: 100vw; 
    margin: 0; 
  }
  
  /* Fix modal content height on mobile */
  .modal-dialog.viewer-70 .modal-content {
    height: 100vh !important;
    border-radius: 0 !important;
  }
  
  /* Stack layout vertically on mobile and make the whole thing scroll */
  .modal-dialog.viewer-70 .modal-body {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 0 !important;
  }
  
  .modal-dialog.viewer-70 .modal-body .d-flex {
    flex-direction: column !important;
    height: auto !important;
    min-height: 100% !important;
  }
  
  /* Make image section responsive on mobile */
  .modal-dialog.viewer-70 .flex-shrink-0 {
    width: 100% !important;
    flex-shrink: 0 !important;
    padding: 1rem !important;
  }
  
  /* Adjust image container height on mobile - much smaller */
  .modal-dialog.viewer-70 .flex-shrink-0 > div {
    height: 150px !important;
  }
  
  /* Make content section not have its own scroll */
  .modal-dialog.viewer-70 .flex-grow-1 {
    flex: 1 !important;
    overflow: visible !important;
    padding: 1rem !important;
    max-height: none !important;
  }
  
  /* Fix for mobile Safari viewport height issues */
  @supports (-webkit-touch-callout: none) {
    .modal-dialog.viewer-70 .modal-content {
      height: 100svh !important;
    }
  }
}

/* Prevent body scrolling when modal is open */
body.modal-open {
  overflow: hidden !important;
}

/* Toggle active look */
#btnViewCards.active, #btnViewList.active { color:#fff; background:#6c757d; border-color:#6c757d; }

/* Force min width to help with text truncation */
.min-w-0 { min-width: 0; }

/* Image button styling */
.btn-img {
  background: none;
  transition: opacity 0.15s ease-in-out;
  cursor: pointer;
}
.btn-img:hover {
  opacity: 0.9;
}
.btn-img:active {
  opacity: 0.8;
}

/* Ensure badges wrap properly */
.text-wrap .badge { display: inline-block; }

/* Filter badges styling */
#tagFilterOptions .badge,
#ageFilterOptions .badge {
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

#tagFilterOptions .badge:hover,
#ageFilterOptions .badge:hover {
  opacity: 1;
}

#tagFilterOptions .badge.active,
#ageFilterOptions .badge.active {
  opacity: 1;
  position: relative;
}

.btn-close-white {
  font-size: 0.6em;
  padding: 0.25em;
}

#activeFilters .badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

