/* ── VARIABILI KALIMANTAN ───────────────── */
:root {
  --green-dark:  #0d3b2e;
  --green-mid:   #1a5c44;
  --green-light: #e8f5ef;
  --orange:      #e07b1a;
  --orange-light:#fff3e0;
  --gold:        #c9952a;
  --text:        #222;
  --text-soft:   #555;
  --white:       #fff;
  --border:      #d4e8dd;
  --card-shadow: 0 2px 8px rgba(0,0,0,.08);
  --radius:      8px;
  --nav-h:       56px;
  --font:        'Segoe UI', system-ui, sans-serif;
}

/* ── RESET ───────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--text); background: #f7faf8; line-height: 1.6; }
a { color: var(--green-mid); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ── NAVBAR ──────────────────────────────── */
.navbar {
  background: var(--green-dark);
  height: var(--nav-h);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 0;
}
.navbar-brand {
  color: var(--white);
  font-size: 1.1rem;
  font-weight: 700;
  white-space: nowrap;
  margin-right: 2rem;
  display: flex;
  align-items: center;
  gap: .4rem;
  text-decoration: none;
}
.navbar-brand:hover { text-decoration: none; color: var(--gold); }
.navbar-flag { font-size: 1.3rem; }
.nav-links {
  display: flex;
  list-style: none;
  gap: 0;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links li a {
  display: block;
  color: rgba(255,255,255,.8);
  padding: .4rem .8rem;
  font-size: .82rem;
  white-space: nowrap;
  border-radius: 4px;
  transition: background .15s, color .15s;
}
.nav-links li a:hover,
.nav-links li a.active {
  background: var(--green-mid);
  color: var(--white);
  text-decoration: none;
}
.nav-user {
  margin-left: auto;
  color: rgba(255,255,255,.7);
  font-size: .8rem;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: .8rem;
  padding-left: 1rem;
}
.nav-user a { color: var(--gold); font-size: .8rem; }

/* ── CONTAINER ───────────────────────────── */
.container { max-width: 980px; margin: 0 auto; padding: 0 1.2rem; }
.page { padding: 2rem 0 4rem; }

/* ── HERO (home) ─────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 100%);
  color: var(--white);
  padding: 2rem 1.5rem;
  text-align: center;
}
.hero-flag { font-size: 3rem; margin-bottom: .5rem; }
.hero h1  { font-size: 2.2rem; font-weight: 800; margin-bottom: .4rem; }
.hero sub  { font-size: 1.1rem; opacity: .85; }
.hero-meta {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}
.hero-meta-item { text-align: center; }
.hero-meta-item strong { display: block; font-size: 1.5rem; }
.hero-meta-item span   { font-size: .8rem; opacity: .75; }

/* ── SEZIONE ──────────────────────────────── */
.section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--green-light);
}
.section-intro {
  background: var(--green-light);
  border-left: 4px solid var(--green-mid);
  padding: 1rem 1.2rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 1.2rem;
  font-size: .95rem;
}

/* ── INFO & LINK — card in griglia ────────── */
.info-link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.info-link-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--card-shadow);
  background: var(--white);
}
.info-link-icon { font-size: 1.6rem; margin-bottom: .4rem; }
.info-link-title { font-weight: 700; color: var(--green-dark); margin-bottom: .5rem; }
.info-link-body { font-size: .88rem; line-height: 1.7; color: var(--text-soft); white-space: pre-line; }
.info-link-badges { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .8rem; }
.info-link-badge {
  font-size: .72rem;
  background: var(--green-light);
  color: var(--green-dark);
  padding: .25rem .55rem;
  border-radius: 999px;
  font-weight: 600;
}

/* ── TIMELINE — programma giornata (day/index.php) ── */
.timeline { position: relative; padding-left: .5rem; }
.timeline-item { display: flex; gap: 1rem; margin-bottom: 1.1rem; }
.timeline-time {
  flex: 0 0 56px;
  background: var(--green-dark);
  color: var(--white);
  font-weight: 700;
  font-size: .8rem;
  border-radius: 6px;
  padding: .3rem .4rem;
  height: fit-content;
  text-align: center;
}
.timeline-card {
  flex: 1;
  background: var(--green-light);
  border-left: 3px solid var(--green-mid);
  border-radius: 0 8px 8px 0;
  padding: .7rem 1rem;
}
.timeline-title { font-weight: 700; color: var(--green-dark); font-size: .95rem; }
.timeline-desc { font-size: .85rem; color: var(--text-soft); margin-top: .3rem; }
.section-intro a { color: var(--green-mid); font-weight: 600; }

