/* Library Page Styles - Matching Course Catalog Design */

/* ============================================================================
   FEATURED CARD - Fixed Aspect Ratio to Prevent Image Stretching
   ============================================================================ */

/* Wrapper maintains aspect ratio */
.featured-card-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* Featured card with fixed 16:9 aspect ratio - matches the podcast image */
.featured-card {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 180px;
  max-height: 280px; /* Prevent getting too tall on desktop */
}

/* Fallback for browsers that don't support aspect-ratio */
@supports not (aspect-ratio: 16 / 9) {
  .featured-card {
    padding-top: 56.25%; /* 9/16 = 56.25% for 16:9 ratio */
    height: 0;
  }
  
  .featured-card > * {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }
}

/* Large desktop: slightly taller max */
@media (min-width: 1200px) {
  .featured-card {
    max-height: 320px;
  }
}

/* Medium desktop */
@media (min-width: 768px) and (max-width: 1199px) {
  .featured-card {
    max-height: 260px;
  }
}

/* Mobile: Enforce 16:9 aspect ratio with smaller size */
@media (max-width: 767px) {
  .featured-card {
    aspect-ratio: 16 / 9;
    height: auto !important;
    min-height: 160px;
    max-height: 220px;
  }
  
  /* Hide the description text on mobile - hard to read */
  .featured-card .card-body p {
    display: none !important;
  }
  
  /* Show the button on mobile - make it visible immediately */
  #featured-btn-wrapper {
    opacity: 1 !important;
    transform: none !important;
    margin-top: 0.5rem !important;
  }
  
  /* Featured card link styling */
  .featured-card-link {
    display: block;
    height: 100%;
  }
  
  .featured-card-link:hover {
    text-decoration: none;
  }
}

/* Overall Layout */
.content-wrapper {
  background-color: #f8f9fa;
  min-height: calc(100vh - 60px);
}

/* Library Grid Container */
.library-grid-container {
  max-width: 100%;
  padding: 0 20px; /* Added padding for margins from edges */
  width: 100%;
}

/* Center cards when they hit max width */
.library-cards-container {
  justify-content: center;
}

/* Library Card Link */
.library-card-link {
  text-decoration: none;
  color: inherit;
  display: block;
  height: 100%;
}

.library-card-link:hover {
  text-decoration: none;
  color: inherit;
}

/* Library Card */
.library-card {
  background: #ffffff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); /* Darker shadow */
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 400px; /* Max width for grid view cards */
  margin: 0 auto; /* Center cards within their grid column */
  /* Performance optimizations for smooth scrolling */
  contain: layout style paint;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Only apply hover effects on devices that support hover (not touch) */
@media (hover: hover) and (pointer: fine) {
  .library-card-link:hover .library-card {
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); /* Darker shadow on hover */
  }
}

/* Library Image */
.library-image-container {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 Aspect Ratio */
  overflow: hidden;
  background-color: #f8f9fa;
  /* Prevent layout shifts */
  contain: strict;
}

.library-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain; /* Shows full image, no cropping */
  object-position: center;
}

/* Library Card Body */
.library-card-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

/* Library Title */
.library-title {
  font-family: "Roboto", sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: #1a1a1a;
  margin: 0 0 0.75rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex-shrink: 0;
}

/* Library Subtitle */
.library-subtitle {
  font-family: "Roboto", sans-serif;
  font-size: 0.9rem;
  font-weight: 400;
  color: #495057; /* Darker gray for better contrast (7:1 ratio) */
  line-height: 1.6;
  margin-bottom: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex-grow: 1;
}

/* Library Button Container */
.library-button-container {
  margin-top: auto;
  width: 100%;
}

