/*
  App CSS — refactor: variables, dedup, consistent spacing
  Behavior unchanged
*/

/* Variables */
:root {
  --color-footer-bg: #5b1236;
  --color-text-muted: rgba(255, 255, 255, 0.75);
  --color-white: #ffffff;
  --color-primary: #5b1236; /* brand color */
  --color-primary-contrast: #ffffff;
  --color-accent: #9b1c57;
  --masonry-gap: 0px;
  --masonry-radius: 0 !important; /* flat look: no rounded corners globally */
  --masonry-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* OAuth Login Styles */
.divider {
  position: relative;
  text-align: center;
  margin: 1rem 0;
}

.divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background-color: #dee2e6;
}

.divider-text {
  background-color: white;
  padding: 0 1rem;
  color: #6c757d;
  font-size: 0.875rem;
}

/* Footer */
.footer {
  background-color: var(--color-footer-bg);
  font-size: 0.9rem;
}

.footer .nav-link {
  color: var(--color-text-muted);
  transition: color 0.2s ease-in-out;
}

.footer .nav-link:hover {
  color: var(--color-white);
}

#site_version {
  text-align: center;
  clear: left; /* fix: was 'clean:left' */
}

/* Masonry gallery */
.masonry-grid {
  column-count: 4; /* Default 4 colonne su schermi desktop */
  column-gap: 0 !important; /* Forza gap a 0 */
  column-rule: none !important; /* Rimuove eventuali linee tra colonne */
  column-fill: balance; /* Distribuisce uniformemente le colonne */
  padding: 0 !important; /* Rimuove padding laterali per layout full-width */
  margin: 0 !important; /* Rimuove margini */
  width: 100%; /* Assicura larghezza completa */
  box-sizing: border-box; /* Include padding e border nel calcolo della larghezza */
  line-height: 0 !important; /* Elimina spazi tra elementi inline-block */
  font-size: 0 !important; /* Elimina spazi tra elementi inline-block */
  word-spacing: 0 !important; /* Elimina spazi tra parole */
  letter-spacing: 0 !important; /* Elimina spazi tra lettere */
  contain: layout; /* Ottimizza il layout per performance */
  will-change: column-count; /* Ottimizza le animazioni */
}

/* Forza 4 colonne su schermi desktop */
@media (min-width: 992px) {
  .masonry-grid {
    column-count: 4 !important;
  }
}

/* Full-width container per masonry */
.container-fluid.px-0 {
  padding-left: 0 !important;
  padding-right: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.masonry-item {
  break-inside: avoid;
  margin-bottom: 0 !important; /* Forza margin-bottom a 0 */
  margin-top: 0 !important; /* Forza margin-top a 0 */
  display: inline-block;
  width: 100%;
  position: relative; /* Permette il posizionamento assoluto dell'overlay NSFW */
}

.masonry-img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 0 !important;
  box-shadow: none; /* flat look */
  transition: transform 0.2s ease;
}

.masonry-img:hover {
  transform: none; /* flat look */
}

/* Thumb overlay on hover */
.thumb {
  position: relative;
  overflow: hidden;
  display: block;
  border-radius: 0; /* flat look */
}

.thumb img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 300ms ease;
  border-radius: 0; /* flat look */
}

.thumb:hover img {
  transform: scale(1.05); /* zoom effect */
}

/* Optimized Lazy Loading */
.lazy-loading {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  will-change: background-position;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.lazy-image {
  opacity: 0;
  transition: opacity 0.2s ease;
  will-change: opacity;
  transform: translateZ(0); /* Hardware acceleration */
}

.lazy-image.loaded {
  opacity: 1;
}

/* Performance optimizations */
.masonry-grid {
  contain: layout style paint; /* CSS Containment */
  will-change: column-count;
}

.masonry-item {
  contain: layout style;
  will-change: transform;
}

.masonry-img {
  transform: translateZ(0); /* Hardware acceleration */
  will-change: transform;
  backface-visibility: hidden; /* Prevent flickering */
}

.thumb-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  color: var(--color-white);
  background: rgba(0, 0, 0, 0.6); /* nero trasparente su tutta l'immagine */
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: none;
  text-align: center;
}