/* ── DAY GRID (home e programma) ────────── */
.day-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}
.day-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  transition: box-shadow .15s, border-color .15s;
  cursor: pointer;
  display: block;
  text-decoration: none;
  color: inherit;
}
.day-card:hover {
  box-shadow: var(--card-shadow);
  border-color: var(--green-mid);
  text-decoration: none;
}
.day-card-header {
  font-size: .78rem;
  font-weight: 700;
  color: var(--green-mid);
  margin-bottom: .3rem;
}
.day-card-title {
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: .4rem;
  line-height: 1.3;
}
.day-card-km {
  font-size: .78rem;
  color: var(--text-soft);
}
.day-card.confirmed { border-left: 3px solid #2e7d32; }
.day-card.open      { border-left: 3px solid var(--orange); }

/* ── BADGE ───────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-ok   { background: #e8f5e9; color: #2e7d32; }
.badge-open { background: #fff3e0; color: #e65100; }
.badge-info { background: #e3f2fd; color: #1565c0; }

/* ── TABELLA ──────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th {
  background: var(--green-dark);
  color: var(--white);
  padding: .6rem 1rem;
  text-align: left;
  font-size: .8rem;
  font-weight: 600;
}
.data-table td { padding: .65rem 1rem; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--green-light); }
.data-table .total-row td { font-weight: 700; background: var(--green-light); }

/* ── GALLERIA ────────────────────────────── */
.gallery-day { margin-bottom: 2.5rem; }
.gallery-day-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: .8rem;
  padding-bottom: .4rem;
  border-bottom: 2px solid var(--border);
}
.slider-wrap {
  position: relative;
  background: #111;
  border-radius: var(--radius);
  overflow: hidden;
}
.slider-img {
  width: 100%;
  height: 320px;
  object-fit: cover;
  display: none;
}
.slider-img.active { display: block; }
.slider-caption {
  background: rgba(0,0,0,.65);
  color: #fff;
  padding: .6rem 1rem;
  font-size: .85rem;
}
.slider-caption strong { color: var(--gold); display: block; }
.slider-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,.45);
  color: #fff;
  border: none;
  padding: .5rem .9rem;
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: 4px;
}
.slider-btn:hover { background: rgba(0,0,0,.7); }
.slider-btn.prev { left: .5rem; }
.slider-btn.next { right: .5rem; }
.slider-counter {
  position: absolute;
  top: .5rem;
  right: .8rem;
  background: rgba(0,0,0,.5);
  color: #fff;
  font-size: .75rem;
  padding: .15rem .5rem;
  border-radius: 99px;
}
.gallery-placeholder {
  width: 100%; height: 220px;
  background: linear-gradient(135deg, var(--green-light), var(--border));
  display: flex; align-items: center; justify-content: center;
  color: var(--text-soft); font-size: .9rem; border-radius: var(--radius);
}