/* Library Button */
.library-button {
  display: inline-block;
  width: auto; /* Changed from 100% to auto for better sizing */
  padding: 0.75rem 1.5rem;
  background-color: #8A6642; /* Slightly darker medium bronze */
  color: #ffffff;
  text-align: center;
  font-family: "Roboto", sans-serif;
  font-size: 1rem;
  font-weight: 500;
  border-radius: 4px;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
  .library-card-link:hover .library-button {
    background-color: #a67d5a; /* Slightly darker on hover */
    transform: scale(1.02);
  }
}

/* Grid view buttons should be full width */
.library-cards-container[data-view="grid"] .library-button {
  width: 100%;
}

/* Back to Library navigation */
.back-to-library-container {
  margin-bottom: 20px;
  margin-left: 30px;
}

/* Selected Item Card (single card view) */
.selected-item-card {
  max-width: 600px;
}

.selected-item-card .image-container {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 ratio */
  overflow: hidden;
  background: #f5f5f5;
  border-bottom: 1px solid #ddd;
}

.selected-item-card .image-container img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain; /* No cropping for single item view */
  object-position: center;
}

/* Ensure proper spacing and alignment */
.library-grid-container .row {
  margin-left: -12px; /* Smaller margins between cards */
  margin-right: -12px; /* Smaller margins between cards */
}

.library-grid-container .col-xl-3,
.library-grid-container .col-lg-4,
.library-grid-container .col-md-6,
.library-grid-container .col-sm-12 {
  padding-left: 12px; /* Smaller margins between cards */
  padding-right: 12px; /* Smaller margins between cards */
}

/* Scroll to Top Button */
#scrollTopBtn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 99;
  border: none;
  outline: none;
  background-color: #BD926F;
  color: #FFFFFF;
  cursor: pointer;
  width: 50px;
  height: 50px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(189, 146, 111, 0.4);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

#scrollTopBtn:hover {
  background-color: #FACE68;
  color: #474544;
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(250, 206, 104, 0.5);
}