.thumb:hover .thumb-overlay {
  opacity: 1;
}

.thumb-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  line-height: 1.3;
  text-align: center;
  width: 100%;
}

.thumb-author {
  margin: 4px 0 0 0;
  font-size: 0.85rem;
  font-weight: 400;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  line-height: 1.2;
  opacity: 0.9;
  text-align: center;
  width: 100%;
}

.thumb-desc {
  margin: 2px 0 0 0;
  font-size: 0.8rem;
  opacity: 0.9;
}

/* Line clamp utilities */
.line-clamp-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Responsiveness */
@media (min-width: 1600px) {
  .masonry-grid { column-count: 4 !important; }
}

@media (max-width: 1599px) and (min-width: 1200px) {
  .masonry-grid { column-count: 4 !important; }
}

@media (max-width: 1199px) and (min-width: 992px) {
  .masonry-grid { column-count: 4 !important; }
}

/* Media query specifica per risoluzioni come 1280x800 */
@media (max-width: 1300px) and (min-width: 1100px) {
  .masonry-grid { 
    column-count: 4 !important; 
    -webkit-column-count: 4 !important;
    -moz-column-count: 4 !important;
  }
}

/* Regola forzata per risoluzioni desktop medie */
@media (min-width: 1100px) and (max-width: 1400px) {
  .masonry-grid { 
    column-count: 4 !important; 
    -webkit-column-count: 4 !important;
    -moz-column-count: 4 !important;
  }
}

@media (max-width: 991px) and (min-width: 576px) {
  .masonry-grid { column-count: 2 !important; }
}

@media (max-width: 575px) {
  .masonry-grid { column-count: 2 !important; }
}

/* Sections */
.section-divider {
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  padding-top: 1rem;
  margin-top: 2rem;
}

/* Simple fade-in animation for dynamic content */
.fade-in {
  animation: fadeIn 200ms ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Flat UI overrides for Bootstrap components */
.card,
.btn,
.form-control,
.navbar,
.dropdown-menu,
.modal-content,
.img-thumbnail,
.badge {
  border-radius: 0 !important;
  box-shadow: none !important;
}

.btn:focus,
.form-control:focus {
  box-shadow: none !important;
}

.navbar-dark,
.navbar {
  box-shadow: none !important;
  background-color: var(--color-primary) !important;
  position: fixed !important;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1030;
}

/* Layout per contenuto scrollabile */
body {
  padding-top: 76px; /* Altezza navbar per evitare sovrapposizione */
}

/* Homepage specifica - rimuove padding extra */
.homepage-content {
  margin-top: 0;
  padding-top: 0;
  background-color: #000 !important; /* sfondo nero per la sezione foto */
  min-height: 100vh;
  line-height: 0 !important; /* Elimina spazi tra elementi */
}

/* Elimina spazi su tutti i contenitori masonry */
.container-fluid .masonry-grid,
.row .masonry-grid,
.col .masonry-grid {
  line-height: 0 !important;
  font-size: 0 !important;
}

/* Ripristina font-size per il contenuto interno */
.masonry-item {
  font-size: 14px; /* Ripristina font-size normale */
  line-height: normal;
  vertical-align: top; /* Allinea in alto per evitare spazi */
}

/* Elimina spazi tra elementi inline-block */
.masonry-grid * {
  margin: 0 !important;
  padding: 0 !important;
}

/* Forza eliminazione spazi su tutti gli elementi masonry */
.masonry-grid,
.masonry-grid *,
.masonry-item,
.masonry-item * {
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  outline: 0 !important;
}

/* Ripristina layout masonry originale ma senza spazi */
.masonry-item {
  break-inside: avoid;
  margin-bottom: 0 !important; /* Forza margin-bottom a 0 */
  margin-top: 0 !important; /* Forza margin-top a 0 */
  display: inline-block;
  width: 100%;
  position: relative; /* Permette il posizionamento assoluto dell'overlay NSFW */
  vertical-align: top; /* Allinea in alto per evitare spazi */
}

/* Forza sfondo nero per tutta la homepage */
body.homepage {
  background-color: #000 !important;
}

/* Stile per la sezione info foto */
#photo-info-section {
  background-color: #1a1a1a !important; /* Sfondo scuro che sta bene con il nero */
  padding: 20px;
  border-radius: 0 !important;
  margin-bottom: 20px;
}