/* ── LOGIN ───────────────────────────────── */
.login-wrap {
  min-height: calc(100vh - var(--nav-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.login-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--card-shadow);
}
.login-logo { text-align: center; margin-bottom: 1.5rem; }
.login-logo .flag { font-size: 3rem; }
.login-logo h2 { color: var(--green-dark); margin-top: .3rem; font-size: 1.2rem; }
.form-group { margin-bottom: 1.2rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .3rem; color: var(--text-soft); }
.form-control {
  width: 100%;
  padding: .65rem .9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .95rem;
  font-family: var(--font);
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--green-mid); }
.btn {
  display: inline-block;
  padding: .65rem 1.4rem;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s;
  font-family: var(--font);
}
.btn-primary { background: var(--green-dark); color: var(--white); width: 100%; }
.btn-primary:hover { background: var(--green-mid); }
.btn-sm { padding: .35rem .8rem; font-size: .8rem; }
.btn-orange { background: var(--orange); color: var(--white); }
.btn-orange:hover { background: #c56a10; }
.alert { padding: .8rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: .9rem; }
.alert-error { background: #fdecea; color: #c62828; border: 1px solid #f5c6c0; }
.alert-ok    { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }

/* ── LINK RAPIDI ─────────────────────────── */
.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-top: 1rem;
}
.quick-links a {
  background: var(--green-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .4rem .9rem;
  font-size: .85rem;
  color: var(--green-dark);
  font-weight: 600;
  transition: background .15s;
}
.quick-links a:hover {
  background: var(--green-mid);
  color: var(--white);
  text-decoration: none;
}

/* ── CONFERMIAMO ─────────────────────────── */
.decision-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1rem;
}
.decision-card.confirmed { border-color: #a5d6a7; background: #f1f8f1; }
.decision-card .dec-day  { font-size: .78rem; color: var(--text-soft); margin-bottom: .3rem; }
.decision-card .dec-text { font-size: .95rem; line-height: 1.5; }
.vote-form { margin-top: .8rem; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.vote-form input[type=text] { flex: 1; min-width: 180px; }

/* ── RESPONSIVE ───────────────────────────── */
@media (max-width: 640px) {
  .hero { padding: 1.5rem 1rem; }
  .hero h1 { font-size: 1.5rem; }
  .day-grid { grid-template-columns: 1fr 1fr; }
  .data-table { font-size: .8rem; }
  .data-table th, .data-table td { padding: .4rem .6rem; }
  .slider-img { height: 220px; }
}

/* ── COSA VEDREMO ────────────────────────── */
.cosavedere-section {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: .7rem;
  margin-bottom: 1rem;
}
.cosavedere-item {
  background: var(--green-light);
  border-radius: 8px;
  padding: .7rem 1rem;
  border-left: 3px solid var(--green-mid);
}
.cosavedere-item strong {
  display: block;
  font-size: .9rem;
  color: var(--green-dark);
  margin-bottom: .2rem;
}
.cosavedere-item span {
  font-size: .82rem;
  color: var(--text-soft);
  line-height: 1.4;
}

/* ── COORDINATE LINKS ───────────────────── */
.coord-link {
  display: inline-block;
  background: var(--green-mid);
  color: #fff !important;
  padding: .1rem .5rem;
  border-radius: 4px;
  font-size: .75rem;
  text-decoration: none !important;
  margin-left: .3rem;
}
.coord-link:hover { background: var(--green-dark) !important; }
.coord { font-family: monospace; font-size: .85rem; }

/* ── MAP CONTAINER FIX ─────────────────── */
#day-map, #overview-map, #home-route-map {
  min-height: 300px;
  background: var(--green-light);
  position: relative;
  z-index: 1;
}
.leaflet-container { z-index: 1 !important; }

/* ── BANDIERA INDONESIA — CSS puro ─────────────────────────────
   Funziona su Chrome, Firefox, Safari, Edge, mobile — senza emoji
   La bandiera indonesiana è esattamente rosso sopra + bianco sotto */
.flag-id {
    display: inline-block;
    width: 1.55em;
    height: 1.05em;
    background: linear-gradient(to bottom, #CE1126 50%, #FFFFFF 50%);
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 2px;
    vertical-align: -0.15em;
    margin-right: 0.2em;
    box-shadow: 0 1px 3px rgba(0,0,0,0.18);
    flex-shrink: 0;
}
/* Hero: bandiera grande nel titolo */
.hero .flag-id,
.hero-flag .flag-id {
    width: 3.2rem;
    height: 2.1rem;
    border-radius: 3px;
    margin: 0 auto .8rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    vertical-align: middle;
    display: block;
}
/* Navbar logo: bandiera piccola */
.logo .flag-id {
    width: 1.4em;
    height: 0.95em;
    vertical-align: -0.12em;
    margin-right: 0.25em;
}

/* ── BANDIERA INDONESIA — SVG inline ── */
img.flag-img {
    height: 1.1em;
    width: 1.65em;
    vertical-align: -0.1em;
    margin-right: 0.25em;
    border-radius: 2px;
    border: 1px solid rgba(0,0,0,0.12);
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
    flex-shrink: 0;
    display: inline;
}
.logo img.flag-img {
    height: 1.2em;
    width: 1.8em;
    vertical-align: -0.12em;
}
.hero-flag img.flag-img {
    height: 3rem;
    width: 4.5rem;
    display: block;
    margin: 0 auto .8rem;
    border-radius: 3px;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

/* Leaflet crea stacking context — navbar deve essere sopra */
.leaflet-container {
    position: relative;
    z-index: 0;
}
/* Admin topbar sticky */
.atop {
    position: sticky !important;
    top: 0 !important;
    z-index: 9999 !important;
}

/* La navbar deve essere SEMPRE sopra qualsiasi elemento Leaflet */
nav, nav *, .site-nav, header > nav,
.navbar, [class*="navbar"] {
    position: sticky;
    top: 0;
    z-index: 100000 !important;
    isolation: auto;
}
/* Blocca i tile Leaflet all'interno del container */
.leaflet-container,
.map-mini,
.map-big,
#home-route-map,
#map-ov,
[id^="map-"] {
    overflow: hidden !important;
    isolation: isolate;
    contain: strict;
}
/* Admin topbar */
.atop { position: sticky; top: 0; z-index: 100000 !important; }

/* ── NAVBAR FISSA (gestita in header.php inline) ── */
/* Le regole nav fixed sono in header.php <style> per bypassare cache CDN */
/* Overflow clip per mappe Leaflet */
.leaflet-container { clip-path: inset(0); }

/* ── MOBILE UX ── min-height 44px per touch targets ── */
@media (max-width: 768px) {
    nav a, .nav-link, .quick-links a, .btn,
    .slider-btn, .day-card, .day-nav-btn,
    input[type=submit], button {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
    }
    /* Quick links griglia su mobile */
    .quick-links { grid-template-columns: 1fr 1fr !important; }
    /* Day grid 2 colonne su mobile */
    .day-grid { grid-template-columns: 1fr 1fr !important; }
    /* Form rows su mobile: 1 colonna */
    .form-row { flex-direction: column; }
    /* Tabelle scrollabili su mobile */
    .data-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    /* Slider immagini più alte su mobile */
    .slider-img { height: 250px !important; }
}
@media (max-width: 480px) {
    .day-grid { grid-template-columns: 1fr !important; }
    .quick-links { grid-template-columns: 1fr !important; }
    .cosavedere-section { grid-template-columns: 1fr !important; }
}