/* Filters Section */
.filters-container {
  max-width: 100%;
  padding: 1rem;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.filter-label {
  font-family: "Roboto", sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  color: #495057;
  margin-bottom: 0;
  white-space: nowrap;
}

/* View Toggle Buttons */
.view-toggle-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-view-toggle {
  background: #ffffff;
  border: 1px solid #ced4da;
  color: #495057;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  font-size: 1rem;
}

.btn-view-toggle:hover {
  background: #e9ecef;
  border-color: #adb5bd;
}

.btn-view-toggle.active {
  background: rgb(189, 146, 111); /* Updated to requested color */
  border-color: rgb(189, 146, 111);
  color: #ffffff;
}

.btn-view-toggle i {
  pointer-events: none;
}

/* List View Styles */
.library-card-list {
  display: flex;
  flex-direction: row;
  height: auto;
  max-width: 1200px; /* Max width for list view cards */
  margin: 0 auto; /* Center the card */
}

/* List view specific item wrapper for margins */
.library-cards-container[data-view="list"] .library-item {
  padding-left: 20px; /* Add left margin */
  padding-right: 20px; /* Add right margin */
}

.library-card-list .library-image-container {
  width: 300px;
  min-width: 300px;
  padding-top: 0;
  height: 200px;
  flex-shrink: 0;
}

.library-card-list .library-image {
  position: relative;
  object-fit: contain; /* Shows full image in list view too */
}

.library-card-list .library-card-body {
  padding: 1.5rem;
  flex: 1;
}

.library-card-list .library-title {
  font-size: 1.5rem;
}

.library-card-list .library-subtitle {
  display: block;
  -webkit-line-clamp: unset;
}

/* Responsive Adjustments */
@media (max-width: 991px) {
  .library-card-body {
    padding: 1.25rem;
  }

  .library-card-list .library-image-container {
    width: 250px;
    min-width: 250px;
    height: 150px;
  }
}

@media (max-width: 767px) {
  /* MOBILE: Add padding to body for fixed navbar */
  body {
    padding-top: 45px !important; /* Reduced much more - was 85px */
  }

  .library-card-body {
    padding: 1rem;
  }
  
  .library-title {
    font-size: 1.125rem;
  }
  
  #scrollTopBtn {
    bottom: 20px;
    right: 20px;
    padding: 10px 14px;
  }

  /* MOBILE: Adjust content wrapper spacing */
  /* (Already handled above with content-wrapper) */

  /* MOBILE: Compact page header */
  .content-wrapper h1 {
    font-size: 1.5rem !important; /* Much smaller - was default ~2.5rem */
    margin-bottom: 0.25rem !important;
    line-height: 1.2;
  }
  
  .content-wrapper h3 {
    font-size: 1rem !important; /* Smaller - was default ~1.75rem */
    margin-bottom: 0.25rem !important;
    font-weight: 500;
    line-height: 1.3;
  }
  
  .content-wrapper p {
    font-size: 0.875rem !important; /* Smaller */
    margin-bottom: 0.75rem !important;
    color: #495057; /* Darker gray for better contrast */
  }

  /* MOBILE: Compact filters section */
  .filters-container {
    padding: 0.5rem !important; /* Less padding */
    margin-bottom: 0.75rem !important;
  }

  /* MOBILE: Sticky navbar that stays at top when scrolling */
  .navbar,
  .main-header {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: fixed !important; /* Fixed to top */
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1050 !important;
    width: 100% !important;
    background-color: #333 !important; /* Dark background */
    padding: 1rem 1rem !important; /* More padding - was 0.5rem */
    min-height: 70px !important; /* Taller navbar */
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important; /* Shadow when scrolling */
  }

  /* Push ALL page content down - target the wrapper, not just content-wrapper */
  .wrapper {
    padding-top: 85px !important; /* 70px navbar + 15px breathing room */
  }
  
  .content-wrapper {
    padding-top: 1rem !important; /* Just normal padding, not 85px */
    margin-top: 0 !important;
  }

  .navbar .navbar-brand {
    display: flex !important;
    max-width: 60% !important;
  }

  .navbar .navbar-brand img {
    /* Reserve the logo box before the file arrives. width:auto left the
       image 0px tall until it loaded (the header then grew by 45px). A
       definite width plus the dark logo's own ratio (1006x266) is the
       same 170x45 box the loaded image ends up in; max-width lets it
       shrink in a narrow bar with the height following the ratio. */
    width: 170px !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 45px !important;
    aspect-ratio: 1006 / 266;
    object-fit: contain;
    content: url('/localized/zh/images/THF-Dark-Logo.webp') !important; /* Dark logo for mobile - absolute path for purged bundle */
  }

  /* MOBILE: Make sure hamburger menu is visible */
  .navbar-toggler {
    display: inline-block !important;
    visibility: visible !important;
    border: 2px solid #fff;
    padding: 0.5rem 0.75rem;
    font-size: 1.25rem;
    background-color: rgb(189, 146, 111) !important; /* THF button color */
    color: #fff;
    cursor: pointer;
    margin-left: auto !important;
    flex-shrink: 0;
    z-index: 9999;
  }

  .navbar-toggler:focus,
  .navbar-toggler:active {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(255,255,255,.5);
    background-color: rgba(0,0,0,0.7);
  }

  .navbar-toggler i,
  .navbar-toggler .fa-bars {
    color: #fff !important;
    font-size: 1.5rem;
    display: block !important;
  }

  /* MOBILE: Style the collapsed menu */
  .navbar-collapse {
    background-color: #fff !important; /* White background for menu */
    padding: 1rem;
    margin-top: 0.5rem;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    max-height: calc(100vh - 70px) !important; /* Don't overflow screen */
    overflow-y: auto !important; /* Scroll if menu is too long */
  }

  .navbar-collapse.show {
    display: block !important;
  }

  .navbar-collapse .navbar-nav {
    padding: 0.5rem 0;
  }

  .navbar-collapse .nav-item {
    display: block !important;
  }

  .navbar-collapse .nav-link {
    color: #333 !important; /* Dark text on white background */
    padding: 0.75rem 1rem !important;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    display: block !important;
    font-size: 1rem !important;
    font-weight: 500 !important;
  }

  .navbar-collapse .nav-link:hover {
    background-color: rgb(189, 146, 111) !important; /* THF color on hover */
    color: #fff !important;
  }

  .navbar-collapse .dropdown-menu {
    background-color: #f8f9fa !important;
    border: none !important;
    padding: 0.5rem 0 !important;
  }

  .navbar-collapse .dropdown-item {
    color: #333 !important;
    padding: 0.5rem 1.5rem !important;
  }

  .navbar-collapse .dropdown-item:hover {
    background-color: rgb(189, 146, 111) !important;
    color: #fff !important;
  }

  /* MOBILE: Force all buttons to be full width for consistency */
  .library-button {
    width: 100% !important;
    display: block;
  }

  /* MOBILE: Image ON TOP for GRID view only */
  .library-card {
    flex-direction: column !important; /* Image on top, text below */
  }
  
  /* MOBILE LIST VIEW: Compact horizontal row layout */
  .library-card-list {
    flex-direction: row !important; /* Horizontal: image | title */
    align-items: center;
    padding: 0.5rem;
    gap: 0.75rem;
    border: 2px solid rgb(189, 146, 111) !important; /* Button color border */
    cursor: pointer;
  }
  
  /* Small image on the left */
  .library-card-list .library-image-container {
    width: 100px !important;
    min-width: 100px !important;
    height: 56px !important; /* 16:9 ratio (100/16*9) */
    padding-top: 0 !important;
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
  }
  
  .library-card-list .library-image {
    position: relative;
    width: 100%;
    height: 100%;
    object-fit: cover; /* Fill the small thumbnail */
  }
  
  /* Title takes up remaining space */
  .library-card-list .library-card-body {
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
  }
  
  .library-card-list .library-title {
    font-size: 0.875rem; /* Smaller text - was 1rem */
    margin: 0;
    line-height: 1.3;
    -webkit-line-clamp: 3; /* Allow up to 3 lines */
    font-weight: 500;
  }
  
  /* Hide subtitle and button in mobile list view */
  .library-card-list .library-subtitle {
    display: none !important;
  }
  
  .library-card-list .library-button-container {
    display: none !important; /* Remove button completely */
  }
}

