/**
 * GISMart Shared Styles
 * Solo ciò che Tailwind CDN non può generare + classi gm-* riutilizzabili da tutte le dashboard.
 */

/* ---------------------------------------------------------------------------
   Base
   --------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: #172321;
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.14), transparent 28%),
    radial-gradient(circle at 80% 20%, rgba(180, 83, 9, 0.12), transparent 25%),
    linear-gradient(180deg, #f8f3ea 0%, #e1ece8 100%);
  background-attachment: fixed;
}

h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; margin: 0; }
p, .small  { color: #5f6b67; line-height: 1.45; margin: 0; }

/* ---------------------------------------------------------------------------
   Alpine — nascondi elementi x-cloak finché Alpine non inizializza
   --------------------------------------------------------------------------- */
[x-cloak] { display: none !important; }

/* ---------------------------------------------------------------------------
   Scrollbar personalizzata
   --------------------------------------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(15, 118, 110, 0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(15, 118, 110, 0.5); }

/* ---------------------------------------------------------------------------
   Leaflet overrides
   --------------------------------------------------------------------------- */
.leaflet-container { border-radius: 18px; font-family: inherit; }
.leaflet-control-attribution { font-size: 10px; }

/* ---------------------------------------------------------------------------
   gm-shell — contenitore pagina
   --------------------------------------------------------------------------- */
.gm-shell {
  width: min(1500px, calc(100vw - 28px));
  margin: 14px auto 18px;
  display: grid;
  gap: 14px;
}

/* ---------------------------------------------------------------------------
   gm-panel — sezioni principali (vetro, bordo, ombra)
   --------------------------------------------------------------------------- */
.gm-panel {
  background: rgba(255, 251, 245, 0.92);
  border: 1px solid rgba(24, 37, 34, 0.12);
  border-radius: 24px;
  box-shadow: 0 22px 54px rgba(17, 24, 39, 0.14);
  backdrop-filter: blur(10px);
  padding: 20px 24px;
}

/* ---------------------------------------------------------------------------
   gm-card — card interne
   --------------------------------------------------------------------------- */
