/* ─────────────────────────────────────────────────────────────
   PR Property Scout — clean, professional, touch-friendly
   ───────────────────────────────────────────────────────────── */
:root {
  --bg:        #f4f6f8;
  --surface:   #ffffff;
  --ink:       #16242e;
  --ink-soft:  #5b6b76;
  --line:      #e2e8ed;
  --brand:     #0e7490;   /* teal — ties to Fix Up brand */
  --brand-dk:  #0b5566;
  --danger:    #dc2626;
  --shadow:    0 6px 24px rgba(16, 36, 46, 0.12);

  /* Deal-status palette */
  --s-interested:     #2563eb;  /* blue   */
  --s-contacted:      #0e7490;  /* teal   */
  --s-offer:          #d97706;  /* amber  */
  --s-contract:       #16a34a;  /* green  */
  --s-passed:         #6b7280;  /* gray   */

  --radius: 12px;
  --header-h: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

/* ───────────── Top bar ───────────── */
.topbar {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  position: relative;
  z-index: 1200;
}
.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand-mark { font-size: 20px; }
.brand-text { font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand-sub  { font-size: 12px; opacity: .8; white-space: nowrap; }
@media (max-width: 520px) { .brand-sub { display: none; } }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.count-badge {
  background: rgba(255,255,255,.2);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 600;
  min-width: 28px;
  text-align: center;
}

/* ───────────── Layout ───────────── */
.layout {
  display: flex;
  height: calc(100% - var(--header-h));
  position: relative;
}
.sidebar {
  width: 320px;
  flex: 0 0 320px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: margin-left .25s ease, transform .25s ease;
}
.sidebar.collapsed { margin-left: -320px; }

/* On phones/tablets the sidebar floats OVER the map instead of squeezing it.
   It is HIDDEN by default (pure CSS — no JS required) so the map always gets
   the full screen, and slides in only when the ☰ button adds .open. */
@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    top: 0; bottom: 0; left: 0;
    z-index: 1100;
    width: 86%;
    max-width: 340px;
    flex-basis: auto;
    margin-left: 0;
    box-shadow: var(--shadow);
    transform: translateX(-105%);
  }
  .sidebar.open { transform: translateX(0); }
}