/* ============================================================================
   DASHBOARD + FEATURED CARDS - Side-by-side Equal Height Layout
   ============================================================================ */

/* Desktop: Force side-by-side layout with equal heights */
@media (min-width: 768px) {
  /* Make the row a flexbox for side-by-side equal height columns */
  .top-cards-row {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 1.5rem;
  }
  
  .top-cards-row > .col-md-6 {
    display: flex !important;
    flex: 1 1 50% !important;
    max-width: 50% !important;
    padding: 0 !important;
    margin-bottom: 0 !important;
  }
  
  /* Dashboard card wrapper - make it fill available height */
  .dashboard-card-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
  }
  
  /* Dashboard card - fixed height matching featured card */
  .dashboard-card-wrapper .card {
    flex: 1;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  
  /* Featured card link/wrapper must stretch so .featured-card can fill the column height */
  .top-cards-row .featured-card-link {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
  }

  /* Featured card wrapper */
  .featured-card-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    flex: 1;
  }
  
  /* Featured card - match dashboard card height */
  .top-cards-row .featured-card {
    flex: 1;
    min-height: 280px;
    height: 100% !important;
    aspect-ratio: unset !important;
    max-height: none !important;
  }
  
  /* Desktop: Larger profile elements */
  .profile-image-large {
    width: 160px !important;
    height: 160px !important;
  }
  
  .profile-placeholder-large {
    width: 160px !important;
    height: 160px !important;
  }
  
  .profile-placeholder-large i {
    font-size: 5rem !important;
  }
  
  .welcome-title-large {
    font-size: 2rem !important;
    font-weight: 600;
  }
  
  .points-display-large {
    padding: 1rem 1.5rem !important;
    font-size: 1.2rem;
  }
  
  .points-display-large .points-value {
    font-size: 1.75rem !important;
  }
  
  .points-display-large i {
    font-size: 1.5rem;
  }
  
  .guest-welcome h4 {
    font-size: 2.5rem !important;
    font-family: 'Playfair Display', Georgia, serif;
    margin-bottom: 1rem;
  }
  
  .guest-welcome p {
    font-size: 1.25rem !important;
  }
  
  .guest-welcome a {
    font-weight: 600;
    color: #BD926F;
  }
  
  .guest-welcome a:hover {
    color: #a17a5c;
    text-decoration: underline;
  }
}

