/* ============================================================
   DENDRIA — Auth styles
   Unico file: base + mobile (≤1023px) + desktop (≥1024px)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:wght@600;700&family=DM+Sans:wght@300;400;500;600&display=swap');

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

:root{
  --bg: #F6F7F4;
  --card: #FFFFFF;

  --text: #0F172A;
  --muted: rgba(0,0,0,0.60);

  --border: rgba(0,0,0,0.12);
  --border-soft: rgba(0,0,0,0.08);

  --cta: #9FB89A;
  --cta-dark: #7FA08A;

  --accent: #1c4d13;
  --accent-2: #2E7D32;

  --radius: 18px;
  --radius-md: 14px;
  --radius-sm: 12px;

  --shadow: 0 12px 40px rgba(0,0,0,0.08);
}

body{
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================
   TOAST
============================ */
.toast-container {
  position: relative;
  width: 100%;
  margin-bottom: 1.25rem;
  pointer-events: none;
}

.toast {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  border: 1.5px solid;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
  font-weight: 500;
  pointer-events: all;
  animation: toastSlideIn 0.35s cubic-bezier(0.4,0,0.2,1);
  will-change: transform, opacity;
}

.toast.toast-exit {
  animation: toastSlideOut 0.3s cubic-bezier(0.4,0,0.2,1) forwards;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

@keyframes toastSlideOut {
  from { opacity: 1; transform: translateY(0)    scale(1);    }
  to   { opacity: 0; transform: translateY(-8px) scale(0.98); }
}

.toast-icon { width: 20px; height: 20px; flex-shrink: 0; }
.toast-content { flex: 1; font-weight: 600; }

.toast.toast-success { background: #f0f9f0; border-color: #9FB89A; color: #1c4d13; }
.toast.toast-success .toast-icon { color: #2E7D32; }
.toast.toast-error   { background: #fef2f2; border-color: #f87171; color: #7f1d1d; }
.toast.toast-error .toast-icon   { color: #dc2626; }
.toast.toast-info    { background: #eff6ff; border-color: #60a5fa; color: #1e40af; }
.toast.toast-info .toast-icon    { color: #3b82f6; }

/* ============================
   FORMS CONTAINER (shared)
============================ */
.forms-container{
  position: relative;
  overflow: hidden;
}

.form-content{
  width: 100%;
  opacity: 0;
  transform: translateX(100%);
  position: absolute;
  top: 0; left: 0;
  transition: all 0.45s cubic-bezier(0.4,0,0.2,1);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.form-content.active{
  opacity: 1;
  transform: translateX(0);
  position: relative;
  pointer-events: all;
}

.form-content.slide-out-left  { transform: translateX(-100%); opacity: 0; }
.form-content.slide-out-right { transform: translateX(100%);  opacity: 0; }
.form-content.slide-in-left   { transform: translateX(-100%); }
.form-content.slide-in-right  { transform: translateX(100%);  }

/* Form header (visibile solo su desktop) */
.form-header{ text-align: center; margin-bottom: 1.75rem; }
.form-title{
  font-size: 2rem;
  line-height: 1.12;
  letter-spacing: -0.02em;
  font-weight: 650;
  margin-bottom: .4rem;
}
.form-subtitle{ font-size: 1rem; color: var(--muted); }

/* Form shared */
.auth-form{ display: flex; flex-direction: column; gap: 1.2rem; }

.form-label{
  font-size: 0.95rem;
  font-weight: 600;
  color: rgba(0,0,0,0.78);
  margin-bottom: .35rem;
  display: inline-block;
}

.label-row{ display: flex; justify-content: space-between; align-items: center; gap: 1rem; }

.forgot-link{
  font-size: 0.9rem;
  color: rgba(46,125,50,0.75);
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
}
.forgot-link:hover{ text-decoration: underline; }

.input-wrapper{ position: relative; display: flex; align-items: center; }

.input-icon{
  position: absolute;
  left: .9rem;
  width: 18px;
  height: 18px;
  color: rgba(0,0,0,0.42);
  pointer-events: none;
}

.form-input{
  width: 100%;
  padding: .95rem 1rem .95rem 2.8rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #fff;
  font-size: 1rem;
  color: var(--text);
  transition: box-shadow .15s ease, border-color .15s ease;
}
.form-input::placeholder{ color: rgba(0,0,0,0.35); }
.form-input:focus{
  outline: none;
  border-color: rgba(46,125,50,0.35);
  box-shadow: 0 0 0 4px rgba(159,184,154,0.25);
}

.toggle-password{
  position: absolute;
  right: .65rem;
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  display: grid; place-items: center;
  cursor: pointer;
  color: rgba(0,0,0,0.45);
}
.toggle-password i{ width: 18px; height: 18px; }
.toggle-password:hover{
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.06);
  color: rgba(0,0,0,0.65);
}

.input-hint{ margin-top: .35rem; font-size: 0.92rem; color: rgba(0,0,0,0.55); }

.btn-primary{
  margin-top: .25rem;
  width: 100%;
  padding: 0.95rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.12);
  background: var(--cta);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  box-shadow: 0 10px 24px rgba(0,0,0,0.10);
}
.btn-primary:hover{ transform: translateY(-1px); background: rgba(159,184,154,1); }
.btn-primary:active{ transform: translateY(0); }

/* Resend verify */
#resendVerifyContainer{
  margin-top: 0.5rem;
  text-align: center;
  min-height: 0;
  overflow: hidden;
  transition: min-height 0.3s ease, opacity 0.3s ease;
}
#resendVerifyContainer.show{ min-height: 2.5rem; opacity: 1; }

.resend-verify-link{
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 0.9rem;
  color: rgba(46,125,50,0.75);
  background: none; border: none;
  cursor: pointer; font-weight: 600;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  transition: background 0.2s ease, color 0.2s ease;
}
.resend-verify-link:hover{ background: rgba(159,184,154,0.1); color: rgba(46,125,50,0.9); }
.resend-verify-link:disabled{ opacity: 0.5; cursor: not-allowed; }
.resend-verify-link svg{ width: 16px; height: 16px; }

/* Divider */
.divider{ position: relative; text-align: center; margin: 1.4rem 0; }
.divider::before{
  content:"";
  position: absolute;
  inset: 50% 0 auto 0;
  height: 1px;
  background: rgba(0,0,0,0.12);
}
.divider-text{
  position: relative;
  display: inline-block;
  padding: 0 .85rem;
  background: #fff;
  font-size: 0.95rem;
  color: rgba(0,0,0,0.55);
}

/* Social */
.social-buttons{ display: grid; gap: .85rem; }
.one-col{ grid-template-columns: 1fr; }

.btn-social{
  width: 100%;
  padding: 0.95rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.12);
  background: #fff;
  color: rgba(0,0,0,0.82);
  font-size: 0.95rem;
  font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  gap: .7rem;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn-social:hover{
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.08);
  background: rgba(0,0,0,0.01);
}

/* Checkbox */
.checkbox-group{ display: flex; gap: .65rem; align-items: flex-start; }
.checkbox-group input{ margin-top: .25rem; width: 16px; height: 16px; accent-color: var(--accent-2); }
.checkbox-label{ font-size: 0.95rem; color: rgba(0,0,0,0.60); }
.checkbox-label .link{ color: rgba(46,125,50,0.85); font-weight: 700; text-decoration: underline; }

/* Switch link */
.switch-link{ text-align: center; margin-top: 1.2rem; font-size: 1rem; color: rgba(0,0,0,0.60); }

.link-button{
  background: none; border: none;
  color: rgba(46,125,50,0.85);
  font-weight: 800; cursor: pointer; font-size: 1rem;
}
.link-button:hover{ text-decoration: underline; }

/* Dots */
.dots-indicator{ display: flex; justify-content: center; gap: .55rem; margin-top: 1.6rem; }
.dot{ width: 6px; height: 6px; border-radius: 999px; background: rgba(0,0,0,0.18); border: none; }
.dot.active{ width: 34px; border-radius: 10px; background: rgba(46,125,50,0.45); }

/* Elementi iniettati via JS nel mobile header — nascosti di default su desktop */
.mobile-dryad,
.mobile-header-title,
.mobile-header-sub { display: none; }

/* ============================================================
   MOBILE (≤ 1023px)
   Layout: sfondo verde fullscreen + card bianca scorrevole
   NB: auth-mobile-header.js deve essere incluso nell'HTML
       per iniettare .mobile-dryad, .mobile-header-title, .mobile-header-sub
   ============================================================ */
@media (max-width: 1023px) {

  html, body {
    background: var(--cta) !important;
    min-height: 100dvh;
  }

  .auth-container {
  display: flex;             /* Cambiato da block a flex */
  align-items: center;       /* Centra verticalmente */
  justify-content: center;    /* Centra orizzontalmente */
  min-height: 100dvh;
  padding: 20px;             /* Un po' di respiro dai bordi dello schermo */
  background: transparent !important;
  }

  .auth-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100dvh;
    max-width: 100%;
    border-radius: 0;
    box-shadow: none;
    border: none;
    background: transparent !important;
    overflow: visible;
  }

  /* Pannello illustrazione desktop: nascosto su mobile */
  .illustration-panel {
    display: none !important;
  }

  /* Form panel */
  .form-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    background: transparent;
  }

  .form-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 0;
    max-width: 100%;
    background: transparent !important;
    border-radius: 0;
    box-shadow: none;
  }

  /* ── Header verde ────────────────────────── */
  .brand-minimal {
    background: transparent;
    min-height: 220px;
    padding: 48px 28px 52px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    position: relative;
    overflow: hidden;
    margin-bottom: 0;
  }

  /* Cerchio grande semitrasparente in alto a destra */
  .brand-minimal::before {
    content: '';
    position: absolute;
    top: -60px; right: -60px;
    width: 240px; height: 240px;
    border-radius: 50%;
    background: rgba(255,255,255,.09);
    pointer-events: none;
  }

  /* Cerchio piccolo in basso a destra */
  .brand-minimal::after {
    content: '';
    position: absolute;
    bottom: 20px; right: 44px;
    width: 52px; height: 52px;
    border-radius: 50%;
    background: rgba(28,77,19,.14);
    pointer-events: none;
  }

  /* Logo */
  .brand-link { display: block; margin-bottom: 20px; position: relative; z-index: 2; }
  .brand-logo-min {
    height: 36px; width: auto;
    filter: brightness(0) invert(1);
    opacity: .9;
  }

  /* Personaggio iniettato via JS */
  .mobile-dryad {
    display: block;              /* override del display:none base */
    position: absolute;
    right: -10px; bottom: 0;
    height: 195px; width: auto;
    object-fit: contain;
    pointer-events: none;
    z-index: 1;
    animation: dryadFadeIn .5s ease both;
  }

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

  /* Titolo iniettato via JS */
  .mobile-header-title {
    display: block;              /* override del display:none base */
    font-family: 'Fraunces', serif;
    font-size: 1.7rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.1;
    margin: 0 0 7px;
    letter-spacing: -.02em;
    position: relative; z-index: 2;
    max-width: 65%;
  }

  /* Sottotitolo iniettato via JS */
  .mobile-header-sub {
    display: block;              /* override del display:none base */
    font-family: 'DM Sans', sans-serif;
    font-size: .875rem;
    color: rgba(255,255,255,.65);
    margin: 0;
    font-weight: 300;
    position: relative; z-index: 2;
    max-width: 60%;
  }

  /* ── Card bianca ─────────────────────────── */
  .toast-container {
    background: var(--card);
    padding: 20px 24px 0;
    border-radius: 24px 24px 0 0;
    margin-bottom: 0;
    box-shadow: 0 -6px 24px rgba(0,0,0,.07);
    position: relative;
  }

  /* Toast vuoto: passa il border-radius al forms-container */
  .toast-container:empty {
    padding: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .toast-container:empty + .forms-container {
    border-radius: 24px 24px 0 0;
    padding-top: 28px;
    box-shadow: 0 -6px 24px rgba(0,0,0,.07);
  }

  .forms-container {
    flex: 1;
    background: var(--card);
    padding: 0 24px 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .dots-indicator {
    background: var(--card);
    padding: 12px 0 24px;
    margin-top: 0;
    display: flex;
    justify-content: center;
    gap: 6px;
  }

  /* Nasconde header interno al form (titolo nel header verde) */
  .form-header { display: none; }

  /* ── Form fields ────────────────────────── */
  .auth-form { display: flex; flex-direction: column; gap: 1rem; padding-top: 8px; }

  .form-label {
    font-size: .73rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: rgba(0,0,0,.38);
    margin-bottom: 4px;
  }

  /* Input underline style */
  .form-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1.5px solid var(--border);
    border-radius: 0;
    padding: 10px 40px 10px 28px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text);
    outline: none;
    box-shadow: none !important;
    transition: border-color .2s ease;
    box-sizing: border-box;
  }

  .form-input::placeholder { color: rgba(0,0,0,.28); font-weight: 300; }
  .form-input:focus { border-bottom-color: var(--accent-2); box-shadow: none !important; }

  .input-icon { position: absolute; left: 0; width: 16px; height: 16px; color: rgba(0,0,0,.32); }

  .toggle-password {
    position: absolute; right: 0;
    background: none; border: none;
    color: rgba(0,0,0,.32);
    cursor: pointer;
    padding: 4px;
    width: 32px; height: 32px;
    display: flex; align-items: center;
    border-radius: 8px;
  }
  .toggle-password:hover { background: rgba(0,0,0,.04); }
  .toggle-password i { width: 16px; height: 16px; }

  .label-row { display: flex; justify-content: space-between; align-items: center; }
  .forgot-link { font-size: .78rem; color: var(--accent-2); font-weight: 600; }
  .input-hint { font-size: .72rem; color: rgba(0,0,0,.38); margin: 4px 0 0; }

  /* CTA */
  .btn-primary {
    width: 100%;
    padding: 15px;
    background: var(--cta);
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: .88rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    cursor: pointer;
    margin-top: 6px;
    box-shadow: 0 6px 20px rgba(127,160,138,.32);
    transition: transform .15s ease, box-shadow .15s ease;
  }
  .btn-primary:active { transform: scale(.98); box-shadow: 0 3px 10px rgba(127,160,138,.18); }

  /* Divider */
  .divider { margin: 18px 0; }
  .divider::before { background: rgba(0,0,0,.09); }
  .divider-text { font-size: .75rem; color: rgba(0,0,0,.38); background: var(--card); }

  /* Social */
  .social-buttons.one-col { display: flex; flex-direction: column; gap: 10px; }
  .btn-social {
    width: 100%;
    display: flex; align-items: center; justify-content: center;
    gap: 10px;
    padding: 13px;
    background: #fff;
    border: 1.5px solid rgba(0,0,0,.1);
    border-radius: 14px;
    font-size: .88rem; font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s;
  }
  .btn-social:active { border-color: var(--cta); box-shadow: 0 0 0 3px rgba(159,184,154,.2); }

  /* Switch link */
  .switch-link { text-align: center; margin-top: 18px; padding-bottom: 4px; }
  .switch-link p { font-size: .875rem; color: var(--muted); margin: 0; }
  .link-button {
    background: none; border: none;
    color: var(--accent-2);
    font-weight: 800; font-size: .875rem;
    cursor: pointer; padding: 0;
    font-family: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
  }

  /* Checkbox */
  .checkbox-group { display: flex; align-items: flex-start; gap: 10px; }
  .checkbox-group input[type="checkbox"] {
    width: 17px; height: 17px;
    flex-shrink: 0;
    accent-color: var(--accent-2);
    margin-top: 2px;
  }
  .checkbox-label { font-size: .8rem; color: var(--muted); line-height: 1.5; }

  /* Dots */
  .dot { width: 6px; height: 6px; border-radius: 999px; background: rgba(0,0,0,.14); border: none; padding: 0; cursor: pointer; transition: all .3s ease; }
  .dot.active { width: 22px; border-radius: 3px; background: var(--cta-dark); }

  /* Resend */
  #resendVerifyContainer { margin-top: -4px; }

} /* fine @media mobile */


/* ============================================================
   DESKTOP (≥ 1024px)
   ============================================================ */
@media (min-width: 1024px) {
  .auth-container {
    display: flex;            /* Attiva Flexbox */
    align-items: center;      /* Centra verticalmente */
    justify-content: center;   /* Centra orizzontalmente */
    min-height: 100vh;        /* Altezza pari a tutto lo schermo */
    padding: 2rem;            /* Padding di sicurezza */
    box-sizing: border-box;
  }

  .auth-card {
    margin: 0 auto;           /* Sicurezza extra per l'orizzontale */
    max-width: 1120px;
    width: 100%;              /* Permette alla card di restringersi se serve */
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
    border-radius: var(--radius);
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow);
    min-height: 720px;        /* Altezza fissa minima desiderata */
    height: auto;
  }
  .toast-container { max-width: 520px; }

  /* ── Left panel ─────────────────────────── */
  .illustration-panel{
    position: relative;
    display: block;
    height: auto;
    overflow: hidden;           /* FIX: impedisce all'immagine di sforare */
    border-radius: 0;
    background: linear-gradient(160deg, var(--cta) 0%, var(--cta-dark) 100%);
  }

  .illustration-stage{
    position: absolute;
    inset: 0;
    overflow: hidden;
  }

  /* Immagine dryad — centrata e responsive */
  .illustration-img{
    position: absolute;
    left: 50%;                  /* FIX: era 280px fisso, rotto su viewport < 1120px */
    top: 50%;
    bottom: auto;
    width: min(480px, 82%);
    height: auto;
    transform: translate(-50%, -50%);
    opacity: 0;
    pointer-events: none;
    will-change: opacity;
    transition: opacity .4s ease;
    filter: brightness(1.05) contrast(1.05);
    z-index: 2;
  }

  .illustration-img.is-active   { opacity: 0.95; }
  .illustration-img.is-out-left { opacity: 0; }
  .illustration-img.is-in-right { opacity: 0; }

  /* Prato */
  .illustration-prato{
    display: block;
    position: absolute;
    left: 0; right: 0; bottom: 0;
    width: 100%; height: auto;
    opacity: 0.95;
    pointer-events: none;
    filter: brightness(1.03) contrast(1.02);
    z-index: 1;
  }

  /* Rimuovi fade mobile */
  .illustration-panel::after { display: none; }

  /* Modalità narrative: login = tocca terra, register = vola */
  .mode-login    .illustration-login    { top: 62%; }
  .mode-register .illustration-register { top: 40%; }

  /* ── Right panel ────────────────────────── */
  .form-panel { width: 100%; }

  .form-wrapper{
    border: none;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
    padding: 3.1rem 3rem;
    background: var(--card);
  }

  .brand-minimal{
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.6rem;
  }

  .brand-logo-min { width: 70px; height: 70px; }

} /* fine @media desktop */