.sidebar-head { padding: 12px; border-bottom: 1px solid var(--line); }
.search {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
}
.search:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14,116,144,.15); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-soft);
}
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.property-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.property-list li {
  padding: 11px 12px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: center;
}
.property-list li:hover, .property-list li.active { background: #eef4f6; }
.pl-thumb {
  width: 44px; height: 44px; border-radius: 8px; object-fit: cover;
  background: var(--line); flex: 0 0 44px;
}
.pl-thumb.placeholder { display: flex; align-items: center; justify-content: center; color: var(--ink-soft); font-size: 18px; }
.pl-body { min-width: 0; flex: 1; }
.pl-addr { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-meta { font-size: 12px; color: var(--ink-soft); margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.status-chip {
  font-size: 11px; font-weight: 600; color: #fff;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}

.empty-state { padding: 24px; color: var(--ink-soft); font-size: 14px; text-align: center; }

/* ───────────── Google Drive sync (sidebar footer) ───────────── */
.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  background: var(--surface);
}
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 8px 10px; font-size: 13px; }
.gdrive-mark { margin-right: 4px; }
.sync-connected { display: flex; flex-direction: column; gap: 8px; }
.sync-account { font-size: 12px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.sync-account::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--s-contract); display: inline-block;
}
.sync-connected-actions { display: flex; gap: 8px; }
.sync-connected-actions .btn { flex: 1; }

/* ───────────── Sync status indicator (map corner) ───────────── */
.sync-status {
  position: absolute;
  bottom: 14px; right: 14px;
  z-index: 600;
  display: flex; align-items: center; gap: 7px;
  background: rgba(255,255,255,.94);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px 6px 10px;
  font-size: 12px; font-weight: 600; color: var(--ink-soft);
  box-shadow: var(--shadow);
  max-width: 70vw;
}
.sync-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sync-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--s-passed); flex: 0 0 10px;
}
.sync-dot.synced  { background: #16a34a; }              /* green  */
.sync-dot.pending { background: #d97706; animation: pulse 1.2s ease-in-out infinite; } /* yellow */
.sync-dot.error   { background: #dc2626; }              /* red    */
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* Keep the indicator clear of Leaflet's bottom-right attribution */
.leaflet-bottom.leaflet-right { margin-bottom: 40px; }

.setup-note { font-size: 13px; color: var(--ink-soft); line-height: 1.5; margin: 0 0 12px; }
.setup-note a { color: var(--brand); }

/* ───────────── Map ───────────── */
.map-wrap { position: relative; flex: 1; }
#map { position: absolute; inset: 0; background: #e8edf0; }
.map-fallback {
  position: absolute; inset: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 24px;
  color: var(--ink-soft); font-size: 15px; line-height: 1.5;
}
.map-hint {
  position: absolute;
  top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(22,36,46,.85); color: #fff;
  padding: 7px 14px; border-radius: 999px;
  font-size: 13px; z-index: 500; pointer-events: none;
  box-shadow: var(--shadow);
}

/* Custom pin markers */
.pin {
  width: 26px; height: 26px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,.35);
}
.pin::after {
  content: ""; position: absolute;
  top: 7px; left: 7px; width: 8px; height: 8px;
  background: #fff; border-radius: 50%;
}

/* ───────────── Buttons ───────────── */
.btn {
  border: none; cursor: pointer;
  padding: 11px 16px; border-radius: 10px;
  font-size: 15px; font-weight: 600;
  min-height: 44px;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dk); }
.btn-ghost { background: transparent; color: inherit; border: 1px solid currentColor; opacity: .9; }
.btn-ghost:hover { opacity: 1; }
.topbar .btn-ghost { border-color: rgba(255,255,255,.5); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.icon-btn {
  background: transparent; border: none; cursor: pointer;
  color: inherit; font-size: 22px; line-height: 1;
  width: 40px; height: 40px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: rgba(0,0,0,.06); }
.topbar .icon-btn:hover { background: rgba(255,255,255,.15); }
.hamburger, .hamburger::before, .hamburger::after {
  display: block; width: 20px; height: 2px; background: currentColor; border-radius: 2px; position: relative;
}
.hamburger::before, .hamburger::after { content: ""; position: absolute; left: 0; }
.hamburger::before { top: -6px; } .hamburger::after { top: 6px; }

/* ───────────── Modal ───────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(16,36,46,.5);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
@media (min-width: 640px) { .modal-overlay { align-items: center; padding: 20px; } }

.modal {
  background: var(--surface);
  width: 100%; max-width: 480px;
  border-radius: 16px 16px 0 0;
  max-height: 92vh; overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slideUp .22s ease;
}
@media (min-width: 640px) { .modal { border-radius: 16px; } }
@keyframes slideUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 8px;
}
.modal-head h2 { margin: 0; font-size: 18px; }

.form { padding: 4px 16px 16px; }
.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field-label small { font-weight: 400; }
.field input[type=text], .field select, .field textarea {
  width: 100%; padding: 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px;
  outline: none; font-family: inherit; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14,116,144,.15);
}
.field textarea { resize: vertical; }

.image-preview { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.image-preview .thumb {
  position: relative; width: 76px; height: 76px;
  border-radius: 10px; overflow: hidden; background: var(--line);
}
.image-preview .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-preview .thumb .rm {
  position: absolute; top: 2px; right: 2px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,.6); color: #fff; border: none;
  cursor: pointer; font-size: 14px; line-height: 1;
}
.upload-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 14px; border: 1.5px dashed var(--brand); color: var(--brand);
  border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px;
}
.upload-btn.disabled { opacity: .4; pointer-events: none; }

.modal-actions { display: flex; align-items: center; gap: 8px; padding-top: 6px; }
.modal-actions .spacer { flex: 1; }

/* ───────────── Popup summary card ───────────── */
.leaflet-popup-content { margin: 0; }
.leaflet-popup-content-wrapper { border-radius: 12px; padding: 0; overflow: hidden; }
.card { width: 240px; }
.card-head { padding: 12px 14px 8px; }
.card-addr { font-weight: 700; font-size: 15px; }
.card-status { display: inline-block; margin-top: 6px; }
.card-notes { padding: 0 14px 10px; font-size: 13px; color: var(--ink-soft); white-space: pre-wrap; }
.card-thumbs { display: flex; gap: 6px; padding: 0 14px 12px; }
.card-thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; cursor: zoom-in; }
.card-actions { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); }
.card-actions .btn { flex: 1; padding: 9px; font-size: 14px; min-height: 40px; }

/* ───────────── Lightbox ───────────── */
.lightbox {
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(0,0,0,.9);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.lightbox-close { position: absolute; top: 12px; right: 12px; color: #fff; font-size: 32px; }

[hidden] { display: none !important; }