/* Large desktop - even larger */
@media (min-width: 1200px) {
  .dashboard-card-wrapper .card,
  .top-cards-row .featured-card {
    min-height: 320px;
  }
  
  .profile-image-large {
    width: 180px !important;
    height: 180px !important;
  }
  
  .profile-placeholder-large {
    width: 180px !important;
    height: 180px !important;
  }
  
  .profile-placeholder-large i {
    font-size: 6rem !important;
  }
  
  .welcome-title-large {
    font-size: 2.25rem !important;
  }
  
  .points-display-large .points-value {
    font-size: 2rem !important;
  }
  
  .guest-welcome h4 {
    font-size: 3rem !important;
  }
  
  .guest-welcome p {
    font-size: 1.35rem !important;
  }
}

/* Mobile: Dashboard card adjustments */
@media (max-width: 767px) {
  /* Profile image on mobile */
  .profile-image-large {
    width: 100px !important;
    height: 100px !important;
  }
  
  .profile-placeholder-large {
    width: 100px !important;
    height: 100px !important;
  }
  
  .profile-placeholder-large i {
    font-size: 2.75rem !important;
  }
  
  /* Welcome text on mobile - high specificity */
  h3.welcome-title-large,
  .dashboard-card-wrapper .welcome-title-large {
    font-size: 1.3rem !important;
    font-weight: 600 !important;
    margin-bottom: 0.5rem !important;
    line-height: 1.2 !important;
  }
  
  /* Points display on mobile */
  .points-display-large {
    padding: 0.5rem 0.9rem !important;
  }
  
  .points-display-large .points-value {
    font-size: 1.15rem !important;
  }
  
  .points-display-large i {
    font-size: 1rem;
  }
  
  /* Add more top padding to dashboard card to make room for label */
  .dashboard-card-wrapper .card-body {
    padding-top: 2.5rem !important;
  }
  
  /* Guest welcome on mobile */
  .guest-welcome h4 {
    font-size: 1.85rem !important;
  }
  
  .guest-welcome p {
    font-size: 1.1rem !important;
  }
}

/* ============================================================================
   SECTION HEADER DIVIDER - Performance Optimized
   ============================================================================ */

.section-header-divider {
  background: linear-gradient(135deg, #f8f4f0 0%, #ede5db 100%);
  border-radius: 12px;
  border: 2px solid #d4c4b0;
  /* Performance optimizations */
  contain: layout style paint;
  will-change: auto;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.section-header-divider h2 {
  font-family: 'Playfair Display', Georgia, serif;
  color: #5a4a3a;
  font-size: 2rem;
  margin: 0;
  letter-spacing: 2px;
}

@media (max-width: 767px) {
  .section-header-divider h2 {
    font-size: 1.5rem;
    letter-spacing: 1px;
  }
}

/* ============================================================================
   WORK CARD PROGRESS BAR - Shows listening progress on work cards
   ============================================================================ */

/* Progress bar container - sits at the bottom of the card image */
.library-card-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: rgba(0, 0, 0, 0.3);
  overflow: hidden;
  z-index: 10;
}

/* Progress bar fill */
.library-card-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #BD926F 0%, #d4a574 100%);
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 0 3px 3px 0;
}

