/* ============================================================
   Dog Emergency — Stili globali
   Tema scuro (default) + tema chiaro
   ============================================================ */

/* --- Variabili tema scuro --- */
:root {
  --bg:           #1a1a1a;
  --bg2:          #242424;
  --bg3:          #2e2e2e;
  --surface:      #2a2a2a;
  --border:       #3a3a3a;
  --border2:      #444;
  --text:         #f0f0f0;
  --text2:        #aaaaaa;
  --text3:        #666666;
  --accent:       #f5c842;
  --accent-text:  #1a1a1a;
  --success:      #4caf7d;
  --warning:      #f5a623;
  --danger:       #e24b4a;
  --info:         #4a90d9;
  --radius-sm:    8px;
  --radius-md:    12px;
  --radius-lg:    16px;
  --radius-full:  9999px;
  --shadow:       0 2px 8px rgba(0,0,0,0.4);
}

/* --- Variabili tema chiaro --- */
[data-theme="light"] {
  --bg:           #f4f4f2;
  --bg2:          #ffffff;
  --bg3:          #e8e8e5;
  --surface:      #ffffff;
  --border:       #e0e0dc;
  --border2:      #ccccca;
  --text:         #1a1a1a;
  --text2:        #555555;
  --text3:        #999999;
  --accent:       #1a1a1a;
  --accent-text:  #f5c842;
  --success:      #2e7d52;
  --warning:      #c47d10;
  --danger:       #c0392b;
  --info:         #1a6bb5;
  --shadow:       0 2px 8px rgba(0,0,0,0.1);
}

/* --- Reset e base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s, color 0.2s;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Tipografia --- */
h1 { font-size: 22px; font-weight: 600; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }

/* --- Layout --- */
.page {
  flex: 1;
  padding: 16px;
  padding-bottom: 80px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.page-wide {
  flex: 1;
  padding: 16px;
  width: 100%;
}

/* --- Card --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 10px;
}

.card-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
}

/* --- Bottoni --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  width: 100%;
  padding: 14px;
  font-size: 16px;
}

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  width: 100%;
  padding: 14px;
  font-size: 16px;
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border2);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* --- Input --- */
input, textarea, select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 16px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}
input::placeholder, textarea::placeholder {
  color: var(--text3);
}
textarea { resize: none; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 6px;
}

/* --- Chip/toggle buttons --- */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s;
  flex: 1;
  text-align: center;
  min-width: 80px;
}
.chip.attivo {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  font-weight: 600;
}

/* --- Badge stato --- */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  letter-spacing: 0.03em;
}
.badge-nuovo    { background: rgba(245,166,35,0.15);  color: var(--warning); }
.badge-assegnato{ background: rgba(74,144,217,0.15);  color: var(--info); }
.badge-corso    { background: rgba(245,200,66,0.2);   color: var(--accent); }
.badge-chiuso   { background: rgba(76,175,125,0.15);  color: var(--success); }
.badge-annullato{ background: rgba(150,150,150,0.15); color: var(--text3); }

/* --- Header app --- */
.app-header {
  background: var(--accent);
  color: var(--accent-text);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header h1 {
  font-size: 18px;
  font-weight: 700;
}

/* --- Nav bottom --- */
.nav-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  color: var(--text3);
  font-size: 11px;
  cursor: pointer;
  gap: 3px;
  transition: color 0.15s;
  text-decoration: none;
}
.nav-item.active { color: var(--accent); }
[data-theme="light"] .nav-item.active { color: #1a1a1a; }

/* --- Card intervento --- */
.int-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.int-card:active { opacity: 0.8; }
.int-card.mio { border-color: var(--success); border-width: 2px; }
.int-card .comune { font-size: 18px; font-weight: 600; color: var(--text); }
.int-card .indirizzo { font-size: 16px; color: var(--text); margin: 2px 0 6px; }
.int-card .meta { font-size: 13px; color: var(--text2); }
.int-card .footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}

/* --- Counter cards --- */
.counter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.counter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.counter-card .label { font-size: 13px; color: var(--text2); margin-bottom: 4px; }
.counter-card .value { font-size: 30px; font-weight: 700; color: var(--text); line-height: 1; }

/* --- Timeline --- */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; }
.tl-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  margin-top: 3px;
}
.tl-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}
.tl-line { width: 1px; flex: 1; min-height: 24px; background: var(--border); }
.tl-content { padding-bottom: 14px; }
.tl-content .stato { font-size: 15px; color: var(--text); }
.tl-content .meta  { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* --- Lookup dropdown --- */
.lookup-wrap { position: relative; }
.lookup-dd {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  z-index: 200;
  margin-top: 2px;
}
.lookup-dd div {
  padding: 12px 14px;
  font-size: 16px;
  color: var(--text);
  cursor: pointer;
}
.lookup-dd div:hover { background: var(--bg3); }

/* --- Avatar operatore --- */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

/* --- Operatore row --- */
.op-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.op-row:last-child { border-bottom: none; }
.op-info { flex: 1; }
.op-info .nome { font-size: 15px; font-weight: 500; color: var(--text); }
.op-info .stato { font-size: 12px; color: var(--text2); }
.op-dot { width: 8px; height: 8px; border-radius: 50%; }
.op-dot.online  { background: var(--success); }
.op-dot.offline { background: var(--border2); }

/* --- Stepper contatore --- */
.stepper {
  display: flex;
  align-items: center;
  gap: 16px;
}
.stepper-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--bg3);
  border: 1px solid var(--border);
  font-size: 22px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stepper-val {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  min-width: 40px;
  text-align: center;
}

/* --- Toggle tema --- */
.theme-toggle {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

/* --- Toast --- */
#toast-container {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  animation: slideUp 0.2s ease;
  box-shadow: var(--shadow);
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger); }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Sezione vuota --- */
.empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--text3);
  font-size: 15px;
}

/* --- Loading --- */
.loading {
  text-align: center;
  padding: 32px;
  color: var(--text3);
  font-size: 14px;
}

/* --- Mappa placeholder --- */
.mappa-placeholder {
  background: var(--bg3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  font-size: 14px;
}

/* --- Dashboard PC (centro) --- */
@media (min-width: 768px) {
  .dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 16px;
    height: calc(100vh - 56px);
    overflow: hidden;
  }
  .dashboard-lista { overflow-y: auto; padding: 16px; }
  .dashboard-side  { overflow-y: auto; padding: 16px; border-left: 1px solid var(--border); }
  .counter-grid { grid-template-columns: repeat(4, 1fr); }
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* --- Utility --- */
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.flex  { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text2 { color: var(--text2); }
.text3 { color: var(--text3); }
.bold  { font-weight: 600; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
