/* ════════════════════════════════════════════════
   PediatrApp — Global CSS
   Palette: bianco latte / azzurro cielo / verde menta / corallo soft
   Font: DM Sans + DM Serif Display
   Mobile-first
════════════════════════════════════════════════ */

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

:root {
  --sky:        #4A90D9;
  --sky-light:  #EBF4FF;
  --sky-mid:    #B8D9F5;
  --mint:       #3DBFA8;
  --mint-light: #E8F8F5;
  --coral:      #F27B6B;
  --coral-light:#FEF0EE;
  --amber:      #F5A623;
  --amber-light:#FFF8EC;
  --ink:        #1A2B3C;
  --ink-mid:    #4A5568;
  --ink-soft:   #718096;
  --border:     #E2EAF0;
  --white:      #FFFFFF;
  --surface:    #F7FAFC;
  --surface2:   #EDF2F7;

  --radius-sm:  8px;
  --radius:     14px;
  --radius-lg:  22px;
  --shadow-sm:  0 1px 3px rgba(74,144,217,0.10), 0 1px 2px rgba(0,0,0,0.06);
  --shadow:     0 4px 16px rgba(74,144,217,0.12), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg:  0 12px 40px rgba(74,144,217,0.18), 0 4px 12px rgba(0,0,0,0.08);

  --font-body:    'DM Sans', sans-serif;
  --font-display: 'DM Serif Display', serif;

  --header-h: 60px;
  --nav-h:    56px;
}

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

html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--surface);
  min-height: 100dvh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--sky-mid); border-radius: 99px; }