/* Image container relative positioning for progress bar */
.library-image-container {
  position: relative;
}

/* Completed indicator (checkmark) */
.library-card-progress.completed .library-card-progress-bar {
  background: linear-gradient(90deg, #4a6741 0%, #5c8055 100%);
  width: 100%;
}

/* ============================================================================
   LAST LISTENED GLOW EFFECT - Blue glow on the card you last listened to
   ============================================================================ */

/* Last listened card - pulsing blue glow */
.library-card.last-listened {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5),
              0 0 20px rgba(59, 130, 246, 0.4),
              0 4px 12px rgba(0, 0, 0, 0.2);
  animation: lastListenedPulse 2s ease-in-out infinite;
}

@keyframes lastListenedPulse {
  0%, 100% {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5),
                0 0 20px rgba(59, 130, 246, 0.4),
                0 4px 12px rgba(0, 0, 0, 0.2);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.7),
                0 0 30px rgba(59, 130, 246, 0.5),
                0 6px 16px rgba(0, 0, 0, 0.25);
  }
}

/* Last listened badge */
.last-listened-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 15;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
  display: flex;
  align-items: center;
  gap: 4px;
}

.last-listened-badge i {
  font-size: 0.65rem;
}

/* Progress percentage text - always visible */
.library-card-progress-text {
  position: absolute;
  bottom: 12px;
  right: 10px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  z-index: 12;
}

/* List view adjustments */
.library-card-list .library-card-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.library-card-list .last-listened-badge {
  position: absolute;
  top: 8px;
  right: auto;
  left: 8px;
  font-size: 0.6rem;
  padding: 3px 8px;
}

/* Mobile adjustments */
@media (max-width: 767px) {
  .library-card-progress {
    height: 4px;
  }
  
  .last-listened-badge {
    font-size: 0.6rem;
    padding: 3px 8px;
    top: 8px;
    right: 8px;
  }
  
  .library-card-progress-text {
    display: none;
  }
}

/* ============================================================================
   APP VIEW - iOS-style App Icons Layout
   ============================================================================ */

/* iOS App Grid - 3 columns mobile, bigger icons with shadows */
.ios-app-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem 0;
  padding: 0 0.25rem;
  justify-items: center;
  width: calc(100% + 2rem);
  margin-left: -1rem;
  max-width: none;
}

/* iOS App Item (wrapper for drag) */
.ios-app-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.ios-app-item.dragging {
  opacity: 0.5;
  transform: scale(1.1);
}

/* iOS App Link */
.ios-app-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.ios-app-link:hover {
  text-decoration: none;
  color: inherit;
}

/* iOS App Icon (the square image) - bigger size with shadow for contrast */
.ios-app-icon {
  width: 85px;
  height: 85px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.32), 0 0 0 0.5px rgba(0, 0, 0, 0.15);
  background: #ffffff;
  position: relative;
}

.ios-app-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #f8f9fa;
}

/* Coming Soon / Partner Badge */
.ios-app-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.85);
  color: #BD926F;
  font-size: 0.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  text-align: center;
  padding: 2px 0;
}

.ios-app-disabled {
  opacity: 0.6;
}

