/* ============================================================
   FieldCam — Shared Styles  (mobile-first)
   ============================================================ */

:root {
  --brand:        #61B746;   /* company green */
  --brand-dark:   #52a03a;
  --brand-light:  #edf7e9;
  --surface:      #ffffff;
  --bg:           #f4f5f7;
  --text:         #111827;
  --text-muted:   #6b7280;
  --border:       #e5e7eb;
  --danger:       #ef4444;
  --success:      #22c55e;
  --radius:       12px;
  --shadow:       0 2px 12px rgba(0,0,0,.08);
  --nav-height:   64px;
  --header-height:56px;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding-bottom: var(--nav-height);
}

/* ── Top Header ──────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--brand);
  color: #fff;
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.app-header .logo {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -.5px;
  color: #fff;
  text-decoration: none;
}

.app-header .header-title {
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header .back-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px 4px 0;
  line-height: 1;
}

.app-header .header-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.icon-btn {
  background: rgba(255,255,255,.2);
  border: none;
  border-radius: 8px;
  color: #fff;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.3); }

/* ── Bottom Nav ──────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,.07);
}

.nav-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: .65rem;
  font-weight: 500;
  transition: color .15s;
}

.nav-link .nav-icon { font-size: 1.4rem; line-height: 1; }
.nav-link.active { color: var(--brand); }
.nav-link:hover  { color: var(--brand); }

/* ── Page / Content ──────────────────────────────────────── */
.page { padding: 16px; max-width: 600px; margin: 0 auto; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-body { padding: 16px; }

/* ── Property Card ───────────────────────────────────────── */
.property-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  display: block;
  margin-bottom: 12px;
  transition: transform .15s, box-shadow .15s;
}
.property-card:active { transform: scale(.98); }

.property-thumb {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: var(--bg);
  display: block;
}

.property-thumb-placeholder {
  width: 100%;
  height: 160px;
  background: linear-gradient(135deg, #f0f0f0, #e0e0e0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: #ccc;
}

.property-info { padding: 12px 16px 16px; }
.property-name { font-size: 1rem; font-weight: 700; margin-bottom: 2px; }
.property-address { font-size: .82rem; color: var(--text-muted); }
.property-meta { display: flex; gap: 12px; margin-top: 8px; font-size: .78rem; color: var(--text-muted); }
.property-meta span { display: flex; align-items: center; gap: 4px; }

/* ── Photo Grid ──────────────────────────────────────────── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}

.photo-thumb-wrap {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg);
}

.photo-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .2s;
}
.photo-thumb-wrap:hover img { transform: scale(1.05); }

.photo-thumb-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.35);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 6px;
  font-size: .65rem;
  opacity: 0;
  transition: opacity .2s;
}
.photo-thumb-wrap:hover .photo-thumb-overlay { opacity: 1; }

/* ── Lightbox ────────────────────────────────────────────── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.92);
  z-index: 999;
  flex-direction: column;
  overflow: hidden;  /* children control their own scroll */
}
.lightbox.open { display: flex; }

/* Scrollable top section: photo + meta + actions */
.lb-top {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 0 12px;
  position: relative;
}

.lightbox-img {
  max-width: 100%;
  max-height: 50dvh;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}

.lightbox-meta {
  color: #fff;
  margin-top: 12px;
  font-size: .85rem;
  text-align: center;
  padding: 0 24px;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,.2);
  border: none;
  color: #fff;
  font-size: 1.5rem;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-delete {
  margin-top: 16px;
  background: var(--danger);
  border: none;
  color: #fff;
  padding: 8px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: .9rem;
}

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
  appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(97,183,70,.12);
}
.form-textarea { resize: vertical; min-height: 80px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 24px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background .15s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }

.btn-secondary { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: #eee; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-full { width: 100%; }

/* ── FAB (Floating Action Button) ────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  right: 20px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  border: none;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(97,183,70,.5);
  cursor: pointer;
  text-decoration: none;
  z-index: 90;
  transition: transform .15s, box-shadow .15s;
}
.fab:hover { transform: scale(1.07); box-shadow: 0 6px 20px rgba(97,183,70,.6); }

/* ── Badge ───────────────────────────────────────────────── */
.badge {
  display: inline-block;
  background: var(--brand-light);
  color: var(--brand);
  border-radius: 100px;
  padding: 2px 10px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red   { background: #fee2e2; color: #b91c1c; }

/* ── Nearby Banner ───────────────────────────────────────── */
.nearby-banner {
  background: linear-gradient(135deg, var(--brand), #86d468);
  color: #fff;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.nearby-banner .nearby-icon { font-size: 2rem; }
.nearby-banner .nearby-text strong { font-size: 1rem; display: block; }
.nearby-banner .nearby-text span  { font-size: .8rem; opacity: .9; }

/* ── Section Header ──────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-title { font-size: 1rem; font-weight: 700; }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3.5rem; margin-bottom: 12px; }
.empty-state p { margin-bottom: 20px; }

/* ── Avatar / Team ───────────────────────────────────────── */
.team-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.team-row:last-child { border-bottom: none; }

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.team-info { flex: 1; }
.team-name  { font-weight: 600; font-size: .95rem; }
.team-email { font-size: .8rem; color: var(--text-muted); }

/* ── Camera Page ─────────────────────────────────────────── */
.camera-preview {
  width: 100%;
  aspect-ratio: 4/3;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}
.camera-preview video,
.camera-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

.camera-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 16px 0;
}

.shutter-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--brand);
  border: 4px solid #fff;
  box-shadow: 0 0 0 3px var(--brand);
  cursor: pointer;
  transition: transform .1s;
}
.shutter-btn:active { transform: scale(.93); }

/* ── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #1f2937;
  color: #fff;
  padding: 12px 20px;
  border-radius: 100px;
  font-size: .9rem;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-error   { background: var(--danger); }

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── GPS Pill ────────────────────────────────────────────── */
.gps-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ecfdf5;
  color: #15803d;
  border-radius: 100px;
  padding: 4px 12px;
  font-size: .8rem;
  font-weight: 500;
}
.gps-pill.warn { background: #fef3c7; color: #92400e; }
.gps-pill.err  { background: #fee2e2; color: #b91c1c; }

/* ── Login Page ──────────────────────────────────────────── */
.login-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #edf7e9 0%, #ffffff 100%);
}

.login-logo {
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--brand);
  margin-bottom: 4px;
  letter-spacing: -1px;
}
.login-tagline {
  color: var(--text-muted);
  margin-bottom: 32px;
  font-size: .95rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.1);
  padding: 28px 24px;
}

.tab-row {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 10px;
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ── Search Box ──────────────────────────────────────────── */
.search-box {
  position: relative;
  margin-bottom: 16px;
}
.search-box input {
  padding-left: 40px;
}
.search-box .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* ── Divider ─────────────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: .8rem;
  margin: 16px 0;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Scrollable Photo Row ────────────────────────────────── */
.photo-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}
.photo-row::-webkit-scrollbar { display: none; }
.photo-row-thumb {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  object-fit: cover;
  cursor: pointer;
}

/* ── Desktop Sidebar (≥900px) ────────────────────────────── */

/* These elements live in the sidebar on desktop, hidden on mobile */
.nav-brand        { display: none; }
.nav-spacer       { display: none; }
.nav-signout      { display: none; }
.nav-collapse-btn { display: none; }
.nav-notif-item   { display: none; }

