/* === CSS Custom Properties === */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --accent: #f59e0b;
  --accent-dark: #d97706;
  --success: #10b981;
  --danger: #ef4444;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* === Header === */
#site-header {
  background: var(--gray-900);
  color: white;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow-md);
}

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

.logo {
  font-size: 1.4rem;
  font-weight: 800;
  color: white;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.logo:hover { color: var(--primary-light); }

.logo-card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 46px;
  background: #ef4444;
  border-radius: 5px;
  font-size: 1.3rem;
  color: white;
  font-weight: 900;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  line-height: 1;
  transform: rotate(-8deg);
  transition: transform 0.3s ease;
}

.logo:hover .logo-card {
  transform: rotate(8deg);
}

nav { display: flex; gap: 1.5rem; }

.nav-link {
  color: var(--gray-300);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}
.nav-link:hover, .nav-link.active { color: white; }

/* === Main App === */
#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-300); }

.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-dark); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 0.35rem 0.9rem; font-size: 0.8rem; }
.btn-full { width: 100%; }

/* === Cards === */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  padding: 1.5rem;
  transition: box-shadow 0.2s, transform 0.2s;
}

.card-clickable:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  cursor: pointer;
}

/* === Hero Section === */
.hero {
  text-align: center;
  padding: 2.5rem 1rem 2rem;
}

.hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 0.5rem;
  letter-spacing: -1px;
}

.hero p {
  color: var(--gray-500);
  font-size: 1.1rem;
  max-width: 500px;
  margin: 0 auto;
}

/* === Search === */
.search-container {
  max-width: 600px;
  margin: 1.5rem auto 2rem;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 0.9rem 1.2rem 0.9rem 3rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: var(--font);
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 1.1rem;
}

/* === Filter Chips === */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 2rem;
}

.chip {
  padding: 0.35rem 0.9rem;
  border-radius: 20px;
  border: 1px solid var(--gray-300);
  background: white;
  color: var(--gray-600);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
}

.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); color: white; border-color: var(--primary); }

/* === Client Cards Grid === */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.client-card { display: flex; flex-direction: column; gap: 0.8rem; }

.client-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.client-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-900);
}

.client-type {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  background: var(--gray-100);
  color: var(--gray-500);
}

.client-type.residential { background: #dbeafe; color: #1d4ed8; }
.client-type.commercial { background: #fef3c7; color: #92400e; }
.client-type.property-management { background: #d1fae5; color: #065f46; }

.client-region {
  font-size: 0.85rem;
  color: var(--gray-500);
}

.location-disclaimer {
  font-size: 0.75rem;
  color: var(--gray-400);
  font-style: italic;
  display: block;
  margin-top: 0.2rem;
}

.client-stats {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
}

.overall-rating {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 700;
  color: var(--gray-800);
}

.review-count { color: var(--gray-400); }

.industry-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.industry-tag {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: var(--gray-100);
  color: var(--gray-500);
}

/* === Stars === */
.stars { display: inline-flex; gap: 1px; }
.star { color: var(--gray-300); font-size: 1rem; }
.star.filled { color: var(--accent); }
.star.half { position: relative; }

.stars-input { display: flex; gap: 2px; cursor: pointer; }
.stars-input .star { font-size: 1.6rem; transition: color 0.15s; cursor: pointer; }
.stars-input .star:hover { color: var(--accent); }

/* === Client Profile === */
.profile-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.profile-header h1 {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--gray-900);
}

.profile-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.profile-layout {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.map-container {
  border-radius: var(--radius);
  overflow: hidden;
  height: 300px;
  border: 1px solid var(--gray-200);
}

.ratings-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.rating-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.rating-label {
  width: 140px;
  font-size: 0.85rem;
  color: var(--gray-600);
  flex-shrink: 0;
}

.rating-bar-bg {
  flex: 1;
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
}

.rating-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.rating-value {
  width: 32px;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gray-700);
}

/* === Reviews List === */
.reviews-section {
  margin-top: 2rem;
}

.reviews-section h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.reviews-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.review-card { }

.review-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}

.worker-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.7rem;
  background: var(--gray-100);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-700);
}

.worker-badge .badge-industry {
  color: var(--gray-400);
  font-weight: 400;
}

.review-date {
  font-size: 0.8rem;
  color: var(--gray-400);
}

.review-ratings-mini {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.mini-rating {
  font-size: 0.75rem;
  color: var(--gray-500);
}

.mini-rating strong {
  color: var(--gray-700);
}

.review-text {
  font-size: 0.9rem;
  color: var(--gray-700);
  line-height: 1.6;
  margin-bottom: 0.6rem;
}

.review-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.helpful-btn {
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  padding: 0.25rem 0.7rem;
  font-size: 0.75rem;
  color: var(--gray-500);
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.2s;
}

.helpful-btn:hover { border-color: var(--primary); color: var(--primary); }
.helpful-btn.voted { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

/* === Review Form === */
.review-form-container {
  max-width: 650px;
  margin: 0 auto;
}

.review-form-container h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.3rem;
}

.review-form-container .subtitle {
  color: var(--gray-500);
  margin-bottom: 2rem;
}

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

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.4rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: var(--font);
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

.rating-input-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  background: var(--gray-50);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}

.rating-input-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-700);
}

.char-count {
  text-align: right;
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 0.3rem;
}

.review-preview {
  margin: 2rem 0;
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.review-preview h3 {
  font-size: 0.85rem;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 1rem;
}

/* === My Reviews === */
.my-reviews h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.3rem;
}

.my-reviews .subtitle {
  color: var(--gray-500);
  margin-bottom: 1.5rem;
}

.my-review-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.my-review-client {
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}

.modal-overlay.hidden { display: none; }

.modal {
  background: white;
  border-radius: var(--radius);
  padding: 2rem;
  width: 90%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
}

.modal h2 {
  font-size: 1.4rem;
  margin-bottom: 0.5rem;
}

.modal p {
  color: var(--gray-500);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-400);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.empty-state h3 {
  color: var(--gray-600);
  margin-bottom: 0.5rem;
}

/* === Add Client Form === */
.add-client-section {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--gray-200);
}

.add-client-section summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
  font-size: 0.9rem;
}

.add-client-form {
  margin-top: 1rem;
  max-width: 500px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--gray-900);
  color: white;
  padding: 0.8rem 1.5rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 3000;
  transition: transform 0.3s ease;
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* === Responsive === */
@media (max-width: 768px) {
  .profile-layout {
    grid-template-columns: 1fr;
  }

  .hero h1 { font-size: 1.6rem; }

  .results-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .header-inner { padding: 0; }
}

/* === Leaflet Overrides === */
.leaflet-container {
  font-family: var(--font);
}

.approx-label {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  font-size: 0.75rem;
  color: var(--gray-500);
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}

/* === Animations === */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.3s ease forwards;
}

/* === Score Colors === */
.score-high { color: var(--success); }
.score-mid { color: var(--accent); }
.score-low { color: var(--danger); }
