/* Reset and base styles */
* {
  margin: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: #f9fafb;
  color: #111827;
}

/* Layout container */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
}

/* Header */
header {
  background-color: #1e3a8a;
  color: white;
  padding: 0.9rem 2rem;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1100px;
}

a.logo {
  font-size: 1.5rem;
  font-weight: 800;
  color: white;
  text-decoration: none;
  letter-spacing: -0.02em;
}

header nav {
  display: flex;
  gap: 0.25rem;
  background: none;
  padding: 0;
  margin: 0;
}

header nav a {
  color: rgba(255,255,255,0.85);
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}

header nav a:hover {
  background: rgba(255,255,255,0.15);
  color: white;
  text-decoration: none;
}


/* Main content */
main {
  background-color: #fff;
  padding: 1rem;
  border-radius: 4px;
  min-height: calc(100vh - 200px); /* Ensure main takes up space */
}

/* Hero section (for home page) */
.hero {
  background-color: #eff6ff;
  padding: 4rem 2rem;
  text-align: center;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 800;
}

.hero p {
  margin-top: 0.5rem;
  color: #374151;
}

/* Search bar */
.search-bar {
  margin-top: 2rem;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 0.5rem;
  align-items: stretch;
}

.search-bar input,
.search-bar button {
  padding: 0.8rem;
  border-radius: 0.5rem;
  border: 1px solid #d1d5db;
  font-size: 0.95rem;
  box-sizing: border-box;
}

.search-bar button {
  background-color: #2563eb;
  color: white;
  border: none;
  padding: 0.8rem 1.2rem;
}

.search-bar button:hover {
  background-color: #1e40af;
}

.location-wrapper,
.distanza-wrapper,
.input-wrapper {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex: 1;
  max-width: 320px;
  min-width: 180px;
  min-height: 44px;
}

.location-wrapper {
  max-width: 320px;
}

.geo-button {
  font-size: 1rem;
  background-color: #e5e7eb;
  border: none;
  color: #1f2937;
  border-radius: 0.4rem;
  padding: 0.2rem;
  cursor: pointer;
  width: 100%;
  text-align: center;
  margin-top: 0.3rem;
}

.geo-button:hover {
  background-color: #d1d5db;
}

.error-message {
  color: #dc2626;
  font-size: 0.8rem;
  margin-top: 0.3rem;
  display: none;
  position: absolute;
  background: white;
  padding: 0.2rem;
  border-radius: 0.2rem;
}

/* How it works section */
.how-it-works {
  padding: 3rem 2rem;
  background: white;
  text-align: center;
}

.how-it-works h2 {
  font-size: 1.75rem;
  font-weight: 700;
}

.steps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2rem;
  margin-top: 2rem;
}

.step {
  max-width: 250px;
}

.step-icon {
  font-size: 2rem;
  color: #2563eb;
  margin-bottom: 0.5rem;
}

/* Forms (for login, register, etc.) */
form {
  margin-top: 2rem;
  padding: 1rem;
  background: #f9f9f9;
  border-radius: 8px;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: bold;
  margin-bottom: 0.3rem;
}

.form-group input {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}

form button {
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  background-color: #2563eb;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

form button:hover {
  background-color: #1e40af;
}

/* Table (for results page) */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 2rem;
}

th, td {
  border: 1px solid #ddd;
  padding: 0.75rem;
  text-align: left;
}

th {
  background-color: #f0f0f0;
}

a {
  color: #2563eb;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* === Badge terzile nazionale === */
.tier-badge {
  display: inline-block;
  padding: 4px 10px;
  margin-left: 8px;
  border-radius: 10px;
  font-size: .85rem;
  font-weight: 600;
  border: 1px solid transparent;
  vertical-align: middle;
  white-space: nowrap;
}
.tier-0 { background: #ffe5e5; color: #9b0000; border-color: #ffc2c2; } /* rosso chiaro */
.tier-1 { background: #fff6cc; color: #6b5700; border-color: #ffe380; } /* giallo */
.tier-2 { background: #e6ffe6; color: #075e07; border-color: #a6f3a6; } /* verde */

/* Per celle tabellari con badge, assicura allineamento piacevole */
td { vertical-align: middle; }

/* Footer */
footer {
  background-color: #f3f4f6;
  padding: 1.5rem;
  text-align: center;
  font-size: 0.9rem;
  color: #6b7280;
  margin-top: 2rem;
}

/* Responsive design */
@media (min-width: 768px) {
  .search-bar {
    flex-wrap: nowrap;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
  }
  .input-wrapper,
  .location-wrapper,
  .distanza-wrapper {
    max-width: 320px;
  }
  .search-bar button {
    flex: 0 0 auto;
    max-width: 120px;
  }
}

@media (max-width: 767px) {
  .search-bar {
    flex-wrap: wrap;
  }
  .input-wrapper,
  .location-wrapper,
  .distanza-wrapper {
    max-width: 100%;
    min-width: 100%;
  }
  .search-bar button {
    width: 100%;
  }
  .error-message {
    position: static;
  }
}