/* ═══════════════════════════════════════════════
   GUIDAMIVDA — AUTH & PROFILE STYLES  v3
   ═══════════════════════════════════════════════ */

/* ── Scroll lock (iOS + Android) ────────────── */
body.auth-open { overflow: hidden; }

/* ── Overlay ────────────────────────────────── */
.auth-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.52);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
  box-sizing: border-box;
  /* JS sets top + height dynamically on mobile to track visualViewport */
}
.auth-overlay.open { opacity: 1; pointer-events: all; }

/* ── Drag handle (visible only on mobile) ───── */
.auth-drag-handle {
  display: none;
  width: 44px; height: 4px;
  background: #d4d4d4; border-radius: 99px;
  margin: 0 auto 18px;
  cursor: grab;
  flex-shrink: 0;
}

/* ── Modal shell ────────────────────────────── */
.auth-modal {
  background: #fff;
  border-radius: 22px;
  padding: 32px 28px 24px;
  width: min(440px, calc(100vw - 24px));
  max-height: min(90dvh, 700px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 24px 64px rgba(0,0,0,.22), 0 4px 16px rgba(0,0,0,.08);
  position: relative;
  transform: translateY(14px) scale(.97);
  transition: transform .28s cubic-bezier(.34,1.26,.64,1);
  /* no safe-area here – handled by padding below in media queries */
}
.auth-overlay.open .auth-modal {
  transform: translateY(0) scale(1);
}

/* ── Close button ───────────────────────────── */
.auth-close {
  position: absolute; top: 14px; right: 14px;
  background: #f4f7f5; border: none; border-radius: 50%;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #777;
  transition: background .15s, color .15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.auth-close:hover { background: #e0ece6; color: #1b3d28; }

/* ── Header text ────────────────────────────── */
.auth-logo { text-align: center; font-size: 34px; margin-bottom: 10px; }
.auth-title {
  text-align: center; font-size: 19px; font-weight: 800;
  color: #1b3d28; margin: 0 0 5px;
}
.auth-sub {
  text-align: center; font-size: 13px; color: #999;
  margin: 0 0 20px; line-height: 1.5;
}

/* ── Tabs ───────────────────────────────────── */
.auth-tabs {
  display: flex; gap: 4px;
  background: #f3f6f4; border-radius: 11px;
  padding: 4px; margin-bottom: 20px;
}
.auth-tab {
  flex: 1; padding: 10px 6px; border: none; border-radius: 8px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  color: #999; background: transparent; cursor: pointer;
  transition: all .15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 42px;
}
.auth-tab.active {
  background: #fff; color: #1b3d28;
  box-shadow: 0 1px 4px rgba(0,0,0,.10);
}

/* ── Social buttons ─────────────────────────── */
.auth-socials { display: flex; flex-direction: column; gap: 9px; margin-bottom: 16px; }
.auth-social-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 16px; border-radius: 11px; border: 1.5px solid #e2dfd9;
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; background: #fff;
  transition: border-color .15s, background .15s, box-shadow .15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 50px; /* generous touch target */
  width: 100%;
}
.auth-social-btn:hover {
  border-color: #bbb; background: #fafafa;
  box-shadow: 0 2px 8px rgba(0,0,0,.07);
}
.auth-social-btn:active { transform: scale(.98); }
.auth-google { color: #3c4043; }
.auth-facebook { color: #1877F2; }

/* ── Divider ────────────────────────────────── */
.auth-divider {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px; color: #c0bbb5; font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: #e8e4de;
}

/* ── Fields ─────────────────────────────────── */
.auth-field { margin-bottom: 11px; }
.auth-field label {
  display: block; font-size: 12px; font-weight: 600;
  color: #666; margin-bottom: 5px;
}
.auth-field input:not([type="checkbox"]):not([type="radio"]),
.auth-field select {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid #e2dfd9; border-radius: 10px;
  font-family: inherit;
  font-size: 16px;           /* 16px = iOS won't zoom */
  color: #1a1a1a; background: #fafaf8;
  box-sizing: border-box;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.auth-field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 38px;
}
.auth-field input:not([type="checkbox"]):not([type="radio"]):focus,
.auth-field select:focus {
  border-color: #2c5e3f;
  box-shadow: 0 0 0 3px rgba(44,94,63,.10);
  background: #fff;
}

/* Checkbox row */
.auth-field-check { display: flex; align-items: flex-start; gap: 10px; }
.auth-field-check label {
  font-size: 13px; font-weight: 400; color: #666; margin: 0;
  display: flex; align-items: flex-start; gap: 10px;
  cursor: pointer; line-height: 1.5;
  touch-action: manipulation;
}
.auth-field-check input[type="checkbox"] {
  width: 20px; height: 20px; min-width: 20px;
  accent-color: #2c5e3f; cursor: pointer;
  margin-top: 1px; flex-shrink: 0;
  /* ripristina aspetto nativo su tutti i browser */
  -webkit-appearance: checkbox;
  appearance: checkbox;
  border: none; padding: 0; background: none;
  touch-action: manipulation;
}

/* ── Primary button ─────────────────────────── */
.auth-btn-main {
  width: 100%; padding: 14px;
  border: none; border-radius: 12px;
  background: linear-gradient(135deg, #2c5e3f 0%, #1b3d28 100%);
  color: #fff; font-family: inherit; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: opacity .15s, transform .12s;
  margin-bottom: 9px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 50px;
  letter-spacing: .01em;
}
.auth-btn-main:hover { opacity: .88; transform: translateY(-1px); }
.auth-btn-main:active { transform: scale(.98); opacity: 1; }
.auth-btn-main:disabled { opacity: .45; cursor: default; transform: none; }

/* ── Magic link button ──────────────────────── */
.auth-btn-magic {
  width: 100%; padding: 12px;
  border: 1.5px solid #e2dfd9; border-radius: 12px;
  background: #fff; color: #666;
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 46px;
}
.auth-btn-magic:hover { border-color: #2c5e3f; color: #2c5e3f; background: #f3f6f4; }
.auth-btn-magic:active { transform: scale(.98); }

/* ── Feedback message ───────────────────────── */
.auth-message {
  padding: 10px 14px; border-radius: 10px;
  font-size: 13px; font-weight: 500;
  margin-top: 10px; text-align: center; line-height: 1.5;
}
.auth-message.error   { background: #fdecea; color: #c0392b; }
.auth-message.success { background: #e6f4ea; color: #1e7e34; }

/* ── Navbar auth button ─────────────────────── */
.auth-nav-btn {
  display: flex; align-items: center; gap: 5px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.auth-avatar-mini {
  width: 22px; height: 22px; border-radius: 50%; object-fit: cover;
}
.auth-btn-label { font-size: 11px; }

/* ── ❤️ Heart button — visibile SOLO da loggato ─ */
.gvda-heart-btn { display: none; }
body.gvda-logged-in .gvda-heart-btn { display: flex; }

.gvda-heart-btn {
  position: absolute; top: 8px; right: 8px;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,.92); border: none;
  /* display gestito dalle regole sopra (none / flex) */
  align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,.16);
  transition: transform .18s cubic-bezier(.34,1.56,.64,1), background .15s;
  z-index: 5;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}
.gvda-heart-btn::before {
  content: '';
  position: absolute;
  inset: -6px; /* +6px clickable zone around the button */
}
.gvda-heart-btn:hover { transform: scale(1.14); background: #fff; }
.gvda-heart-btn:active { transform: scale(.92); }
.gvda-heart-btn.active { background: #fff0f0; }
.gvda-heart-btn svg { transition: fill .18s, stroke .18s; }
.gvda-heart-btn.active svg { fill: #e74c3c; stroke: #e74c3c; }

/* ════════════════════════════════════════════
   PROFILO
   ════════════════════════════════════════════ */
.profile-modal {
  width: min(520px, calc(100vw - 24px));
  padding: 32px 28px 24px;
}

.profile-loading {
  text-align: center; padding: 40px 20px; color: #999; font-size: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.profile-loading::before {
  content: "";
  display: block;
  width: 32px; height: 32px;
  border: 3px solid #e0e0e0;
  border-top-color: #2d7a4f;
  border-radius: 50%;
  animation: _prof-spin .8s linear infinite;
}
@keyframes _prof-spin { to { transform: rotate(360deg); } }

.profile-header {
  display: flex; align-items: center; gap: 14px;
  padding-bottom: 18px; border-bottom: 1px solid #f0ede8;
  margin-bottom: 18px;
}
.profile-avatar {
  width: 58px; height: 58px; border-radius: 50%; object-fit: cover;
  border: 3px solid #e6efea; flex-shrink: 0;
}
.profile-avatar-placeholder {
  width: 58px; height: 58px; border-radius: 50%;
  background: #e6efea; display: flex; align-items: center;
  justify-content: center; font-size: 26px; flex-shrink: 0;
}
.profile-name  { font-size: 16px; font-weight: 700; color: #1b3d28; }
.profile-email { font-size: 12px; color: #999; margin-top: 2px; word-break: break-all; }
.profile-admin-badge {
  display: inline-block; background: #fff8e1; color: #b8860b;
  font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; margin-top: 5px;
}

/* Profile tabs */
.profile-tabs {
  display: flex; gap: 4px;
  background: #f3f6f4; border-radius: 11px;
  padding: 4px; margin-bottom: 16px;
}
.profile-tab {
  flex: 1; padding: 9px 6px; border: none; border-radius: 8px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  color: #999; background: transparent; cursor: pointer;
  transition: all .15s; display: flex; align-items: center;
  justify-content: center; gap: 5px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 42px;
}
.profile-tab.active {
  background: #fff; color: #1b3d28;
  box-shadow: 0 1px 4px rgba(0,0,0,.10);
}
.profile-count {
  background: #2c5e3f; color: #fff;
  font-size: 10px; padding: 1px 6px; border-radius: 20px;
  font-weight: 700;
}

.profile-empty {
  text-align: center; padding: 28px 16px;
  color: #bbb; font-size: 14px; line-height: 1.7;
}

/* Favorites list */
.profile-fav-grid { display: flex; flex-direction: column; gap: 9px; }
.profile-fav-card {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; background: #fafaf8; border-radius: 11px;
  border: 1px solid #f0ede8;
}
.profile-fav-img {
  width: 50px; height: 50px; border-radius: 8px;
  object-fit: cover; flex-shrink: 0;
}
.profile-fav-img-placeholder {
  width: 50px; height: 50px; border-radius: 8px;
  background: #e6efea; display: flex; align-items: center;
  justify-content: center; font-size: 20px; flex-shrink: 0;
}
.profile-fav-info { flex: 1; min-width: 0; }
.profile-fav-title {
  font-size: 14px; font-weight: 700; color: #1b3d28;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profile-fav-type { font-size: 11px; color: #999; margin-top: 2px; }
.profile-fav-remove {
  background: none; border: none; color: #ccc; font-size: 14px;
  cursor: pointer; border-radius: 50%;
  transition: color .15s; flex-shrink: 0;
  /* 44px touch target */
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation;
}
.profile-fav-remove:hover { color: #e74c3c; }

.profile-form { display: flex; flex-direction: column; gap: 4px; }

.profile-footer {
  margin-top: 18px; padding-top: 16px;
  border-top: 1px solid #f0ede8; text-align: center;
}
.profile-logout-btn {
  background: none; border: 1.5px solid #e2dfd9;
  border-radius: 10px; padding: 10px 24px;
  font-family: inherit; font-size: 13px; color: #999;
  cursor: pointer; transition: all .15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.profile-logout-btn:hover { border-color: #e74c3c; color: #e74c3c; }

/* ════════════════════════════════════════════
   TABLET  481 – 1024px  (centred modal, slightly narrower)
   ════════════════════════════════════════════ */
@media (min-width: 481px) and (max-width: 1024px) {
  .auth-modal   { width: min(420px, calc(100vw - 48px)); padding: 30px 26px 22px; }
  .profile-modal{ width: min(480px, calc(100vw - 48px)); }
  /* Slightly bigger social buttons for finger tapping */
  .auth-social-btn { min-height: 52px; }
}

/* ════════════════════════════════════════════
   MOBILE  ≤ 480px  —  BOTTOM SHEET
   ════════════════════════════════════════════ */
@media (max-width: 480px) {

  /* Overlay anchors to bottom */
  .auth-overlay { align-items: flex-end; }

  /* Show the drag handle */
  .auth-drag-handle { display: block; }

  /* Auth bottom sheet */
  .auth-modal {
    width: 100%;
    border-radius: 22px 22px 0 0;
    /* JS controls top/height via visualViewport;
       CSS only provides the default padding */
    padding: 12px 20px calc(env(safe-area-inset-bottom, 0px) + 24px);
    max-height: 90dvh;
    /* Slide-up animation */
    transform: translateY(60px);
    transition: transform .3s cubic-bezier(.25,.8,.25,1);
  }
  .auth-overlay.open .auth-modal { transform: translateY(0); }

  /* Profile bottom sheet */
  .profile-modal {
    width: 100%;
    border-radius: 22px 22px 0 0;
    padding: 12px 18px calc(env(safe-area-inset-bottom, 0px) + 20px);
    max-height: 90dvh;
    transform: translateY(60px);
    transition: transform .3s cubic-bezier(.25,.8,.25,1);
  }
  .auth-overlay.open .profile-modal { transform: translateY(0); }

  /* Move close button below drag handle */
  .auth-close { top: 12px; right: 14px; }

  /* Hide label next to icon in navbar */
  .auth-btn-label { display: none; }

  /* Bigger tab hit area */
  .auth-tab    { padding: 12px 6px; }
  .profile-tab { padding: 11px 6px; }

  /* Larger primary button */
  .auth-btn-main { min-height: 52px; font-size: 15px; }
}

/* ════════════════════════════════════════════
   HAMBURGER — badge notifica profilo incompleto
   ════════════════════════════════════════════ */
.menu-notif-badge {
  position: absolute;
  top: 6px; right: 6px;
  width: 9px; height: 9px;
  background: #e74c3c;
  border-radius: 50%;
  border: 2px solid #fff;
  pointer-events: none;
}

/* ════════════════════════════════════════════
   AUTH MODAL — password dimenticata
   ════════════════════════════════════════════ */
.auth-forgot-link {
  background: none;
  border: none;
  color: #2c5e3f;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  opacity: 0.8;
  transition: opacity .15s;
}
.auth-forgot-link:hover { opacity: 1; }

/* ════════════════════════════════════════════
   PROFILO — campo email con bottone inline
   ════════════════════════════════════════════ */
.profile-inline-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.profile-inline-row input {
  flex: 1;
  min-width: 0;
}
.profile-inline-btn {
  flex-shrink: 0;
  padding: 10px 14px;
  background: #2c5e3f;
  color: #fff;
  border: none;
  border-radius: 9px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .15s;
  min-height: 44px;
}
.profile-inline-btn:hover { opacity: .85; }
.profile-field-hint {
  font-size: 11px;
  color: #bbb;
  margin-top: 4px;
  line-height: 1.4;
}

/* ════════════════════════════════════════════
   SIDENAV — badge ! e alert profilo incompleto
   ════════════════════════════════════════════ */
.sidenav-notif-dot {
  margin-left: auto;
  width: 20px; height: 20px;
  background: #e74c3c;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidenav-profile-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 12px 4px;
  padding: 9px 12px;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 10px;
  font-size: 12.5px;
  color: #7d5a00;
  font-weight: 500;
  cursor: pointer;
  line-height: 1.4;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s;
}
.sidenav-profile-alert:hover { background: #fff3cd; }

/* ════════════════════════════════════════════
   SIDENAV — user section (injected by updateSideNav)
   ════════════════════════════════════════════ */

/* User info row */
.sidenav-user-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.sidenav-avatar {
  width: 44px; height: 44px;
  border-radius: 50%; object-fit: cover;
  border: 2px solid #e6efea;
  flex-shrink: 0;
}
.sidenav-avatar-placeholder {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #e6efea;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.sidenav-user-name {
  font-size: 14px; font-weight: 700; color: #1b3d28;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidenav-user-email {
  font-size: 11px; color: #aaa; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidenav-admin-badge {
  display: inline-block;
  background: #fff8e1; color: #b8860b;
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px;
  margin-top: 4px;
}

/* Favourites count badge inside item */
.sidenav-count {
  margin-left: auto;
  background: #e74c3c; color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px;
  flex-shrink: 0;
}

/* Heart-tinted item */
.sidenav-item--heart {
  color: #1a1a1a;
}
.sidenav-item--heart:hover { background: #fff0f0; }

/* Logout item */
.sidenav-item--logout { color: #c0392b; }
.sidenav-item--logout:hover { background: #fdecea; }
.sidenav-item--logout svg { opacity: 0.8; }

/* Divider injected inside user section */
.sidenav-divider {
  height: 1px; background: #f0f0f0; margin: 4px 0;
}

/* Login button shown when logged out */
.sidenav-login-btn {
  display: block; width: 100%;
  padding: 13px 16px;
  background: linear-gradient(135deg, #2c5e3f 0%, #1b3d28 100%);
  color: #fff; font-family: inherit; font-size: 14px; font-weight: 700;
  border: none; border-radius: 12px; cursor: pointer;
  text-align: center; letter-spacing: .01em;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: opacity .15s;
  min-height: 48px; margin-bottom: 4px;
}
.sidenav-login-btn:hover { opacity: .88; }
.sidenav-login-btn:active { opacity: 1; transform: scale(.98); }

/* ════════════════════════════════════════════
   LANDSCAPE PHONE  height < 500px
   ════════════════════════════════════════════ */
@media (max-height: 500px) and (max-width: 768px) {
  .auth-overlay { align-items: flex-start; }
  .auth-modal, .profile-modal {
    border-radius: 0 0 20px 20px;
    max-height: 100dvh;
    padding-top: calc(env(safe-area-inset-top, 0px) + 8px);
    transform: translateY(-40px);
  }
  .auth-overlay.open .auth-modal,
  .auth-overlay.open .profile-modal { transform: translateY(0); }
}
