/* ─────────────────────────────────────────────────────────────────────────────
   BuroPass iOS — base.css
   Ottimizzato per Safari su iPhone/iPad
   ───────────────────────────────────────────────────────────────────────────── */

/* ── RESET SAFARI-SAFE ──────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  height: -webkit-fill-available;
}

body {
  font-family: -apple-system, 'SF Pro Text', 'SF Pro Display', 'Helvetica Neue', Arial, sans-serif;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

/* ── CSS VARIABLES ──────────────────────────────────────────────────────────── */
:root {
  /* Colors */
  --ink:          #1a1a18;
  --ink2:         #4a4a46;
  --ink3:         #8a8a84;
  --paper:        #f5f2eb;
  --paper2:       #ede9e0;
  --paper3:       #e4dfd4;
  --accent:       #2a6e3f;
  --accent2:      #1d5230;
  --accent-light: #d4ead9;
  --red:          #c23b22;
  --white:        #fdfcf9;

  /* iOS Safe Area */
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);

  /* Navigation */
  --nav-height:    56px;
  --tab-height:    calc(56px + var(--sab));

  /* Touch */
  --touch-min:     44px;

  /* Spacing */
  --page-pad:      1rem;
  --card-radius:   14px;
  --btn-radius:    10px;
}

/* ── SAFE AREA UTILITIES ────────────────────────────────────────────────────── */
.safe-top    { padding-top: var(--sat); }
.safe-bottom { padding-bottom: var(--sab); }
.safe-left   { padding-left: var(--sal); }
.safe-right  { padding-right: var(--sar); }

/* ── TYPOGRAPHY ─────────────────────────────────────────────────────────────── */
h1 { font-size: clamp(1.6rem, 5vw, 2rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
h2 { font-size: clamp(1.2rem, 4vw, 1.5rem); font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
h3 { font-size: 1rem; font-weight: 600; }
p  { font-size: .9375rem; line-height: 1.6; }

/* ── SCROLLING ──────────────────────────────────────────────────────────────── */
.scroll-native {
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.scroll-x {
  -webkit-overflow-scrolling: touch;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.scroll-x::-webkit-scrollbar { display: none; }

/* ── TOUCH TARGETS ──────────────────────────────────────────────────────────── */
.touch-target {
  min-height: var(--touch-min);
  min-width: var(--touch-min);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── BUTTONS ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: var(--touch-min);
  padding: 0 1.25rem;
  border: none;
  border-radius: var(--btn-radius);
  font-family: inherit;
  font-size: .9375rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}
.btn:active { opacity: .75; transform: scale(.97); }

.btn-primary  { background: var(--accent); color: white; }
.btn-secondary{ background: var(--paper2); color: var(--ink); }
.btn-ghost    { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-full     { width: 100%; }
.btn-lg       { min-height: 52px; font-size: 1.0625rem; padding: 0 1.5rem; }

/* ── INPUTS ─────────────────────────────────────────────────────────────────── */
input, select, textarea {
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  font-size: 1rem; /* 1rem prevents iOS zoom on focus */
  border-radius: 10px;
  border: 1.5px solid var(--paper3);
  background: var(--white);
  color: var(--ink);
  outline: none;
  transition: border-color .2s;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--ink3); }

/* ── CARDS ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: .5px solid var(--paper3);
  border-radius: var(--card-radius);
  padding: 1rem;
}

/* ── TOP NAVBAR (sotto status bar) ─────────────────────────────────────────── */
.ios-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: calc(var(--nav-height) + var(--sat));
  padding-top: var(--sat);
  padding-left: calc(1rem + var(--sal));
  padding-right: calc(1rem + var(--sar));
  background: rgba(253,252,249,.92);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: .5px solid var(--paper3);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ios-nav-logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -.01em;
}
.ios-nav-logo span { color: var(--accent); }

/* ── BOTTOM TAB BAR ─────────────────────────────────────────────────────────── */
.tab-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--tab-height);
  padding-bottom: var(--sab);
  background: rgba(253,252,249,.95);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border-top: .5px solid var(--paper3);
  display: flex;
  align-items: flex-start;
  padding-top: 8px;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-decoration: none;
  color: var(--ink3);
  font-size: .625rem;
  font-weight: 500;
  letter-spacing: .02em;
  padding: 2px 0;
  transition: color .15s;
  min-height: var(--touch-min);
  justify-content: center;
}
.tab-item.active { color: var(--accent); }
.tab-icon { font-size: 1.375rem; line-height: 1; }

/* ── PAGE LAYOUT ────────────────────────────────────────────────────────────── */
.page {
  padding-top: calc(var(--nav-height) + var(--sat) + 1rem);
  padding-bottom: calc(var(--tab-height) + 1rem);
  padding-left: calc(var(--page-pad) + var(--sal));
  padding-right: calc(var(--page-pad) + var(--sar));
  min-height: 100vh;
  background: var(--paper);
}

/* ── SECTION LABELS ─────────────────────────────────────────────────────────── */
.sec-label {
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink3);
  margin-bottom: .5rem;
}

/* ── BADGE ──────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: .75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}
.badge-green  { background: var(--accent-light); color: var(--accent2); }
.badge-blue   { background: #e9f5ff; color: #185fa5; }
.badge-amber  { background: #fef9ec; color: #92400e; }
.badge-red    { background: #fef2f2; color: var(--red); }
.badge-gray   { background: var(--paper2); color: var(--ink2); }

/* ── LIST ROWS (stile iOS) ──────────────────────────────────────────────────── */
.list-section { margin-bottom: 1.5rem; }
.list-card { background: var(--white); border-radius: var(--card-radius); overflow: hidden; border: .5px solid var(--paper3); }
.list-row {
  display: flex;
  align-items: center;
  gap: .85rem;
  min-height: var(--touch-min);
  padding: .6rem 1rem;
  border-bottom: .5px solid var(--paper2);
  text-decoration: none;
  color: inherit;
  transition: background .1s;
}
.list-row:last-child { border-bottom: none; }
.list-row:active { background: var(--paper2); }
.list-row-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
.list-row-content { flex: 1; min-width: 0; }
.list-row-title { font-size: .9375rem; font-weight: 500; color: var(--ink); line-height: 1.2; }
.list-row-sub { font-size: .8125rem; color: var(--ink3); margin-top: 1px; }
.list-row-chevron { color: var(--ink3); font-size: .75rem; flex-shrink: 0; }

/* ── HERO CARD ──────────────────────────────────────────────────────────────── */
.hero-card {
  background: var(--accent);
  border-radius: 18px;
  padding: 1.5rem;
  color: white;
  margin-bottom: 1.25rem;
  position: relative;
  overflow: hidden;
}
.hero-card::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 120px; height: 120px;
  background: rgba(255,255,255,.08);
  border-radius: 50%;
}