@media (min-width: 900px) {
  :root {
    --sidebar-width: 220px;
    --nav-height: 0px;   /* no bottom bar → all nav-height calculations = 0 */
  }

  /* Body shifts right to make room for sidebar */
  body {
    padding-bottom: 0;
    padding-left: var(--sidebar-width);
  }

  /* ── Sidebar ── */
  .bottom-nav {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    right: auto;
    width: var(--sidebar-width);
    height: 100dvh;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    border-top: none;
    border-right: 1px solid var(--border);
    box-shadow: none;
    padding: 0;
    gap: 2px;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--surface);
    transition: width .22s ease;
  }

  /* Body padding tracks sidebar width */
  body { transition: padding-left .22s ease; }

  /* Logo / brand at top of sidebar */
  .nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--brand);
    letter-spacing: -.5px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
    text-decoration: none;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
  }
  .nav-brand .nav-label { transition: opacity .15s ease; }

  /* Spacer pushes sign-out to bottom */
  .nav-spacer { display: block; flex: 1; }

  /* Sign-out button at bottom of sidebar */
  .nav-signout {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    margin: 0 8px 8px;
    width: calc(100% - 16px);
    font-size: .88rem;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
  }
  .nav-signout:hover { background: #fee2e2; color: var(--danger); }

  /* Nav links as left-aligned rows */
  .nav-link {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 11px 14px;
    font-size: .88rem;
    font-weight: 500;
    border-radius: 10px;
    margin: 0 8px;
    width: calc(100% - 16px);
    white-space: nowrap;
    overflow: hidden;
  }
  .nav-link .nav-icon { font-size: 1.15rem; flex-shrink: 0; }
  .nav-link.active, .nav-link:hover {
    background: var(--brand-light);
    color: var(--brand);
  }

  /* Notification nav item (desktop sidebar only) */
  .nav-notif-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    font-size: .88rem;
    font-weight: 500;
    border-radius: 10px;
    margin: 0 8px;
    width: calc(100% - 16px);
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    flex-shrink: 0;
  }
  .nav-notif-item:hover { background: var(--brand-light); color: var(--brand); }
  .nav-notif-item .nav-icon { font-size: 1.15rem; flex-shrink: 0; }
  .nav-notif-label { flex: 1; }
  .nav-notif-badge {
    background: #FF3B30;
    color: #fff;
    border-radius: 100px;
    padding: 1px 6px;
    font-size: .68rem;
    font-weight: 700;
    flex-shrink: 0;
    transition: opacity .15s;
  }
  .nav-notif-badge.hidden { display: none; }

  /* ── Collapse toggle button ── */
  .nav-collapse-btn {
    position: fixed;
    top: 22px;
    left: calc(var(--sidebar-width) - 12px);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--surface);
    border: 1.5px solid var(--border);
    color: var(--text-muted);
    font-size: .75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    box-shadow: 0 2px 6px rgba(0,0,0,.12);
    transition: left .22s ease, background .15s, color .15s, border-color .15s;
    line-height: 1;
  }
  .nav-collapse-btn:hover {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
  }

  /* ── Collapsed state ── */
  html.sidebar-collapsed { --sidebar-width: 64px; }

  html.sidebar-collapsed .nav-label          { opacity: 0; width: 0; overflow: hidden; }
  html.sidebar-collapsed .nav-brand          { justify-content: center; padding: 20px 0 16px; gap: 0; }
  html.sidebar-collapsed .nav-link           { justify-content: center; padding: 12px 0; width: calc(100% - 8px); margin: 0 4px; gap: 0; }
  html.sidebar-collapsed .nav-link .nav-icon { font-size: 1.3rem; }
  html.sidebar-collapsed .nav-notif-item     { justify-content: center; padding: 12px 0; width: calc(100% - 8px); margin: 0 4px; gap: 0; }
  html.sidebar-collapsed .nav-notif-item .nav-icon { font-size: 1.3rem; }
  html.sidebar-collapsed .nav-notif-label    { display: none; }
  html.sidebar-collapsed .nav-notif-badge    { display: none; }
  html.sidebar-collapsed .nav-signout        { justify-content: center; padding: 12px 0; width: calc(100% - 8px); margin: 0 4px 8px; gap: 0; font-size: 0; }
  html.sidebar-collapsed .nav-signout .nav-icon { font-size: 1.15rem; }

  /* Hide logo from top header — it's in the sidebar now */
  .app-header .logo { display: none; }

  /* Hide header sign-out on desktop — it's in the sidebar */
  .header-signout { display: none; }

  /* Hide header notif bell on desktop — it's in the sidebar */
  .app-header .notif-bell { display: none; }

  /* Wider content area */
  .page { max-width: 1100px; }

  /* Photo grid: 4 columns */
  .photo-grid { grid-template-columns: repeat(4, 1fr); }

  /* Property card list: 2-column grid (dashboard) */
  #properties-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  #properties-list .property-card { margin-bottom: 0; }

  /* FAB — no bottom-nav offset */
  .fab { bottom: 24px; }

  /* Toast — center in the content area (not full viewport) */
  .toast {
    left: calc(var(--sidebar-width) + (100vw - var(--sidebar-width)) / 2);
  }

  /* Bottom sheets — offset left so they don't cover sidebar */
  .sheet-overlay { left: var(--sidebar-width); }
  .sheet         { left: var(--sidebar-width); }

  /* Property card image taller on desktop */
  .property-thumb { height: 200px; }

  /* Smoother hover on cards */
  .property-card:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(0,0,0,.12); }

  /* Map cap height on desktop */
  #map { max-height: 320px; }
}

/* ── Utilities ───────────────────────────────────────────── */
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: .85rem; }
.text-xs    { font-size: .75rem; }
.font-bold  { font-weight: 700; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