/* iOS App Label - allow 2 lines, don't truncate aggressively */
.ios-app-label {
  margin-top: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: #1a1a1a;
  text-align: center;
  max-width: 95px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

/* Section headers in apps view - clear visual separation */
.ios-app-section-header {
  grid-column: 1 / -1;
  text-align: center;
  padding: 1.5rem 1rem 1rem;
  margin-top: 0.5rem;
  border-top: 1px solid #e8e4de;
}

.ios-app-section-header:first-child {
  margin-top: 0;
  padding-top: 0.5rem;
  border-top: none;
}

.ios-app-section-header h2 {
  font-family: 'Playfair Display', Georgia, serif;
  color: #1a2a3a;
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.5px;
}

/* Delete Button (hidden by default) */
.ios-app-delete-btn {
  display: none;
  position: absolute;
  top: -6px;
  left: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid #fff;
  color: #fff;
  font-size: 10px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.ios-app-delete-btn:hover {
  background: #dc3545;
}

/* Edit Mode (jiggle animation) */
.ios-app-grid.edit-mode .ios-app-item {
  animation: jiggle 0.15s ease-in-out infinite alternate;
}

.ios-app-grid.edit-mode .ios-app-item:nth-child(even) {
  animation-delay: 0.075s;
}

.ios-app-grid.edit-mode .ios-app-delete-btn {
  display: flex;
}

@keyframes jiggle {
  0% { transform: rotate(-1deg); }
  100% { transform: rotate(1deg); }
}

/* Add Apps Container */
.ios-add-apps-container {
  display: flex;
  justify-content: center;
  padding: 1rem 0;
  margin-top: 0.5rem;
}

.ios-add-apps-btn {
  background: #BD926F;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 0.5rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.2s ease;
}

.ios-add-apps-btn:hover {
  background: #a67d5a;
}

/* Add Apps Modal */
.ios-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  justify-content: center;
  align-items: center;
}

.ios-modal-overlay.show {
  display: flex;
}

.ios-modal-box {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  max-width: 320px;
  width: 90%;
  overflow: hidden;
}

.ios-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e8e4de;
}

.ios-modal-header h5 {
  margin: 0;
  font-weight: 600;
  font-size: 1rem;
}

.ios-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #6c757d;
  cursor: pointer;
  line-height: 1;
}

.ios-modal-body {
  padding: 1rem 1.25rem;
  max-height: 300px;
  overflow-y: auto;
}

.ios-add-apps-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ios-add-app-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #f8f9fa;
  border: 1px solid #e8e4de;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #1a1a1a;
  cursor: pointer;
  transition: background 0.2s ease;
}

.ios-add-app-item:hover {
  background: #e9ecef;
}

.ios-add-app-item i {
  color: #BD926F;
}

/* ============================================================================
   APP VIEW - Responsive Adjustments (matching dashboard)
   ============================================================================ */

/* Large Desktop - 4 columns, bigger icons */
@media (min-width: 992px) {
  .ios-app-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem 1.5rem;
    padding: 1rem 2rem;
    width: 100%;
    margin-left: 0;
    max-width: none;
  }
  
  .ios-app-icon {
    width: 90px;
    height: 90px;
    border-radius: 20px;
  }
  
  .ios-app-label {
    font-size: 12px;
    max-width: 110px;
  }
  
  .ios-app-section-header h2 {
    font-size: 1.2rem;
  }
}

/* Tablet - 3 columns */
@media (min-width: 768px) and (max-width: 991px) {
  .ios-app-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.75rem 1rem;
    padding: 0.75rem 1.5rem;
    width: 100%;
    margin-left: 0;
    max-width: none;
  }
  
  .ios-app-icon {
    width: 85px;
    height: 85px;
    border-radius: 18px;
  }
  
  .ios-app-label {
    font-size: 11px;
    max-width: 100px;
  }
}

/* Mobile (default) - 3 columns, bigger icons, close to edges */
@media (max-width: 767px) {
  .ios-app-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem 0.5rem;
    padding: 0 0.5rem;
    width: 100%;
    margin-left: 0;
    max-width: none;
  }
  
  .ios-app-icon {
    width: 85px;
    height: 85px;
    border-radius: 18px;
  }
  
  .ios-app-label {
    font-size: 11px;
    margin-top: 6px;
    max-width: 95px;
  }
  
  .ios-app-section-header {
    padding: 1rem 0.5rem 0.75rem;
  }
  
  .ios-app-section-header h2 {
    font-size: 1rem;
  }
  
  .ios-app-delete-btn {
    width: 22px;
    height: 22px;
    font-size: 10px;
    top: -6px;
    left: -6px;
  }
}