#photo-info-section .card {
  background-color: #1a1a1a !important;
  border: none;
}

#photo-info-section .card-body {
  background-color: #1a1a1a !important;
  color: #ffffff !important;
}

#photo-info-section .text-muted {
  color: #cccccc !important;
}

#photo-info-section .btn {
  color: #ffffff !important;
}

/* Stile per i breadcrumbs */
.breadcrumb {
  background-color: transparent !important;
  padding: 0;
  margin: 0;
}

.breadcrumb-item a {
  color: #ffffff !important;
  text-decoration: none;
}

.breadcrumb-item a:hover {
  color: #cccccc !important;
  text-decoration: underline;
}

.breadcrumb-item.active {
  color: #cccccc !important;
}

.breadcrumb-item + .breadcrumb-item::before {
  color: #666666 !important;
  content: ">";
}

/* Filtro B&N per le 4 thumbnails nella pagina dettaglio foto */
#photo-related-images-section .thumb img {
  filter: grayscale(100%) !important;
  transition: filter 0.3s ease !important;
}

#photo-related-images-section .thumb:hover img {
  filter: grayscale(0%) !important;
}

/* Modal per ingrandimento immagine */
.image-modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(5px);
}

.image-modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.image-modal-content {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
  border-radius: 0 !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform 0.3s ease;
}

.image-modal-content:hover {
  transform: scale(1.02);
}

.image-modal-close {
  position: absolute;
  top: 20px;
  right: 30px;
  color: #fff;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  z-index: 10000;
  transition: color 0.3s ease;
}

.image-modal-close:hover {
  color: #ccc;
}

/* Animazioni */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Cursor pointer per l'immagine principale */
#photo-main-image-section img {
  cursor: pointer;
  transition: transform 0.3s ease;
}

#photo-main-image-section img:hover {
  transform: scale(1.02);
}

/* Forza sfondo nero per il container della homepage */
.homepage-content .container-fluid {
  background-color: #000 !important;
}

/* Layout pagina dettaglio utente */
.user-detail-layout .sticky-top {
  position: sticky;
  top: 100px;
  z-index: 10;
}

/* Sfondo nero per pagine dettaglio - solo body */
body.user-detail-page,
body.photo-detail-page {
  background-color: #000;
}

/* Sfondo nero solo per la sezione delle immagini, non per tutto il container */
.user-detail-page .masonry-grid,
.photo-detail-page .masonry-grid {
  background-color: #000;
}

/* Sfondo nero per la sezione foto principale */
.photo-detail-page .col-lg-9 {
  background-color: #000;
}

/* Container avatar con sfondo nero */
.avatar-container {
  background-color: #000 !important;
  padding: 20px;
  border-radius: 0 !important;
  margin-bottom: 1rem;
}

/* Avatar responsive */
.user-detail-photo {
  width: 100%;
  max-width: 150px;
  height: 150px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 50%;
}

/* Brand theming */
.btn-primary {
  background-color: var(--color-primary) !important;
  border-color: var(--color-primary) !important;
}

.btn-outline-secondary {
  border-color: #bbb !important;
  color: #555 !important;
}

.badge.bg-secondary {
  background-color: var(--color-primary) !important;
  color: var(--color-primary-contrast) !important;
}

.navbar .nav-link {
  color: var(--color-primary-contrast) !important;
}

.list-group-item,
.alert,
.input-group .form-control,
.input-group .btn {
  border-radius: 0 !important;
}

/* NSFW Protection Layer */
.nsfw-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #000000; /* Sfondo completamente nero */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: 0 !important;
  cursor: pointer; /* Cursore pointer per indicare che è cliccabile */
  transition: background-color 0.3s ease;
}

.nsfw-overlay:hover {
  background-color: #1a1a1a; /* Leggero cambiamento al hover */
}

.nsfw-content {
  text-align: center;
  color: var(--color-white);
  padding: 20px;
}

