/* ==========================================================================
   Food Hygiene Rating Tool - Styles
   ========================================================================== */

/* --------------------------------------------------------------------------
   Tool Container Layout
   -------------------------------------------------------------------------- */
.tool-container {
  display: flex;
  max-height: 700px;
  background-color: var(--bg);
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.tool-sidebar {
  width: 380px;
  background-color: var(--card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.sidebar-content {
  padding: 20px;
}

.sidebar-content label {
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
  margin-top: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.sidebar-content label:first-of-type {
  margin-top: 0;
}

.tool-section {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.tool-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.tool-section h3 {
  font-size: 15px;
  margin-bottom: 16px;
  color: var(--text);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --------------------------------------------------------------------------
   Input Section
   -------------------------------------------------------------------------- */
.input-section {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--card) 100%);
  margin: -20px -20px 24px -20px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.divider {
  display: flex;
  align-items: center;
  margin: 16px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.divider span {
  padding: 0 12px;
}

/* --------------------------------------------------------------------------
   Suggestions Dropdown
   -------------------------------------------------------------------------- */
.input-with-suggestions {
  position: relative;
}

.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.suggestions.show {
  display: block;
}

.suggestions .item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}

.suggestions .item:last-child {
  border-bottom: none;
}

.suggestions .item:hover {
  background: var(--hover-bg);
}

/* --------------------------------------------------------------------------
   Rating Badges
   -------------------------------------------------------------------------- */
.rating-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 1rem;
  color: white;
}

.rating-badge.small {
  width: 24px;
  height: 24px;
  font-size: 0.8rem;
}

.rating-badge.large {
  width: 48px;
  height: 48px;
  font-size: 1.5rem;
}

.rating-5, .rating-badge[data-rating="5"] { background: #22c55e; }
.rating-4, .rating-badge[data-rating="4"] { background: #84cc16; }
.rating-3, .rating-badge[data-rating="3"] { background: #eab308; }
.rating-2, .rating-badge[data-rating="2"] { background: #f97316; }
.rating-1, .rating-badge[data-rating="1"] { background: #ef4444; }
.rating-0, .rating-badge[data-rating="0"] { background: #991b1b; }
.rating-exempt, .rating-badge[data-rating="Exempt"] { background: #6b7280; }
.rating-awaiting, .rating-badge[data-rating="AwaitingInspection"] { background: #6b7280; }

/* --------------------------------------------------------------------------
   Rating Guide in Sidebar
   -------------------------------------------------------------------------- */
.rating-guide {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.rating-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.rating-item .rating-badge {
  width: 24px;
  height: 24px;
  font-size: 0.8rem;
}

.guide-badge {
  height: 24px;
  width: auto;
  flex-shrink: 0;
}

/* Result card rating badge */
.result-rating-badge {
  height: 32px;
  width: auto;
  flex-shrink: 0;
}

/* Map marker badge */
.fhrs-marker {
  height: 28px;
  width: auto;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* Logo marker for chains */
.logo-marker {
  width: 36px;
  height: 36px;
  background: white;
  border-radius: 50%;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

.logo-marker img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  border-radius: 50%;
}

/* Emoji marker for cuisine */
.emoji-marker {
  width: 32px;
  height: 32px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  border: 2px solid white;
}

/* Cuisine tag */
.cuisine-tag {
  display: inline-block;
  background: var(--bg-secondary);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 6px;
  text-transform: capitalize;
}

/* Popup cuisine */
.popup-cuisine {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 4px;
  text-transform: capitalize;
}

.popup-meta {
  font-size: 0.8rem;
  color: #999;
  margin-bottom: 8px;
}

/* --------------------------------------------------------------------------
   Results Summary
   -------------------------------------------------------------------------- */
.results-summary {
  display: flex;
  gap: 12px;
}

.summary-stat {
  flex: 1;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
}

.summary-stat.warning {
  border-color: #f97316;
  background: rgba(249, 115, 22, 0.1);
}

.summary-stat .stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  display: block;
}

.summary-stat.warning .stat-value {
  color: #f97316;
}

.summary-stat .stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --------------------------------------------------------------------------
   Results List
   -------------------------------------------------------------------------- */
.results-section {
  border-bottom: none !important;
  padding-bottom: 0 !important;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
}

.result-card {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.result-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.result-card.highlighted {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.05);
}

.result-card.low-rated {
  border-color: #f97316;
  background: rgba(249, 115, 22, 0.05);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.result-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.chain-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
  background: white;
  padding: 2px;
}

.result-name {
  font-weight: 700;
  color: var(--text);
  font-size: 0.95rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-type {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.result-address {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.result-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.result-distance {
  display: flex;
  align-items: center;
  gap: 4px;
}

.result-date {
  font-size: 0.75rem;
}

.result-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.btn-action {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text);
}

.btn-action:hover {
  background: var(--hover-bg);
}

.btn-action.call {
  background: #22c55e;
  border-color: #22c55e;
  color: white;
}

.btn-action.call:hover {
  background: #16a34a;
}

.btn-action.website {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
}

.btn-action.website:hover {
  background: #2563eb;
}

.btn-action.nav {
  background: #8b5cf6;
  border-color: #8b5cf6;
  color: white;
}

.btn-action.nav:hover {
  background: #7c3aed;
}

.btn-action.share {
  background: var(--bg-secondary);
  color: var(--text);
}

/* Opening hours */
.result-hours {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* Popup buttons */
.popup-btn {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  color: white !important;
  margin-right: 4px;
  margin-bottom: 4px;
}

.popup-btn.call {
  background: #22c55e;
}

.popup-btn.call:hover {
  background: #16a34a;
}

.popup-btn.website {
  background: #3b82f6;
}

.popup-btn.website:hover {
  background: #2563eb;
}

.popup-btn.nav {
  background: #8b5cf6;
}

.popup-btn.nav:hover {
  background: #7c3aed;
}

.popup-phone {
  font-size: 0.85rem;
  color: #22c55e;
  margin-bottom: 4px;
}

/* --------------------------------------------------------------------------
   Loading
   -------------------------------------------------------------------------- */
.loading-indicator {
  text-align: center;
  padding: 40px 20px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-indicator p {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.9rem;
}

/* --------------------------------------------------------------------------
   Data Note
   -------------------------------------------------------------------------- */
.data-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

.data-note a {
  color: var(--primary);
}

/* --------------------------------------------------------------------------
   Button Styles
   -------------------------------------------------------------------------- */
.btn-full {
  width: 100%;
  justify-content: center;
  margin-top: 12px;
}

.btn-icon {
  margin-right: 6px;
}

/* --------------------------------------------------------------------------
   Map Container
   -------------------------------------------------------------------------- */
.map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 500px;
  max-height: 700px;
}

.map {
  width: 100%;
  height: 100%;
  min-height: 500px;
}

/* --------------------------------------------------------------------------
   Mobile FAB
   -------------------------------------------------------------------------- */
.fab {
  display: none;
  width: 56px;
  height: 56px;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 9999;
}

/* --------------------------------------------------------------------------
   Map Markers
   -------------------------------------------------------------------------- */
.hygiene-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 14px;
  color: white;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.hygiene-marker.rating-5 { background: #22c55e; }
.hygiene-marker.rating-4 { background: #84cc16; }
.hygiene-marker.rating-3 { background: #eab308; }
.hygiene-marker.rating-2 { background: #f97316; }
.hygiene-marker.rating-1 { background: #ef4444; }
.hygiene-marker.rating-0 { background: #991b1b; }

/* Map Popup */
.map-popup {
  min-width: 200px;
}

.map-popup .popup-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.map-popup .popup-rating-badge {
  height: 28px;
  width: auto;
  flex-shrink: 0;
}

.map-popup .popup-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.map-popup .popup-type {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 6px;
}

.map-popup .popup-address {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 8px;
}

.map-popup .popup-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.popup-nav-btn {
  display: inline-block;
  padding: 6px 12px;
  background: #22c55e;
  color: white !important;
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
}

.popup-nav-btn:hover {
  background: #16a34a;
}

/* --------------------------------------------------------------------------
   Marker Cluster Overrides
   -------------------------------------------------------------------------- */
.marker-cluster-small {
  background-color: rgba(34, 197, 94, 0.6);
}
.marker-cluster-small div {
  background-color: rgba(34, 197, 94, 0.8);
}

.marker-cluster-medium {
  background-color: rgba(234, 179, 8, 0.6);
}
.marker-cluster-medium div {
  background-color: rgba(234, 179, 8, 0.8);
}

.marker-cluster-large {
  background-color: rgba(239, 68, 68, 0.6);
}
.marker-cluster-large div {
  background-color: rgba(239, 68, 68, 0.8);
}

.marker-cluster {
  background-clip: padding-box;
  border-radius: 20px;
}

.marker-cluster div {
  width: 30px;
  height: 30px;
  margin-left: 5px;
  margin-top: 5px;
  text-align: center;
  border-radius: 15px;
  font: 12px "Helvetica Neue", Arial, Helvetica, sans-serif;
  font-weight: 700;
  color: white;
}

.marker-cluster span {
  line-height: 30px;
}

/* --------------------------------------------------------------------------
   Responsive Design
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .tool-container {
    flex-direction: column;
    max-height: none;
    height: auto;
  }

  .tool-sidebar {
    width: 100%;
    max-height: none;
    overflow-y: visible;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .map-container {
    flex: none;
    height: 400px;
    min-height: 350px;
    max-height: 400px;
  }

  .map {
    min-height: 350px;
    height: 400px;
  }

  .fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 20px;
    right: 20px;
  }

  .results-list {
    max-height: 300px;
  }
}

@media (max-width: 600px) {
  .sidebar-content {
    padding: 16px;
  }

  .input-section {
    margin: -16px -16px 20px -16px;
    padding: 16px;
  }

  .tool-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
  }

  .results-summary {
    flex-wrap: wrap;
  }

  .summary-stat {
    flex: 1 1 30%;
  }

  .result-actions {
    flex-wrap: wrap;
  }

  .btn-action {
    flex: 1 1 45%;
  }
}