/* Very Small Mobile - still 3 columns but tighter */
@media (max-width: 360px) {
  .ios-app-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem 0.25rem;
  }
  
  .ios-app-icon {
    width: 75px;
    height: 75px;
    border-radius: 16px;
  }
  
  .ios-app-label {
    font-size: 9px;
    max-width: 58px;
  }
}

/* ============================================================================
   DARK MODE: Library / ANF cards and reader-adjacent lists
   ========================================================================== */
html[data-theme="dark"] #main-content.content-wrapper {
  background-color: var(--thf-bg);
  color: var(--thf-text);
}

html[data-theme="dark"] #main-content.content-wrapper.text-navy,
html[data-theme="dark"] #main-content.content-wrapper h1,
html[data-theme="dark"] #main-content.content-wrapper h2,
html[data-theme="dark"] #main-content.content-wrapper h3,
html[data-theme="dark"] #main-content.content-wrapper h4,
html[data-theme="dark"] #main-content.content-wrapper h5,
html[data-theme="dark"] #main-content.content-wrapper .text-dark {
  color: var(--thf-heading) !important;
}

html[data-theme="dark"] .library-card,
html[data-theme="dark"] .selected-item-card,
html[data-theme="dark"] .selected-volume-card,
html[data-theme="dark"] .section-header-divider {
  background: var(--thf-surface);
  border-color: var(--thf-border);
  box-shadow: 0 4px 12px var(--thf-shadow);
  color: var(--thf-text);
}

html[data-theme="dark"] .library-card-link,
html[data-theme="dark"] .library-card-link:hover {
  color: var(--thf-text);
}

html[data-theme="dark"] .library-image-container,
html[data-theme="dark"] .ios-app-icon,
html[data-theme="dark"] .ios-app-icon img {
  background-color: var(--thf-surface-2);
}

html[data-theme="dark"] .library-card-body,
html[data-theme="dark"] .library-title,
html[data-theme="dark"] .section-header-divider h2,
html[data-theme="dark"] .ios-app-section-header h2 {
  color: var(--thf-heading);
}

html[data-theme="dark"] .library-subtitle,
html[data-theme="dark"] .filter-label,
html[data-theme="dark"] .ios-app-label {
  color: var(--thf-text-2);
}

html[data-theme="dark"] .btn-view-toggle {
  background: var(--thf-surface);
  border-color: var(--thf-border);
  color: var(--thf-text);
}

html[data-theme="dark"] .btn-view-toggle.active,
html[data-theme="dark"] .btn-view-toggle:hover {
  background: var(--thf-accent);
  border-color: var(--thf-accent);
  color: var(--thf-bg);
}

html[data-theme="dark"] .library-button,
html[data-theme="dark"] .ios-add-apps-btn {
  background-color: var(--thf-accent);
  color: var(--thf-bg);
}

html[data-theme="dark"] .library-card-progress {
  background: var(--thf-surface-3);
}

html[data-theme="dark"] .library-card-progress-bar {
  background: var(--thf-accent);
}

html[data-theme="dark"] .library-card-progress.completed .library-card-progress-bar {
  background: var(--thf-accent-2);
}

html[data-theme="dark"] .library-card-progress-text,
html[data-theme="dark"] .last-listened-badge,
html[data-theme="dark"] .ios-app-badge {
  background: var(--thf-surface-3);
  color: var(--thf-heading);
}

html[data-theme="dark"] .ios-app-section-header,
html[data-theme="dark"] .ios-modal-header,
html[data-theme="dark"] .ios-add-app-item {
  border-color: var(--thf-border);
}

html[data-theme="dark"] .ios-modal-box,
html[data-theme="dark"] .ios-add-app-item {
  background: var(--thf-surface);
  color: var(--thf-text);
}

html[data-theme="dark"] .ios-add-app-item:hover {
  background: var(--thf-surface-2);
}