/* ── TIPOGRAFIA ── */
h1,h2,h3,h4 { font-family: var(--font-display); line-height: 1.25; color: var(--ink); }
h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); }
h2 { font-size: clamp(1.25rem, 4vw, 1.6rem); }
h3 { font-size: clamp(1rem, 3vw, 1.2rem); }
p  { color: var(--ink-mid); font-size: 0.9375rem; }
small { font-size: 0.8125rem; color: var(--ink-soft); }
a  { color: var(--sky); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── LAYOUT BASE ── */
.app-wrap {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.page-content {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(var(--nav-h) + 24px);
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

/* ── HEADER ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-header .brand-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--sky), var(--mint));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.app-header .brand-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--ink);
  font-style: italic;
}
.app-header .header-right {
  display: flex; align-items: center; gap: 10px;
}
.user-chip {
  display: flex; align-items: center; gap: 7px;
  background: var(--sky-light);
  border: 1.5px solid var(--sky-mid);
  border-radius: 99px;
  padding: 4px 12px 4px 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--sky);
  max-width: 160px;
  overflow: hidden;
  white-space: nowrap;
}
.user-chip .avatar {
  width: 26px; height: 26px;
  background: var(--sky);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}

/* ── BOTTOM NAV ── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--white);
  border-top: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(74,144,217,0.10);
}
.nav-btn {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px;
  background: none; border: none;
  cursor: pointer;
  padding: 6px 0;
  color: var(--ink-soft);
  font-size: 0.65rem;
  font-family: var(--font-body);
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color 0.18s;
  min-height: 44px;
}
.nav-btn .nav-icon {
  font-size: 20px;
  transition: transform 0.18s;
}
.nav-btn.active { color: var(--sky); }
.nav-btn.active .nav-icon { transform: scale(1.15); }
.nav-btn:active .nav-icon { transform: scale(0.9); }

/* ── CARDS ── */
.card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s;
}
.card:hover { box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--ink);
}

/* ── SEZIONI COLORATE ── */
.section-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.75rem; font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-sky   { background: var(--sky-light);   color: var(--sky);   border: 1px solid var(--sky-mid); }
.badge-mint  { background: var(--mint-light);  color: var(--mint);  border: 1px solid #9FE0D5; }
.badge-coral { background: var(--coral-light); color: var(--coral); border: 1px solid #F9BDBA; }
.badge-amber { background: var(--amber-light); color: var(--amber); border: 1px solid #FAD88A; }
.badge-gray  { background: var(--surface2);    color: var(--ink-soft); border: 1px solid var(--border); }

/* ── BOTTONI ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--font-body); font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none; cursor: pointer;
  transition: transform 0.14s, box-shadow 0.14s, background 0.14s;
  min-height: 44px;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--sky); color: white; box-shadow: 0 3px 12px rgba(74,144,217,0.35); }
.btn-primary:hover { background: #3a7ec9; box-shadow: 0 5px 18px rgba(74,144,217,0.45); }
.btn-mint    { background: var(--mint); color: white; box-shadow: 0 3px 12px rgba(61,191,168,0.3); }
.btn-mint:hover { background: #31a893; }
.btn-coral   { background: var(--coral); color: white; box-shadow: 0 3px 12px rgba(242,123,107,0.3); }
.btn-outline  { background: var(--white); color: var(--sky); border: 1.5px solid var(--sky-mid); }
.btn-outline:hover { background: var(--sky-light); }
.btn-ghost   { background: transparent; color: var(--ink-mid); }
.btn-ghost:hover { background: var(--surface2); }
.btn-danger  { background: var(--coral); color: white; }
.btn-sm      { font-size: 0.8125rem; padding: 7px 14px; min-height: 36px; }
.btn-full    { width: 100%; }
.btn-icon    { padding: 10px; min-width: 44px; border-radius: var(--radius-sm); }

/* ── FORMS ── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 0.8125rem; font-weight: 600;
  color: var(--ink-mid);
  margin-bottom: 5px;
  letter-spacing: 0.02em;
}
.form-label .req { color: var(--coral); }
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--ink);
  background: var(--white);
  transition: border-color 0.18s, box-shadow 0.18s;
  min-height: 44px;
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(74,144,217,0.15);
}
.form-control::placeholder { color: var(--ink-soft); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ── LISTE ── */
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--sky-light); }

.list-avatar {
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: white;
}
.avatar-m { background: linear-gradient(135deg, #4A90D9, #3DBFA8); }
.avatar-f { background: linear-gradient(135deg, #F27B6B, #F5A623); }

.list-info { flex: 1; min-width: 0; }
.list-name  { font-weight: 600; font-size: 0.9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-sub   { font-size: 0.8125rem; color: var(--ink-soft); margin-top: 1px; }

/* ── STATS CARDS ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
}
.stat-icon {
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.stat-icon.sky   { background: var(--sky-light); }
.stat-icon.mint  { background: var(--mint-light); }
.stat-icon.coral { background: var(--coral-light); }
.stat-icon.amber { background: var(--amber-light); }
.stat-value { font-family: var(--font-display); font-size: 1.5rem; line-height: 1; color: var(--ink); }
.stat-label { font-size: 0.75rem; color: var(--ink-soft); margin-top: 2px; }

/* ── TABS ── */
.tabs {
  display: flex; gap: 4px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  flex: 1; min-width: max-content;
  padding: 8px 14px;
  border: none; background: none;
  cursor: pointer;
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 0.8125rem; font-weight: 600;
  color: var(--ink-mid);
  transition: all 0.18s;
  white-space: nowrap;
}
.tab-btn.active {
  background: var(--white);
  color: var(--sky);
  box-shadow: var(--shadow-sm);
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(26,43,60,0.5);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.22s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%; max-width: 600px;
  max-height: 92dvh;
  overflow-y: auto;
  padding: 20px 20px 32px;
  transform: translateY(20px);
  transition: transform 0.22s cubic-bezier(0.34,1.3,0.64,1);
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 99px;
  margin: 0 auto 16px;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin-bottom: 18px;
}

/* ── ALERT / TOAST ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 14px;
}
.alert-info    { background: var(--sky-light);   border: 1px solid var(--sky-mid);  color: #1a4a7a; }
.alert-success { background: var(--mint-light);  border: 1px solid #9FE0D5;         color: #1a5a4a; }
.alert-warning { background: var(--amber-light); border: 1px solid #FAD88A;         color: #7a4a00; }
.alert-danger  { background: var(--coral-light); border: 1px solid #F9BDBA;         color: #7a1a1a; }
.alert-icon    { font-size: 16px; flex-shrink: 0; margin-top: 1px; }

.toast-container {
  position: fixed; bottom: calc(var(--nav-h) + 16px);
  left: 50%; transform: translateX(-50%);
  z-index: 600;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px); max-width: 400px;
}
.toast {
  background: var(--ink);
  color: var(--white);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease;
  text-align: center;
}
.toast.success { background: var(--mint); }
.toast.error   { background: var(--coral); }
@keyframes toastIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

/* ── SEZIONE VUOTA ── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 40px 20px; text-align: center; gap: 10px;
  color: var(--ink-soft);
}
.empty-state .empty-icon { font-size: 48px; opacity: 0.5; }
.empty-state p { font-size: 0.875rem; max-width: 240px; }

/* ── CHIP ── */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.75rem; font-weight: 600;
  background: var(--surface2);
  color: var(--ink-mid);
  border: 1px solid var(--border);
}
.chip + .chip { margin-left: 5px; }
.chip-allergia { background: var(--coral-light); color: var(--coral); border-color: #F9BDBA; }
.chip-vaccino  { background: var(--mint-light);  color: var(--mint);  border-color: #9FE0D5; }

/* ── SEPARATORE ── */
.divider {
  height: 1px; background: var(--border);
  margin: 14px 0;
}

/* ── DESKTOP ADATTAMENTO ── */
@media (min-width: 768px) {
  :root { --header-h: 64px; }

  .page-content {
    padding: 24px;
    padding-bottom: 32px;
  }

  .bottom-nav {
    position: static;
    height: auto;
    border-top: none;
    border-bottom: 1.5px solid var(--border);
    border-right: 1.5px solid var(--border);
    flex-direction: column;
    width: 220px;
    padding: 16px 0;
    justify-content: flex-start;
    align-items: stretch;
    box-shadow: none;
  }

  .nav-btn {
    flex: 0;
    flex-direction: row;
    justify-content: flex-start;
    padding: 12px 20px;
    gap: 12px;
    font-size: 0.875rem;
    border-radius: 0;
  }
  .nav-btn .nav-icon { font-size: 18px; }
  .nav-btn.active {
    background: var(--sky-light);
    border-right: 3px solid var(--sky);
    color: var(--sky);
  }

  .app-main {
    display: flex;
    flex: 1;
    overflow: hidden;
  }

  .stats-grid { grid-template-columns: repeat(4, 1fr); }

  .form-row { grid-template-columns: 1fr 1fr; }
  .form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

  .modal-overlay { align-items: center; }
  .modal {
    border-radius: var(--radius-lg);
    max-height: 85dvh;
    margin: 0 16px;
  }
  .modal-handle { display: none; }
}

@media (min-width: 1024px) {
  .bottom-nav { width: 240px; }
}

/* ── PRINT ── */
@media print {
  .app-header, .bottom-nav, .btn, .no-print { display: none !important; }
  .page-content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ── UTILITY ── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.text-sky    { color: var(--sky); }
.text-mint   { color: var(--mint); }
.text-coral  { color: var(--coral); }
.text-amber  { color: var(--amber); }
.text-soft   { color: var(--ink-soft); }
.hidden { display: none !important; }
