/* ============================================
   COSA MANGIO — Design System
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400&family=DM+Sans:wght@300;400;500&display=swap');

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

:root {
  --cream:        #FAF6EF;
  --terracotta:   #C4603A;
  --terra-light:  #E8845E;
  --terra-dark:   #8C3D1F;
  --basil:        #3D5E3A;
  --basil-light:  #6B9467;
  --warm-brown:   #6B4423;
  --sand:         #E8D5B7;
  --sand-dark:    #C9B090;
  --ink:          #1C1208;
  --muted:        #8A7560;
  --white:        #FFFFFF;

  --radius-sm:    10px;
  --radius-md:    16px;
  --radius-lg:    24px;
  --radius-pill:  40px;

  --shadow-sm:    0 2px 12px rgba(107,68,35,0.06);
  --shadow-md:    0 8px 40px rgba(107,68,35,0.10);
  --shadow-lg:    0 16px 64px rgba(107,68,35,0.13);
}

html { scroll-behavior: smooth; }

body {
  background: var(--cream);
  color: var(--ink);
  font-family: 'DM Sans', sans-serif;
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ── */
h1, h2, h3, h4 { font-family: 'Playfair Display', serif; line-height: 1.1; }
h1 { font-size: clamp(42px, 5.5vw, 72px); font-weight: 700; }
h2 { font-size: clamp(32px, 4vw, 48px); font-weight: 700; }
h3 { font-size: 22px; font-weight: 700; }
em { font-style: italic; color: var(--terracotta); }
a  { color: inherit; text-decoration: none; }

/* ── Layout ── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 48px; }
@media (max-width: 768px) { .container { padding: 0 20px; } }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 14px 24px; border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif; font-size: 14px; font-weight: 500;
  cursor: pointer; border: none; transition: all .2s; text-decoration: none;
}
.btn-primary { background: var(--terracotta); color: white; }
.btn-primary:hover { background: var(--terra-dark); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(196,96,58,0.3); }
.btn-secondary { background: white; color: var(--ink); border: 1.5px solid var(--sand); }
.btn-secondary:hover { border-color: var(--terracotta); color: var(--terracotta); }
.btn-ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--sand); }
.btn-ghost:hover { background: white; color: var(--ink); }
.btn-danger { background: #FCEBEB; color: #A32D2D; border: 1px solid #F7C1C1; }
.btn-danger:hover { background: #F7C1C1; }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Forms ── */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block; font-size: 11px; font-weight: 500;
  letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 8px;
}
.form-input {
  width: 100%; padding: 13px 16px;
  border: 1.5px solid var(--sand); border-radius: var(--radius-sm);
  background: var(--cream); font-family: 'DM Sans', sans-serif;
  font-size: 15px; color: var(--ink); outline: none; transition: .2s;
}
.form-input:focus { border-color: var(--terracotta); background: white; }
.form-input::placeholder { color: var(--sand-dark); }
.form-select {
  width: 100%; padding: 13px 16px;
  border: 1.5px solid var(--sand); border-radius: var(--radius-sm);
  background: var(--cream); font-family: 'DM Sans', sans-serif;
  font-size: 15px; color: var(--ink); outline: none; transition: .2s;
  cursor: pointer; appearance: none;
  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='%238A7560' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.form-select:focus { border-color: var(--terracotta); }

/* ── Cards ── */
.card {
  background: white; border: 1px solid var(--sand);
  border-radius: var(--radius-lg); padding: 32px;
  box-shadow: var(--shadow-md);
}
.card-sm { padding: 20px; border-radius: var(--radius-md); }

/* ── Tags ── */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 14px; border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 400;
}
.tag-eat     { background: #EAF3DE; color: var(--basil); }
.tag-no      { background: #FCEBEB; color: #A32D2D; }
.tag-allergy { background: #FAEEDA; color: #854F0B; }
.tag-neutral { background: var(--cream); color: var(--muted); border: 1px solid var(--sand); }
.tag-removable { cursor: pointer; }
.tag-removable .tag-x { opacity: 0.5; font-size: 11px; margin-left: 2px; }
.tag-removable:hover .tag-x { opacity: 1; }

/* ── Badges ── */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 500; letter-spacing: 0.05em;
}
.badge-green  { background: #EAF3DE; color: var(--basil); }
.badge-red    { background: #FCEBEB; color: #A32D2D; }
.badge-amber  { background: #FAEEDA; color: #854F0B; }

/* ── Nav ── */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 48px;
  background: rgba(250,246,239,0.88); backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(232,213,183,0.6);
}
.nav-logo {
  font-family: 'Playfair Display', serif; font-size: 21px; font-weight: 700;
  color: var(--terracotta); letter-spacing: -0.3px;
  display: flex; align-items: center; gap: 8px;
}
.nav-logo-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--basil); }
.nav-actions { display: flex; align-items: center; gap: 12px; }

/* ── Alert/Toast ── */
.alert {
  padding: 14px 18px; border-radius: var(--radius-sm);
  font-size: 14px; display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
}
.alert-success { background: #EAF3DE; color: var(--basil); border: 1px solid #C0DD97; }
.alert-error   { background: #FCEBEB; color: #A32D2D; border: 1px solid #F7C1C1; }
.alert-info    { background: #E6F1FB; color: #185FA5; border: 1px solid #B5D4F4; }
.alert { display: none; }
.alert.visible { display: flex; }

/* ── Section labels ── */
.section-label {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--terracotta); font-weight: 500; margin-bottom: 14px;
}

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--sand); margin: 24px 0; }

/* ── Loading spinner ── */
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white; animation: spin .7s linear infinite;
  display: none;
}
.spinner.visible { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fadeUp .6s ease both; }
.fade-up-1 { animation-delay: .1s; }
.fade-up-2 { animation-delay: .2s; }
.fade-up-3 { animation-delay: .3s; }
.fade-up-4 { animation-delay: .4s; }
.fade-up-5 { animation-delay: .5s; }

/* ── Utilities ── */
.text-muted   { color: var(--muted); }
.text-center  { text-align: center; }
.text-terra   { color: var(--terracotta); }
.text-basil   { color: var(--basil); }
.mt-8  { margin-top: 8px;  }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-8  { margin-bottom: 8px;  }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.hidden { display: none !important; }

/* ── Language switcher ── */
.lang-switcher {
  display: flex; gap: 2px; align-items: center;
  background: var(--cream); border: 1px solid var(--sand);
  border-radius: var(--radius-pill); padding: 3px;
  overflow-x: auto; scrollbar-width: none; flex-shrink: 0;
}
.lang-switcher::-webkit-scrollbar { display: none; }
.lang-btn {
  padding: 4px 10px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 500; cursor: pointer;
  border: none; background: transparent; flex-shrink: 0;
  color: var(--muted); transition: all .15s; font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
}
.lang-btn.active { background: white; color: var(--ink); box-shadow: 0 1px 4px rgba(107,68,35,.1); }
.lang-btn:hover:not(.active) { color: var(--ink); }
  .nav { padding: 14px 20px; }
  .hide-mobile { display: none; }
}

