*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html, body { height: 100%; font-family: var(--font); background: var(--bg); color: var(--text); }

/* Login */
#login-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e293b, #0f172a); z-index: 1000;
}
.login-card {
  background: var(--surface); border-radius: 12px; padding: 40px; width: 380px;
  text-align: center; box-shadow: var(--shadow-lg);
}
.login-logo { font-size: 48px; margin-bottom: 8px; }
.login-card h1 { font-size: 28px; font-weight: 700; margin-bottom: 4px; }
.login-subtitle { color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }
#login-form { display: flex; flex-direction: column; gap: 12px; }
#login-form input {
  padding: 12px 16px; border: 2px solid var(--border); border-radius: var(--radius);
  font-size: 16px; text-align: center; letter-spacing: 2px; outline: none; transition: border-color 0.2s;
}
#login-form input:focus { border-color: var(--primary); }
#login-form button {
  padding: 12px; border: none; border-radius: var(--radius); background: var(--primary);
  color: #fff; font-size: 16px; font-weight: 600; cursor: pointer; transition: background 0.2s;
}
#login-form button:hover { background: var(--primary-hover); }
.login-error { color: var(--danger); font-size: 14px; margin-top: 12px; min-height: 20px; }

/* App Layout */
#app { display: flex; flex-direction: column; height: 100vh; }

/* Top Bar */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow); z-index: 10; flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-logo { font-size: 22px; }
.topbar-title { font-size: 18px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user { font-size: 14px; color: var(--text-secondary); }
.topbar-center { flex: 1; display: flex; justify-content: center; }

/* Main Content */
#main-content { display: flex; flex: 1; overflow: hidden; }
#map-container { flex: 1; position: relative; display: flex; flex-direction: column; }
#map { flex: 1; }

/* Stats Bar */
#stats-bar {
  display: flex; gap: 2px; padding: 8px 16px; background: var(--surface);
  border-top: 1px solid var(--border); flex-shrink: 0;
}
.stat-item {
  display: flex; flex-direction: column; align-items: center; padding: 4px 16px;
  border-right: 1px solid var(--border); gap: 2px;
}
.stat-item:last-child { border-right: none; }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--text-secondary); }
.stat-value { font-size: 20px; font-weight: 700; }
.stat-scope-5 .stat-value { color: #22c55e; }
.stat-scope-4 .stat-value { color: #10b981; }
.stat-scope-3 .stat-value { color: #f59e0b; }
.stat-scope-2 .stat-value { color: #f97316; }
.stat-scope-1 .stat-value { color: #ef4444; }
.stat-contacted .stat-value { color: var(--primary); }

/* Side Panel */
#side-panel {
  width: 380px; background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto; flex-shrink: 0;
  transition: margin-right 0.3s ease;
}
#side-panel.hidden { margin-right: -380px; }
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.panel-header h2 { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.field input, .field textarea, .field select {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; font-family: var(--font); outline: none; transition: border-color 0.2s;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--primary); }
.field textarea { resize: vertical; min-height: 60px; }
.required { color: var(--danger); }
.gym-id { font-size: 11px; color: var(--text-secondary); word-break: break-all; }

/* Star Rating */
.star-rating { display: flex; gap: 4px; }
.star { font-size: 28px; cursor: pointer; color: #d1d5db; transition: color 0.15s; user-select: none; }
.star.active, .star:hover, .star:hover ~ .star { color: #f59e0b; }
.star-rating[data-hover] .star { color: #d1d5db; }
.star-rating[data-hover] .star.active-hover { color: #f59e0b; }
.scope-description { font-size: 12px; color: var(--text-secondary); font-style: italic; }

/* Status Badges */
.status-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.status-badge {
  padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
  cursor: pointer; border: 2px solid var(--border); background: transparent;
  transition: all 0.15s; color: var(--text-secondary);
}
.status-badge:hover { border-color: var(--text); color: var(--text); }
.status-badge.active-new { background: #dbeafe; border-color: #3b82f6; color: #1d4ed8; }
.status-badge.active-contacted { background: #f3e8ff; border-color: #a855f7; color: #7e22ce; }
.status-badge.active-follow_up { background: #fef3c7; border-color: #f59e0b; color: #b45309; }
.status-badge.active-cancelled { background: #f1f5f9; border-color: #64748b; color: #475569; }
.status-badge.active-converted { background: #dcfce7; border-color: #22c55e; color: #15803d; }
.contacted-date { font-size: 12px; color: var(--text-secondary); }

/* Panel Actions */
.panel-actions { padding-top: 8px; border-top: 1px solid var(--border); }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal-content {
  position: relative; background: var(--surface); border-radius: 12px; width: 480px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); z-index: 1;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0; 
}
.modal-header h3 { font-size: 18px; font-weight: 600; }
#add-gym-form { padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 14px; }

/* Buttons */
.btn {
  padding: 8px 16px; border: none; border-radius: var(--radius); font-size: 14px;
  font-weight: 600; cursor: pointer; transition: all 0.15s; font-family: var(--font);
}
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-full { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-outline {
  background: transparent; border: 1px solid var(--border); color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text); }
.btn-close {
  background: none; border: none; font-size: 20px; cursor: pointer;
  color: var(--text-secondary); line-height: 1;
}
.btn-close:hover { color: var(--text); }

/* Info Window replacement with side panel - we style the marker click behavior */
.pac-container { font-family: var(--font); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
