/*
  ====================================
  WATCH FILM - STYLES.CSS
  ====================================
  
  Foglio di stile principale per Watch Film
  
  Sezioni:
  1. Variabili CSS
  2. Reset e base
  3. Layout header
  4. Controlli e form
  5. Layout principale
  6. Card film
  7. Paginazione
  8. Utilities
  9. Media queries
*/

/* ====================================
   1. VARIABILI CSS
   ==================================== */
:root {
  /* Colori principali */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: #1e293b;
  --bg-glass: rgba(255, 255, 255, 0.05);
  
  /* Accenti e gradients */
  --accent-primary: #3b82f6;
  --accent-secondary: #06b6d4;
  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
  --success: #10b981;
  --warning: #f59e0b;
  
  /* Testi */
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --text-dark: #1e293b;
  
  /* Layout */
  --maxwidth: 1200px;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --border-radius-lg: 16px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.3);
  
  /* Animations */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

/* ====================================
   2. RESET E BASE
   ==================================== */
* {
  box-sizing: border-box;
}

body {
  background: linear-gradient(135deg, #0a0e1a 0%, #111827 50%, #1e293b 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  margin: 0;
  padding: 20px;
  min-height: 100vh;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Backdrop blur effect per un look moderno */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(6, 182, 212, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 40% 60%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
  z-index: -1;
  pointer-events: none;
}

/* ====================================
   3. LAYOUT HEADER
   ==================================== */
header {
  max-width: var(--maxwidth);
  margin: 0 auto 32px;
  padding: 24px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  position: relative;
  overflow: hidden;
}

header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--accent-gradient);
}

h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  background: var(--accent-gradient);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  text-shadow: 0 0 30px rgba(59, 130, 246, 0.5);
  letter-spacing: -0.02em;
}

/* ====================================
   4. CONTROLLI E FORM
   ==================================== */
.controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

input,
select {
  padding: 12px 16px;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  color: var(--text-dark);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-normal);
  min-width: 140px;
  box-shadow: var(--shadow-sm);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow), var(--shadow-md);
  transform: translateY(-1px);
}

input:hover,
select:hover {
  border-color: rgba(59, 130, 246, 0.5);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

input::placeholder {
  color: var(--text-muted);
  opacity: 0.8;
  font-weight: 400;
}

select option {
  background: #ffffff;
  color: var(--text-dark);
  padding: 8px 12px;
  font-weight: 500;
}

select#filterSelect {
  min-width: 160px;
}

#filterIndicator {
  font-size: 13px;
  color: var(--text-secondary);
  margin-left: 16px;
  font-style: italic;
  font-weight: 500;
  padding: 6px 12px;
  background: var(--bg-glass);
  border-radius: var(--border-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ====================================
   5. LAYOUT PRINCIPALE
   ==================================== */
main {
  max-width: var(--maxwidth);
  margin: 0 auto;
}

/* Wrapper che mette la paginazione immediatamente sotto l'header */
.pagination-row {
  max-width: var(--maxwidth);
  margin: -16px auto 20px; /* solleva leggermente rispetto al main per essere vicina all'header */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 8px;
}

.movies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

/* ====================================
   6. CARD FILM
   ==================================== */
.movie {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  padding: 16px;
  border-radius: var(--border-radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  text-align: center;
}

.movie::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-gradient);
  transform: scaleX(0);
  transition: transform var(--transition-normal);
}

.movie:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: var(--shadow-xl), var(--shadow-glow);
  border-color: rgba(59, 130, 246, 0.3);
}

.movie:hover::before {
  transform: scaleX(1);
}

.poster {
  width: 100%;
  height: 300px;
  max-width: 200px;
  margin: 0 auto;
  object-fit: cover;
  border-radius: var(--border-radius);
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-card) 100%);
  flex-shrink: 0;
  box-shadow: var(--shadow-lg);
  transition: all var(--transition-normal);
}

/* Trailer overlay nella card */
.trailer-wrapper {
  position: absolute;
  /* allineiamo esattamente al poster (centro orizzontale, posizione verticale in alto della card) */
  top: 16px; /* coincide con il padding interno della card */
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none; /* non interferisce con i click della card */
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: 10;
}

.trailer-wrapper[aria-hidden="false"] {
  opacity: 1;
  pointer-events: auto;
}