.nsfw-text {
  font-size: 2.5rem;
  font-weight: bold;
  margin-bottom: 10px;
  letter-spacing: 2px;
}

.nsfw-subtitle {
  font-size: 0.9rem;
  opacity: 0.8;
  line-height: 1.4;
}

.nsfw-click-hint {
  font-size: 0.8rem;
  opacity: 0.6;
  margin-top: 8px;
  font-style: italic;
}

/* Responsive adjustments for NSFW overlay */
@media (max-width: 768px) {
  .nsfw-text {
    font-size: 2rem;
  }
  
  .nsfw-subtitle {
    font-size: 0.8rem;
  }
  
  .nsfw-click-hint {
    font-size: 0.7rem;
  }
}

/* Profile Photo Hover Effect */
.profile-photo-container {
  position: relative;
  display: inline-block;
  overflow: hidden;
  border-radius: 50%;
}

.profile-photo-container img {
  transition: opacity 0.3s ease-in-out;
  display: block;
}

.profile-photo-hover {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.profile-photo-container:hover .profile-photo-hover {
  opacity: 1;
}

.profile-photo-container:hover .profile-photo-main {
  opacity: 0;
}

/* Hover effect for user lists and details */
.user-photo-hover {
  position: relative;
  display: inline-block;
  overflow: hidden;
}

.user-photo-hover img {
  transition: opacity 0.3s ease-in-out;
  display: block;
}

.user-photo-hover .hover-image {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.user-photo-hover:hover .hover-image {
  opacity: 1;
}

.user-photo-hover:hover .main-image {
  opacity: 0;
}

/* Specific styles for user list cards */
.user-list-card .user-photo-hover {
  border-radius: 0; /* No rounded corners for square images */
}

/* Specific styles for user detail page */
.user-detail-photo .user-photo-hover {
  border-radius: 0; /* No rounded corners for square images */
}

/* Responsive adjustments for square images */
@media (max-width: 768px) {
  .user-detail-photo .user-photo-hover {
    width: 180px !important;
    height: 180px !important;
  }
  
  .user-detail-photo .user-photo-hover img {
    width: 180px !important;
    height: 180px !important;
  }
}

@media (max-width: 576px) {
  .user-detail-photo .user-photo-hover {
    width: 150px !important;
    height: 150px !important;
  }
  
  .user-detail-photo .user-photo-hover img {
    width: 150px !important;
    height: 150px !important;
  }
}

/* Admin Bar Styles */
.admin-bar {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.admin-bar .btn {
  font-weight: 500;
  border: 1px solid rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

.admin-bar .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.admin-bar .btn-warning {
  background-color: #ffc107;
  border-color: #ffc107;
  color: #000;
}

.admin-bar .btn-warning:hover {
  background-color: #e0a800;
  border-color: #d39e00;
  color: #000;
}

.admin-bar .btn-info {
  background-color: #0dcaf0;
  border-color: #0dcaf0;
  color: #000;
}

.admin-bar .btn-info:hover {
  background-color: #0aa2c0;
  border-color: #0992aa;
  color: #000;
}

.admin-bar .badge {
  font-size: 0.75rem;
  font-weight: 600;
}

/* Force no rounded corners on all masonry images */
.masonry-grid img,
.masonry-img,
.thumb img {
  border-radius: 0 !important;
}

/* Filtri pulsanti pagina explorer */
.filter-btn {
  background-color: #4a4a4a !important; /* Grigio scuro */
  border: 1px solid #4a4a4a !important;
  color: #ffffff !important;
  padding: 8px 16px !important;
  border-radius: 4px !important;
  transition: all 0.3s ease !important;
  font-size: 14px !important;
  font-weight: 500 !important;
}

.filter-btn:hover {
  background-color: #5a5a5a !important; /* Grigio leggermente più chiaro al hover */
  border-color: #5a5a5a !important;
  color: #ffffff !important;
}

.filter-btn.active {
  background-color: #5b1236 !important; /* Stesso colore della navbar */
  border-color: #5b1236 !important;
  color: #ffffff !important;
}

.filter-btn:focus {
  box-shadow: 0 0 0 0.2rem rgba(91, 18, 54, 0.25) !important;
  outline: none !important;
}

/* Breadcrumb su sfondo nero */
.homepage .breadcrumb {
  background-color: rgba(255, 255, 255, 0.1) !important;
  padding: 10px 15px !important;
  border-radius: 5px !important;
  backdrop-filter: blur(10px) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

.homepage .breadcrumb-item a {
  color: #ffffff !important;
  text-decoration: none !important;
}

.homepage .breadcrumb-item a:hover {
  color: #cccccc !important;
  text-decoration: underline !important;
}

.homepage .breadcrumb-item.active {
  color: #ffffff !important;
  font-weight: 500 !important;
}

.homepage .breadcrumb-item + .breadcrumb-item::before {
  color: #ffffff !important;
  content: ">" !important;
}

/* ===== GLOBAL BODY STYLING ===== */

/* Sfondo nero per tutte le pagine */
body {
  background-color: black;
}

/* ===== HOMEPAGE STYLE - REFACTORED ===== */

/* Base homepage styling - identico alla homepage */
.homepage {
  background-color: #000000;
  color: #ffffff;
  min-height: 100vh;
}

.homepage .homepage-content {
  background-color: #000000;
  color: #ffffff;
  min-height: 100vh;
}

/* ===== SECTIONS STYLING ===== */

/* Container filtri fisso per Explorer */
.filters-container {
  position: fixed;
  top: 56px; /* Sotto la navbar */
  left: 0;
  right: 0;
  z-index: 1000;
  background-color: #000000;
  border-bottom: 1px solid #333333;
  padding: 15px 0;
  transition: all 0.3s ease;
}

.filters-container.hidden {
  transform: translateY(-100%);
  opacity: 0;
}

.filters-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Aggiusta il padding del body quando i filtri sono visibili */
body.filters-visible {
  padding-top: 120px; /* Navbar + filtri */
}

/* Filtri section per Explorer (deprecato) */
.filters-section {
  padding: 20px 0;
  background-color: #000000;
}

/* Breadcrumb section per Modelle/Fotografi */
.breadcrumb-section {
  padding: 20px 0;
  background-color: #000000;
}

/* Allineamento breadcrumbs */
.breadcrumb-section .breadcrumb {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
}

.breadcrumb-section .breadcrumb-item {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
}

.breadcrumb-section .breadcrumb-item a {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #ffffff;
  text-decoration: none;
}

.breadcrumb-section .breadcrumb-item a:hover {
  color: #cccccc;
  text-decoration: underline;
}

.breadcrumb-section .breadcrumb-item.active {
  color: #ffffff;
  font-weight: 500;
}

.breadcrumb-section .breadcrumb-item + .breadcrumb-item::before {
  content: ">";
  color: #ffffff;
  margin: 0 10px;
  display: flex;
  align-items: center;
}

/* Allineamento specifico per l'icona casa */
.breadcrumb-section .breadcrumb-item a i {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  line-height: 1;
}

.breadcrumb-section .breadcrumb-item a {
  line-height: 1;
  vertical-align: middle;
}

/* Title section */
.title-section {
  padding: 20px 0;
  background-color: #000000;
}

/* Empty section */
.empty-section {
  padding: 40px 0;
  background-color: #000000;
  text-align: center;
}

/* ===== USERS GRID - MASONRY STYLE ===== */

.users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
  padding: 20px;
  background-color: #000000;
}

.user-card {
  background-color: #1a1a1a;
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.user-card:hover {
  transform: translateY(-5px);
}

.user-photo-hover {
  position: relative;
  width: 100%;
  height: 200px;
  overflow: hidden;
  background-color: #1a1a1a;
}

.user-photo-hover .main-image,
.user-photo-hover .hover-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.3s ease;
}

.user-photo-hover .hover-image {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
}

.user-card:hover .hover-image {
  opacity: 1;
}

.user-info {
  padding: 15px;
  background-color: #1a1a1a;
  color: #ffffff;
  text-align: center;
}

.user-name {
  color: #ffffff;
  font-size: 1.1rem;
  margin-bottom: 5px;
}

.user-location {
  color: #cccccc;
  font-size: 0.9rem;
  margin: 0;
}