/* ── PROGRESS RING (iOS style) ──────────────────────────────────────────────── */
.progress-ring { position: relative; width: 52px; height: 52px; flex-shrink: 0; }
.progress-ring svg { transform: rotate(-90deg); }
.progress-ring-bg { fill: none; stroke: rgba(255,255,255,.2); }
.progress-ring-fill { fill: none; stroke: white; stroke-linecap: round; transition: stroke-dashoffset .5s; }
.progress-ring-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; color: white; }

/* ── PULL TO REFRESH (visual only) ─────────────────────────────────────────── */
.ptr-hint { text-align: center; font-size: .8125rem; color: var(--ink3); padding: .75rem 0; }

/* ── SKELETON ───────────────────────────────────────────────────────────────── */
.skel { background: var(--paper2); border-radius: 8px; animation: skel-pulse 1.4s ease infinite; }
@keyframes skel-pulse { 0%,100%{opacity:1} 50%{opacity:.45} }

/* ── MODAL SHEET (iOS bottom sheet) ────────────────────────────────────────── */
.sheet-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  display: none;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.sheet-overlay.open { display: block; }
.sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 201;
  background: var(--white);
  border-radius: 20px 20px 0 0;
  padding: .5rem 1rem calc(1.5rem + var(--sab));
  transform: translateY(100%);
  transition: transform .35s cubic-bezier(.4,0,.2,1);
}
.sheet.open { transform: translateY(0); }
.sheet-handle {
  width: 36px; height: 4px;
  background: var(--paper3);
  border-radius: 2px;
  margin: .5rem auto 1rem;
}

/* ── ANIMATIONS ─────────────────────────────────────────────────────────────── */
@keyframes slide-up { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} }
@keyframes fade-in  { from{opacity:0} to{opacity:1} }
.anim-up  { animation: slide-up .4s ease both; }
.anim-in  { animation: fade-in .3s ease both; }

/* ── DARK MODE ──────────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --ink:          #f0ede6;
    --ink2:         #a8a5a0;
    --ink3:         #6b6b65;
    --paper:        #1a1a18;
    --paper2:       #242420;
    --paper3:       #2e2e2a;
    --accent:       #3d9957;
    --accent2:      #2a6e3f;
    --accent-light: #1a3d24;
    --white:        #222220;
  }
  .ios-nav, .tab-bar {
    background: rgba(26,26,24,.92);
    border-color: rgba(255,255,255,.08);
  }
}

/* ── IPAD LAYOUT ────────────────────────────────────────────────────────────── */
@media (min-width: 768px) {
  :root {
    --page-pad: 2rem;
    --card-radius: 16px;
  }
  .tab-bar { display: none; }
  .ios-nav { height: calc(60px + var(--sat)); }
  .page { padding-top: calc(60px + var(--sat) + 1.5rem); padding-bottom: 2rem; max-width: 768px; margin: 0 auto; }
}