.trailer-iframe {
  width: calc(100% - 32px);
  max-width: 200px; /* stessa max-width del poster */
  height: 300px; /* stessa height del poster */
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
}

/* Quando il trailer   visibile, nascondiamo il poster per dare l'effetto di replacement */
.trailer-wrapper[aria-hidden="false"] ~ .poster,
.trailer-wrapper[aria-hidden="false"] + .poster,
.movie:hover .trailer-wrapper[aria-hidden="false"] ~ .poster {
  opacity: 0;
  visibility: hidden;
}

.movie:hover .poster {
  transform: scale(1.05);
  box-shadow: var(--shadow-xl);
}

.movie-info {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.date {
  margin: 0 0 12px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  padding: 4px 8px;
  background: var(--bg-glass);
  border-radius: var(--border-radius-sm);
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.overview {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  max-height: 6em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  font-weight: 400;
  text-align: left;
}

/* ====================================
   7. PAGINAZIONE
   ==================================== */
.pagination {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 0; /* spaziatura gestita dal wrapper .pagination-row */
  flex-wrap: wrap;
}

.page-btn {
  padding: 12px 16px;
  border-radius: var(--border-radius);
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transition-normal);
  min-width: 48px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.page-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  right: 0;
  bottom: 0;
  background: var(--accent-gradient);
  transition: left var(--transition-normal);
  z-index: -1;
}

.page-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(59, 130, 246, 0.3);
}

.page-btn:hover:not(:disabled)::before {
  left: 0;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.page-btn.active {
  background: var(--accent-gradient);
  color: white;
  font-weight: 700;
  box-shadow: var(--shadow-glow), var(--shadow-md);
  border-color: transparent;
}

.page-btn.active::before {
  display: none;
}

/* ====================================
   8. UTILITIES
   ==================================== */
.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-secondary);
  font-style: italic;
  font-weight: 500;
  grid-column: 1 / -1;
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  border-radius: var(--border-radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-md);
  font-size: 16px;
}

/* Animazioni di caricamento */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes slideInUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

/* Applicare animazioni agli elementi */
.movie {
  animation: slideInUp 0.6s ease forwards;
}

.movie:nth-child(even) {
  animation-delay: 0.1s;
}

.movie:nth-child(3n) {
  animation-delay: 0.2s;
}

header {
  animation: fadeIn 0.8s ease;
}

.pagination {
  animation: slideInUp 0.6s ease 0.3s both;
}

/* ====================================
   9. MEDIA QUERIES
   ==================================== */

/* Tablet */
@media (max-width: 768px) {
  body {
    padding: 16px;
  }
  
  header {
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
    padding: 20px;
  }
  
  h1 {
    text-align: center;
    font-size: 24px;
  }
  
  .controls {
    justify-content: center;
    gap: 16px;
  }
  
  .movies-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
  }
  
  .movie {
    padding: 12px;
  }
  
  .poster {
    height: 250px;
    max-width: 160px;
  }
}

/* Mobile */
@media (max-width: 480px) {
  body {
    padding: 12px;
  }
  
  header {
    padding: 16px;
    margin-bottom: 24px;
  }
  
  h1 {
    font-size: 20px;
  }
  
  .controls {
    flex-direction: column;
    width: 100%;
    gap: 16px;
  }
  
  input,
  select {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px; /* Previene zoom su iOS */
  }
  
  .movies-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .movie {
    padding: 12px;
  }
  
  .poster {
    height: 220px;
    max-width: 140px;
  }
  
  .title {
    font-size: 16px;
  }
  
  .date,
  .overview {
    font-size: 13px;
  }
  
  .pagination {
    gap: 6px;
    margin: 32px 0;
  }
  
  .page-btn {
    padding: 10px 12px;
    font-size: 13px;
    min-width: 40px;
  }
  
  #filterIndicator {
    text-align: center;
    margin: 12px 0 0 0;
    font-size: 12px;
  }
}

/* Mobile piccoli (< 360px) */
@media (max-width: 360px) {
  body {
    padding: 8px;
  }
  
  header {
    padding: 12px;
  }
  
  h1 {
    font-size: 18px;
  }
  
  .movie {
    padding: 12px;
  }
  
  .poster {
    height: 200px;
    max-width: 120px;
  }
  
  .pagination {
    gap: 4px;
  }
  
  .page-btn {
    padding: 8px 10px;
    font-size: 12px;
    min-width: 36px;
  }
}