/* ============================================
   RESPONSIVE — aggiornato per 5 lingue e tutti i device
   Breakpoints: 480px | 640px | 768px | 1024px
   ============================================ */

/* ── NAV — compatto su mobile con lang switcher a 5 lingue ── */
.lang-switcher { flex-wrap: nowrap; }

@media (max-width: 768px) {
  .nav { padding: 12px 16px; gap: 8px; }
  .nav-logo { font-size: 18px; }
  .nav-actions { gap: 6px; }

  /* Nasconde email utente e "Vedi scheda" su mobile */
  .hide-mobile { display: none !important; }

  /* Lang switcher: bottoni più compatti */
  .lang-switcher { gap: 1px; padding: 2px; }
  .lang-btn { padding: 3px 7px; font-size: 11px; }
}

@media (max-width: 480px) {
  .nav { padding: 10px 12px; }
  .nav-logo { font-size: 16px; }
  /* Su mobile molto piccolo, nasconde label testo e mostra solo bandierina */
  .lang-btn { padding: 3px 5px; font-size: 10px; }
}

/* ── INDEX — landing page ── */
@media (max-width: 900px) {
  /* Hero già gestito nel file, ma aggiungiamo dettagli */
  .magic-form { max-width: 100%; }
  .input-row { flex-direction: column; }
  .input-row .btn { width: 100%; justify-content: center; }
  .preview-section { flex-direction: column; padding: 48px 20px; gap: 40px; }
  .card-preview { transform: none !important; max-width: 100%; }
}

@media (max-width: 640px) {
  .features { grid-template-columns: 1fr; }
  .feature { border-right: none; border-bottom: 1px solid var(--sand); }
  .feature:last-child { border-bottom: none; }
  .hero-left { padding: 90px 20px 60px; }
}

/* ── BENVENUTO ── */
@media (max-width: 540px) {
  .welcome-card { padding: 32px 20px; margin: 12px; border-radius: 16px; }
  .welcome-title { font-size: 26px; }
  .allergy-add-row { grid-template-columns: 1fr 1fr; gap: 6px; }
}

