/* ========================================
   CHARACTER CARDS & GALLERY STYLES
   Mobile-First Responsive Design
   Following DESIGN_THEME_DOCUMENTATION.md
   ======================================== */

/* Gallery card - Professional glassmorphic design */
.gallery-card {
  animation: galleryFadeIn 0.7s cubic-bezier(0.23, 1, 0.32, 1);
  transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
  height: 100%;
  max-height: 400px;
}

.gallery-card .card {
  border-radius: var(--radius-sm);
  border: 1px solid rgba(130, 64, 255, 0.1);
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.card.gallery-hover {
  transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
  background: var(--glass-bg, rgba(45, 45, 45, 0.95));
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border, rgba(130, 64, 255, 0.2));
}

.card.gallery-hover:hover {
  box-shadow: 0 12px 30px rgba(110, 32, 244, 0.15);
  z-index: 2;
}

/* Image wrapper with aspect ratio */
.gallery-image-wrapper {
  position: relative;
  aspect-ratio: 4/5;
  background: linear-gradient(135deg, var(--bg-secondary, #2d2d2d) 0%, var(--bg-tertiary, #3d3d3d) 100%);
  overflow: hidden;
  transition: background-size 0.3s ease, background-position 0.3s ease;
}

/* Primary and secondary images */
.gallery-img-primary,
.gallery-img-secondary {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-img-secondary {
  opacity: 0;
  z-index: 2;
  transition: opacity 0.45s ease;
}

.gallery-img-primary {
  z-index: 1;
  opacity: 1;
  transition: opacity 0.45s ease;
}

.gallery-img {
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), 
              filter 0.4s ease, 
              opacity 0.45s ease;
  will-change: transform, opacity;
}

.card.gallery-hover:hover .gallery-img {
  filter: brightness(1.08) saturate(1.1);
}

.card.gallery-hover:hover .gallery-img-secondary {
  opacity: 1;
}

.card.gallery-hover:hover .gallery-img-primary {
  opacity: 0;
}

/* Gradient overlay for text readability */
.gallery-image-wrapper::after {
  content: '';
  display: block;
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: linear-gradient(to top, 
    rgba(0, 0, 0, 0.8) 0%, 
    rgba(0, 0, 0, 0.4) 50%, 
    transparent 100%);
  z-index: 1;
}

/* Content positioning at bottom of image */
.gallery-image-wrapper .position-absolute {
  z-index: 2;
}

/* Character card content */
.gallery-card .card-body {
  flex-grow: 1;
  display: none;
  padding: 0.75rem;
  border-top: 1px solid rgba(130, 64, 255, 0.1);
}

.gallery-card .admin .card-body {
  display: flex;
}

/* Tag badges styling - Flexbox for wrapping */
.gallery-card .badge {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 0.6rem; /* Slightly smaller font */
  padding: 0.2rem 0.4rem; /* Compact padding */
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.2s ease;
  border-radius: var(--radius-xs, 4px); /* Softer radius */
  color: rgba(255,255,255,0.85);
  background: rgba(255, 255, 255, 0.1);
}

.gallery-card .badge:hover {
  background: rgba(130, 64, 255, 0.4) !important;
  border-color: rgba(130, 64, 255, 0.7) !important;
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(130, 64, 255, 0.2);
}

/* Tag container with flexbox for wrapping */
.gallery-card .tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.5rem;
  overflow: hidden; /* No scrollbars */
}

/* Character name - Smaller for full display */
.gallery-card .card-title {
  font-size: 0.95rem;
  font-weight: 300;
  line-height: 1.2;
  margin-bottom: 0.4rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  display: -webkit-box;
  overflow: hidden;
}

/* First message text - Compact */
.gallery-card .text-white-50 {
  font-size: 0.7rem;
  line-height: 1.3;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

/* Badges positioning */
.gallery-card .position-absolute.top-0 {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-end;
}

.gallery-card .top-0 .badge {
  font-size: 0.65rem;
  padding: 0.35rem 0.6rem;
  border-radius: 12px;
}

/* Admin controls */
.gallery-card .btn-sm {
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  border-radius: 6px;
}

/* Loading overlay */
.loading-overlay {
  border-radius: var(--radius-sm);
}

/* Animations */
@keyframes galleryFadeIn {
  from { 
    opacity: 0; 
    transform: translateY(20px);
  }
  to { 
    opacity: 1; 
    transform: translateY(0);
  }
}

/* ========================================
   RESPONSIVE BREAKPOINTS
   ======================================== */

/* Mobile - Small devices (320px - 480px) */
@media (max-width: 480px) {
  .gallery-card .card-title {
    font-size: 0.85rem;
  }

  .gallery-card .text-white-50 {
    font-size: 0.65rem;
  }

  .card.gallery-hover:hover {
    transform: none;
    box-shadow: 0 4px 12px rgba(110, 32, 244, 0.12);
  }

  .card.gallery-hover:hover .gallery-img {
    transform: none;
  }
}

/* Mobile - Medium devices (481px - 600px) */
@media (min-width: 481px) and (max-width: 600px) {
  .gallery-card .card-title {
    font-size: 0.9rem;
  }
}

/* Tablet - Portrait (601px - 768px) */
@media (min-width: 601px) and (max-width: 768px) {
  .gallery-card .card-title {
    font-size: 0.95rem;
  }
}

/* Tablet & Desktop (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .gallery-card .card-title {
    font-size: 1rem;
  }
}

/* Desktop - Large screens (1025px+) */
@media (min-width: 1025px) {

  .gallery-card .card-title {
    font-size: 1rem;
  }

  .card.gallery-hover:hover {
    box-shadow: 0 15px 30px rgba(110, 32, 244, 0.2);
  }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

/* Transition helpers */
.transition {
  transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

/* Premium/Special badge styles */
.popular-badge {
  background: linear-gradient(45deg, #FF5E7E, #FF8C40);
  transform: rotate(3deg);
  box-shadow: 0 4px 12px rgba(255, 94, 126, 0.35);
  border: none !important;
}

/* NSFW content handling */
.nsfw-badge-container {
  background: linear-gradient(to right, red, #ff4d4d, #f99);
  opacity: 0.5;
}

/* ========================================
   ADMIN CONTROLS
   ======================================== */

.gallery-card .card-body.admin {
  display: flex;
  justify-content: between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
}

.gallery-card .btn.persona {
  flex-shrink: 0;
}

.gallery-card .chat-nsfw-toggle {
  flex-shrink: 0;
}

.gallery-card .btn-danger {
  flex-shrink: 0;
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  .gallery-card,
  .card.gallery-hover,
  .gallery-img,
  .badge {
    animation: none !important;
    transition: none !important;
  }

  .gallery-card:hover {
    transform: none !important;
  }
}

/* Focus visible states for keyboard navigation */
.gallery-card:focus-within {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.gallery-card .badge:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 1px;
}

.gallery-card .btn:focus {
  box-shadow: 0 0 0 3px rgba(130, 64, 255, 0.25);
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  .gallery-card {
    page-break-inside: avoid;
    box-shadow: none;
  }

  .gallery-card:hover {
    transform: none;
  }
}

/* ========================================
   FLOATING LIKE BUTTON
   Modern, intuitive design for character cards
   ======================================== */

/* CSS Variables for Like Button Theme */
:root {
  --like-btn-gradient-from: rgba(130, 64, 255, 0.95);
  --like-btn-gradient-to: rgba(210, 184, 255, 0.95);
  --like-btn-liked-from: #ff006e;
  --like-btn-liked-to: #ff4d9d;
  --like-btn-shadow-color: rgba(130, 64, 255, 0.4);
  --like-btn-liked-shadow-color: rgba(255, 0, 110, 0.4);
}

.gallery-like-btn {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--like-btn-gradient-from) 0%, var(--like-btn-gradient-to) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: white;
  font-size: 18px;
  cursor: pointer;
  z-index: 15;
  transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--like-btn-shadow-color);
  opacity: 0.9;
}

.gallery-like-btn:hover {
  transform: scale(1.1);
  opacity: 1;
  box-shadow: 0 6px 16px var(--like-btn-shadow-color);
}

.gallery-like-btn:active {
  transform: scale(0.95);
}

.gallery-like-btn i {
  transition: all 0.2s ease;
}

/* Liked state */
.gallery-like-btn.liked {
  background: linear-gradient(135deg, var(--like-btn-liked-from) 0%, var(--like-btn-liked-to) 100%);
  box-shadow: 0 4px 12px var(--like-btn-liked-shadow-color);
}

.gallery-like-btn.liked:hover {
  box-shadow: 0 6px 16px var(--like-btn-liked-shadow-color);
}

.gallery-like-btn.liked i {
  animation: heartBeat 0.3s ease;
}

/* Heart beat animation */
@keyframes heartBeat {
  0%, 100% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.3);
  }
  50% {
    transform: scale(1.1);
  }
  75% {
    transform: scale(1.25);
  }
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .gallery-like-btn {
    width: 40px;
    height: 40px;
    font-size: 16px;
    bottom: 10px;
    right: 10px;
    /* Always visible on mobile */
    opacity: 1;
  }
  
  /* Full-screen mode for mobile images */
  .gallery-card .card {
    position: relative;
  }
  
  /* Ensure like button is above image on mobile */
  .gallery-card .gallery-like-btn {
    z-index: 20;
  }
}

/* Touch device support - show button on tap */
@media (hover: none) and (pointer: coarse) {
  .gallery-like-btn {
    opacity: 1;
  }

  /* Double tap support will be handled via JavaScript */
}

/* ========================================
   ADMIN NSFW TOGGLE BUTTON
   Toggle button for admin users to switch
   images between SFW and NSFW categories
   ======================================== */

/* CSS Variables for Admin Toggle Button */
:root {
  --admin-toggle-sfw-from: rgba(34, 197, 94, 0.95);
  --admin-toggle-sfw-to: rgba(74, 222, 128, 0.95);
  --admin-toggle-nsfw-from: rgba(239, 68, 68, 0.95);
  --admin-toggle-nsfw-to: rgba(248, 113, 113, 0.95);
  --admin-toggle-shadow-sfw: rgba(34, 197, 94, 0.4);
  --admin-toggle-shadow-nsfw: rgba(239, 68, 68, 0.4);
}

/* Admin NSFW Toggle Button - positioned below like button */
.admin-nsfw-toggle {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: white;
  font-size: 14px;
  cursor: pointer;
  z-index: 15;
  transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  margin-top: 8px;
}

/* Show on hover over media-item */
.media-item:hover .admin-nsfw-toggle {
  opacity: 1;
}

/* SFW state (image is currently SFW, clicking will make it NSFW) */
.admin-nsfw-toggle.is-sfw {
  background: linear-gradient(135deg, var(--admin-toggle-sfw-from) 0%, var(--admin-toggle-sfw-to) 100%);
  box-shadow: 0 3px 10px var(--admin-toggle-shadow-sfw);
}

.admin-nsfw-toggle.is-sfw:hover {
  transform: scale(1.1);
  box-shadow: 0 5px 14px var(--admin-toggle-shadow-sfw);
}

/* NSFW state (image is currently NSFW, clicking will make it SFW) */
.admin-nsfw-toggle.is-nsfw {
  background: linear-gradient(135deg, var(--admin-toggle-nsfw-from) 0%, var(--admin-toggle-nsfw-to) 100%);
  box-shadow: 0 3px 10px var(--admin-toggle-shadow-nsfw);
}

.admin-nsfw-toggle.is-nsfw:hover {
  transform: scale(1.1);
  box-shadow: 0 5px 14px var(--admin-toggle-shadow-nsfw);
}

.admin-nsfw-toggle:active {
  transform: scale(0.95);
}

.admin-nsfw-toggle i {
  transition: all 0.2s ease;
}

/* Loading state */
.admin-nsfw-toggle.loading {
  pointer-events: none;
  opacity: 0.7;
}

.admin-nsfw-toggle.loading i {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Media item actions container - stack buttons vertically */
.media-item-actions {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 15;
  gap: 0;
}

/* Mobile adjustments for admin toggle */
@media (max-width: 768px) {
  .admin-nsfw-toggle {
    width: 32px;
    height: 32px;
    font-size: 12px;
    /* Always visible on mobile for admin */
    opacity: 1;
  }
}

/* Touch device support - always show for admins */
@media (hover: none) and (pointer: coarse) {
  .admin-nsfw-toggle {
    opacity: 1;
  }
}