.gm-card {
  border: 1px solid rgba(24, 37, 34, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  padding: 16px;
  display: grid;
  gap: 10px;
  align-content: start;
}

/* ---------------------------------------------------------------------------
   gm-btn — bottoni azione
   --------------------------------------------------------------------------- */
.gm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 10px 16px;
  border-radius: 14px;
  border: none;
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  background: #0f766e;
  color: white;
  text-decoration: none;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.gm-btn:hover:not(:disabled) { opacity: 0.85; }
.gm-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.gm-btn-full { width: 100%; }
.gm-btn-sec   { background: #334155; }
.gm-btn-danger{ background: #b91c1c; }
.gm-btn-sm    { min-height: 34px; padding: 6px 12px; font-size: 0.8rem; }

/* ---------------------------------------------------------------------------
   gm-input, gm-select, gm-label — form elements
   --------------------------------------------------------------------------- */
.gm-input,
.gm-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(24, 37, 34, 0.12);
  font: inherit;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.86);
  color: #172321;
  transition: border-color 0.15s;
}
.gm-input:focus,
.gm-select:focus { outline: none; border-color: #0f766e; }

.gm-label {
  display: block;
  margin-bottom: 6px;
  color: #5f6b67;
  font-size: 0.86rem;
}

/* ---------------------------------------------------------------------------
   gm-metric — valori KPI grandi
   --------------------------------------------------------------------------- */
.gm-metric {
  font-size: 2rem;
  font-family: Georgia, "Times New Roman", serif;
  color: #172321;
  line-height: 1;
}

/* ---------------------------------------------------------------------------
   gm-console — area log/codice scura
   --------------------------------------------------------------------------- */
.gm-console {
  padding: 14px 16px;
  background: rgba(17, 26, 34, 0.95);
  color: #d1fae5;
  font-family: Consolas, "Courier New", monospace;
  white-space: pre-wrap;
  min-height: 120px;
  font-size: 0.82rem;
  border-radius: 20px;
  border: 1px solid rgba(24, 37, 34, 0.12);
  box-shadow: 0 22px 54px rgba(17, 24, 39, 0.14);
}

/* ---------------------------------------------------------------------------
   gm-map — contenitore mappa Leaflet
   --------------------------------------------------------------------------- */
.gm-map {
  min-height: 520px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(24, 37, 34, 0.12);
}

/* ---------------------------------------------------------------------------
   gm-tag — badge di stato
   --------------------------------------------------------------------------- */
.gm-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  background: rgba(15, 118, 110, 0.1);
  color: #0f766e;
}
.gm-tag-ok   { background: rgba(21, 128, 61, 0.1);  color: #15803d; }
.gm-tag-warn { background: rgba(180, 83, 9, 0.12);  color: #b45309; }
.gm-tag-bad  { background: rgba(185, 28, 28, 0.1);  color: #b91c1c; }

/* ---------------------------------------------------------------------------
   gm-eyebrow — label sopra titolo
   --------------------------------------------------------------------------- */
.gm-eyebrow {
  display: inline-flex;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  color: #0f766e;
  font-size: 0.88rem;
  margin-bottom: 12px;
}

/* ---------------------------------------------------------------------------
   Griglia responsiva — layout comuni
   --------------------------------------------------------------------------- */
.gm-grid2,
.gm-grid3,
.gm-grid4,
.gm-map-layout,
.gm-hero-layout { display: grid; gap: 14px; }

.gm-grid2      { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gm-grid3      { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gm-grid4      { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.gm-map-layout { grid-template-columns: 1.5fr 1fr; align-items: start; }
.gm-hero-layout{ grid-template-columns: 1.3fr 1fr; align-items: start; }

@media (max-width: 1180px) {
  .gm-grid4, .gm-map-layout, .gm-hero-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gm-grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .gm-grid2, .gm-grid3, .gm-grid4, .gm-map-layout, .gm-hero-layout { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------------------
   Spinner — stato caricamento bottoni
   --------------------------------------------------------------------------- */
.gm-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: gm-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes gm-spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------------------
   Link nav stile bottone — usati nelle sezioni hero
   --------------------------------------------------------------------------- */
.gm-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 14px;
  text-decoration: none;
  color: white;
  background: #334155;
  font-size: 0.875rem;
  transition: opacity 0.15s;
}
.gm-link:hover { opacity: 0.85; }
.gm-link-primary { background: #0f766e; }

/* ---------------------------------------------------------------------------
   Auth/warn box — blocchi informativi colorati
   --------------------------------------------------------------------------- */
.gm-auth-box {
  border-left: 3px solid #0f766e;
  padding: 12px 16px;
  background: rgba(15, 118, 110, 0.06);
  border-radius: 0 12px 12px 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #172321;
}
.gm-warn-box {
  border-left: 3px solid #b45309;
  padding: 12px 16px;
  background: rgba(180, 83, 9, 0.07);
  border-radius: 0 12px 12px 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #172321;
}

/* ---------------------------------------------------------------------------
   Tabella endpoint — developer portal
   --------------------------------------------------------------------------- */
.gm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.gm-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid rgba(24, 37, 34, 0.12);
  color: #5f6b67;
  font-weight: 600;
}
.gm-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(24, 37, 34, 0.12);
  vertical-align: top;
}
.gm-table tr:last-child td { border-bottom: none; }

code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.85em;
  background: rgba(15, 118, 110, 0.08);
  padding: 1px 5px;
  border-radius: 5px;
}

/* ---------------------------------------------------------------------------
   Checkbox toggle row — logistica e altri
   --------------------------------------------------------------------------- */
.gm-toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.gm-toggle-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #172321;
  font-size: 0.9rem;
  cursor: pointer;
}
.gm-toggle-row input[type="checkbox"] { width: auto; cursor: pointer; }

/* ---------------------------------------------------------------------------
   Legend dot — mappa
   --------------------------------------------------------------------------- */
.gm-legend { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.gm-legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 0.88rem; color: #5f6b67; }
.gm-legend-dot { width: 12px; height: 12px; border-radius: 999px; display: inline-block; flex-shrink: 0; }