/* ── DASHBOARD ── */
@media (max-width: 840px) {
  .dashboard { padding: 24px 16px 100px; }

  /* Tabs: scrollabili orizzontalmente su mobile */
  .section-tabs { overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; border-radius: var(--radius-md) var(--radius-md) 0 0; }
  .section-tabs::-webkit-scrollbar { display: none; }
  .section-tab { min-width: 80px; flex-shrink: 0; padding: 12px 6px; }
  .section-tab .tab-label { font-size: 11px; }
  .section-tab .tab-emoji { font-size: 18px; }

  /* Profile card non sticky su mobile */
  .profile-card { position: static; }

  /* Save bar full width su mobile */
  .save-bar { padding: 12px 16px; }
  .save-bar .save-hint { font-size: 12px; }

  /* Business card modal full screen su mobile */
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal { border-radius: 20px 20px 0 0; max-width: 100%; max-height: 90vh; overflow-y: auto; padding: 24px 20px; }
  #vcard-canvas { max-width: 100%; height: auto; }
}

@media (max-width: 640px) {
  .dash-header h2 { font-size: 22px; }

  /* Categorie pills: più compatte */
  .cat-pills.open { gap: 5px; }
  .pill { padding: 5px 10px; font-size: 12px; }

  /* Sezione body: padding ridotto */
  .section-body { padding: 16px; }
  .recipes-panel { padding: 16px; }

  /* Avatar upload hint nascosto su mobile tiny */
  .avatar-upload-hint { display: none; }

  /* Pro status bar compatta */
  .pro-status-bar { font-size: 11px; padding: 6px 10px; }
}

@media (max-width: 480px) {
  .section-tab { min-width: 64px; padding: 10px 4px; }
  .section-tab .tab-count { display: none; } /* nasconde contatore su piccolo schermo */
  .recipe-item-actions { flex-wrap: wrap; }
  .share-actions { flex-direction: column; }
  .share-actions .btn { width: 100%; justify-content: center; }
}

/* ── SCHEDA PUBBLICA ── */
@media (max-width: 640px) {
  .page-wrap { padding: 20px 14px 56px; }

  /* Hero banner più basso */
  .hero-banner { height: 80px; }
  .avatar-outer { width: 80px; height: 80px; font-size: 28px; margin-top: -40px; }
  .pub-name { font-size: 22px; }

  /* Prefs in colonna unica su mobile */
  .prefs-wrap { grid-template-columns: 1fr; }

  /* Allergie: chip più compatti */
  .a-chip { padding: 6px 11px; font-size: 13px; }

  /* Actions: in colonna */
  .actions-bar { flex-direction: column; align-items: stretch; }
  .actions-bar .spacer { display: none; }
  .actions-bar .btn { width: 100%; justify-content: center; }

  /* Header */
  .pub-header { padding: 11px 16px; }
  .pub-header .create-btn { display: none; } /* nasconde su mobile piccolo */
}

@media (max-width: 400px) {
  .food-list { grid-template-columns: 1fr; } /* già presente ma assicuriamo */
  .pub-meta { flex-direction: column; align-items: flex-start; gap: 4px; }
  .a-chip { font-size: 12px; padding: 5px 9px; }
}

/* ── PRO PAGE ── */
@media (max-width: 640px) {
  .pro-wrap { padding: 32px 16px 60px; }
  .features-card { padding: 20px; }
  .contact-card { padding: 28px 20px; }
  .contact-card h2 { font-size: 20px; }
}

/* ── GLOBAL TOUCH IMPROVEMENTS ── */
@media (hover: none) and (pointer: coarse) {
  /* Touch targets più grandi */
  .btn { min-height: 44px; }
  .pill { min-height: 38px; }
  .lang-btn { min-height: 32px; padding: 5px 10px; }
  .cat-hdr, .section-header, .section-tab { min-height: 48px; }
  .toggle { width: 44px; height: 26px; }
  .toggle-slider::before { width: 22px; height: 22px; }
  .toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

  /* Rimuove hover effects che non hanno senso su touch */
  .cat-hdr:hover { background: var(--cream); }
  .food-cell:hover img { transform: none; }
}

/* ── LANDSCAPE MOBILE ── */
@media (max-width: 768px) and (orientation: landscape) {
  .hero { min-height: auto; }
  .hero-left { padding: 80px 32px 40px; }
  .welcome-card { padding: 24px 28px; }
  .welcome-title { font-size: 24px; }
}

/* ── LARGE SCREENS ── */
@media (min-width: 1400px) {
  .dashboard { max-width: 1200px; }
  .dash-cols { grid-template-columns: 300px 1fr; }
}
