:root {
  --background: #09090b;
  --foreground: #fafafa;
  --card: #09090b;
  --muted: #a1a1aa;
  --border: #27272a;
  --header-height: 80px; /* Altezza fissa per il titolo */
  --radius: 0.5rem;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
}

/* --- STILE DEL TITOLO (HEADER) --- */
.site-header {
  height: var(--header-height);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  /* Effetto vetro scuro tipico dello stile moderno */
  background: rgba(9, 9, 11, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.brand-logo {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.06em;
  text-transform: uppercase;
  
  background: linear-gradient(to bottom right, #ffffff 50%, #a1a1aa 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  
}

/* --- LAYOUT GENERALE --- */
.main-container {
  display: flex;
  flex-direction: column;
  /* L'altezza minima calcola lo spazio meno l'header */
  min-height: calc(100vh - var(--header-height));
}

/* Sezione Immagine */
.image-wrapper {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  background-color: #000000;
}

.profile-img {
  width: 100%;
  max-width: 380px;
  max-height: 70vh;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* Animazione */
.fade-in-left {
  opacity: 0;
  transform: translateX(-20px);
  animation: fadeInLeft 0.6s ease-out forwards;
}

@keyframes fadeInLeft {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Sezione Contenuto */
.content-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 2rem;
}

.card {
  width: 100%;
  max-width: 400px;
}

.card-header {
  margin-bottom: 1rem;
  /* Su mobile centriamo il testo della card, su desktop no (opzionale) */
  text-align: left; 
}

.card-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

/* Griglia Nickname */
.nickname-grid {
  list-style: none;
  display: grid;
  gap: 0.5rem;
}

.nickname-item {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color 0.2s, border-color 0.2s;
  cursor: default;
  overflow: hidden; 
}

.nickname-item:hover {
  background-color: #27272a;
  border-color: #52525b;
}

/* --- MEDIA QUERY DESKTOP --- */
@media (min-width: 1024px) {
  .main-container {
    flex-direction: row;
  }
}

/* Scrollbar personalizzata elegante (per Webkit: Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background-color: #3f3f46; /* Grigio scuro coerente col tema */
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background-color: #52525b;
}

/* --- STILE FOOTER E BOTTONI --- */
.card-footer {
  padding-top: 1rem;
  flex-shrink: 0; /* Impedisce al footer di schiacciarsi */
}

.btn-primary {
  width: 100%;
  background-color: #ffffff;
  color: #09090b;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-primary:hover {
  background-color: #e4e4e7; /* Grigio chiaro al passaggio */
}

/* --- MODALE (Overlay e Contenuto) --- */
.modal-overlay {
  position: fixed;
  inset: 0; /* occupa tutto lo schermo top/right/bottom/left */
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  transition: opacity 0.3s ease;
}

/* Classe di utilità per nascondere la modale */
.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none; /* Disabilita click quando invisibile */
}

.modal-content {
  background-color: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 400px;
  padding: 1.5rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  transform: translateY(0);
  transition: transform 0.3s ease;
  max-height: 90vh; /* Impedisce alla modale di uscire dallo schermo */
  overflow-y: auto; /* Abilita lo scroll interno alla modale se necessario */
}

.modal-overlay.hidden .modal-content {
  transform: translateY(20px); /* Effetto scivolamento quando appare/scompare */
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.btn-close:hover {
  color: var(--foreground);
}

/* --- INPUT FORM STYLE --- */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--foreground);
}

.form-group input {
  width: 100%;
  padding: 0.75rem;
  background-color: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--foreground);
  font-size: 0.95rem;
  outline: none;
}

.form-group input:focus {
  border-color: #ffffff; /* Bordo bianco al focus */
  box-shadow: 0 0 0 1px #ffffff;
}

.full-width {
  width: 100%;
}

/* --- NUOVI STILI MODALE --- */

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--foreground);
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-divider {
  border: 0;
  height: 1px;
  background-color: var(--border);
  margin: 1.5rem 0; /* Spazio sopra e sotto la linea */
}

/* Stile per il messaggio di errore */
.error-message {
  background-color: rgba(239, 68, 68, 0.1); /* Rosso trasparente */
  color: #ef4444; /* Rosso acceso */
  padding: 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 1rem;
  text-align: center;
  border: 1px solid rgba(239, 68, 68, 0.2);
  
  /* Animazione di comparsa */
  animation: shake 0.4s ease-in-out;
}

.error-message.hidden {
  display: none;
}

/* Animazione "Shake" per attirare l'attenzione sull'errore */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}


@keyframes growIn {
  0% {
    opacity: 0;
    max-height: 0px;
  }
  100% {
    opacity: 1;
    max-height: 100%;
  }
}

/* --- MEDIA QUERY DESKTOP (CORRETTA E PULITA) --- */
@media (min-width: 1024px) {
  /* LA LISTA (Contenitore scrollabile) */
  .nickname-grid {
    display: flex;        /* Cambiamo da Grid a Flex per controllo migliore */
    flex-direction: column;
    gap: 0.5rem;          /* Mantiene lo spazio tra gli elementi */
    
    flex-grow: 1;         /* Occupa tutto lo spazio verticale disponibile */
    overflow-y: auto;     /* Abilita lo scroll solo qui */
    padding-right: 10px;  /* Spazio per la scrollbar */
    scrollbar-gutter: stable;
    max-height: 0px;
    /* border-top: 1px solid var(--border); */   
    /* border-bottom: 1px solid var(--border); */
  }

  .nickname-grid.grow {
    animation: growIn 0.8s ease-out forwards;
  }

  /* I SINGOLI SOPRANNOMI */
  .nickname-item {
    flex-shrink: 0;  /* "Non diventare mai più piccolo del tuo contenuto" */
    min-height: auto;
  }

  .main-container {
    flex-direction: row;
    /* L'altezza totale è fissa: Schermo - Header Generale */
    height: calc(100vh - var(--header-height));
    overflow: hidden; /* Nessuno scroll sulla pagina principale */
  }
  
  .image-wrapper {
    flex: 0 0 50%;
    border-right: 1px solid var(--border);
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
  }

  .profile-img {
    max-height: 85%;
    max-width: 80%;
    width: auto;
  }

  /* Lato Destro: Contenitore che centra la card */
  .content-wrapper {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    overflow: hidden; /* Non far scrollare il wrapper, deve scrollare la lista */
  }

  /* La Card: ha un limite massimo di altezza ma si adatta */
  .card {
    width: 100%;
    max-width: 500px;
    
    display: flex;
    flex-direction: column;

    /* TRUCCO PERFETTO: */
    /* La card prova ad essere 'auto' (piccola), ma non può superare il 100% del padre */
    max-height: 100%; 
    background-color: var(--card);
  }

  .card-header {
    flex-shrink: 0; /* Il titolo non si schiaccia mai */
    margin-bottom: 1rem;
    padding-right: 10px;
  }

}
