/* ============================================================
   Vara GIS — TitleMind.AI
   Dark-theme map UI for Texas land ownership at vara scale
   ============================================================ */

/* --- Design tokens --- */
:root {
  --bg:        #0a0a0f;
  --panel:     #111118;
  --panel-alt: #16161f;
  --accent:    #e94560;
  --success:   #00d48a;
  --text:      #e0e0e8;
  --muted:     #6b7280;
  --border:    #1e1e2e;
  --radius:    10px;
  --blur:      12px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* --- Loading overlay --- */
#loading-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
#loading-overlay.hidden {
  opacity: 0; visibility: hidden; pointer-events: none;
}
.loading-content { text-align: center; }
.loading-spinner {
  width: 40px; height: 40px; margin: 0 auto 20px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-brand {
  font-size: 28px; font-weight: 700; letter-spacing: -0.5px;
  color: var(--text);
}
.loading-brand::after {
  content: ''; /* no dot here, handled in HTML */
}
.loading-sub {
  font-size: 13px; color: var(--muted); margin-top: 4px;
  letter-spacing: 2px; text-transform: uppercase;
}

/* --- Toast notifications --- */
#toast-container {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 10000; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 10px 20px; border-radius: 6px;
  font-size: 13px; font-weight: 500;
  background: var(--panel);
  border: 1px solid var(--border);
  backdrop-filter: blur(var(--blur));
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 3.7s forwards;
}
.toast.error { border-color: var(--accent); color: var(--accent); }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.info { border-color: #4a9eff; color: #4a9eff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* --- Map container --- */
#map {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
}
/* Override MapLibre attribution for dark theme */
.maplibregl-ctrl-attrib {
  background: rgba(10, 10, 15, 0.7) !important;
  color: var(--muted) !important;
  font-size: 10px !important;
}
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }
.maplibregl-popup-content {
  background: var(--panel) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  padding: 12px 16px !important;
  font-size: 13px !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6) !important;
}
.maplibregl-popup-tip {
  border-top-color: var(--panel) !important;
}
.maplibregl-popup-close-button {
  color: var(--muted) !important;
  font-size: 18px !important;
  padding: 4px 8px !important;
}

/* --- Logo — top left --- */
#logo {
  position: absolute; top: 16px; left: 16px; z-index: 10;
  padding: 10px 16px;
  background: rgba(17, 17, 24, 0.85);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  user-select: none;
}
.logo-title {
  font-size: 20px; font-weight: 700; letter-spacing: -0.5px;
}
.logo-dot { color: var(--accent); }
.logo-subtitle {
  font-size: 11px; color: var(--muted);
  letter-spacing: 2px; text-transform: uppercase;
  margin-top: 1px;
}

/* --- Search bar — top right --- */
#search-bar {
  position: absolute; top: 16px; right: 16px; z-index: 10;
  display: flex; align-items: center;
  background: rgba(17, 17, 24, 0.85);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 14px;
  width: 280px;
  transition: border-color var(--transition), width var(--transition);
}
#search-bar:focus-within {
  border-color: var(--accent);
  width: 340px;
}
.search-icon { color: var(--muted); flex-shrink: 0; }
#search-input {
  background: none; border: none; outline: none;
  color: var(--text); font-size: 14px;
  padding: 10px 10px;
  width: 100%;
}
#search-input::placeholder { color: var(--muted); }
#search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 260px; overflow-y: auto;
  display: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
#search-results.active { display: block; }
.search-result-item {
  padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  transition: background var(--transition);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--panel-alt); }
.search-result-item .result-id { font-weight: 600; }
.search-result-item .result-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* --- Map controls --- */
#map-controls {
  position: absolute; top: 64px; right: 16px; z-index: 10;
  display: flex; flex-direction: column; gap: 6px;
}
.map-ctrl-btn {
  width: 38px; height: 38px;
  background: rgba(17, 17, 24, 0.85);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), border-color var(--transition);
}
.map-ctrl-btn:hover { background: var(--panel-alt); border-color: var(--muted); }
.map-ctrl-btn.active { border-color: var(--accent); color: var(--accent); }

/* --- Sidebar — right side --- */
#sidebar {
  position: absolute; top: 0; right: 0; bottom: 60px;
  width: 380px; z-index: 10;
  background: rgba(17, 17, 24, 0.92);
  backdrop-filter: blur(16px);
  border-left: 1px solid var(--border);
  transform: translateX(0);
  transition: transform var(--transition);
  display: flex; flex-direction: column;
}
#sidebar.sidebar-closed {
  transform: translateX(100%);
}
#sidebar-toggle {
  position: absolute; top: 50%; left: -32px;
  transform: translateY(-50%);
  width: 32px; height: 56px;
  background: rgba(17, 17, 24, 0.92);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 8px 0 0 8px;
  color: var(--text); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
#sidebar-toggle:hover { background: var(--panel-alt); }
.sidebar-closed #sidebar-toggle svg {
  transform: rotate(180deg);
}
#sidebar-content {
  flex: 1; overflow-y: auto; padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
#sidebar-content::-webkit-scrollbar { width: 6px; }
#sidebar-content::-webkit-scrollbar-track { background: transparent; }
#sidebar-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

#sidebar-placeholder {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%; text-align: center;
  color: var(--muted); gap: 16px;
}
#sidebar-placeholder p { font-size: 14px; line-height: 1.5; }

/* Survey header */
.survey-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.survey-header h2 {
  font-size: 20px; font-weight: 700; line-height: 1.3;
}
.coverage-badge {
  flex-shrink: 0;
  padding: 4px 10px; border-radius: 6px;
  font-size: 13px; font-weight: 700;
  background: rgba(233, 69, 96, 0.15);
  color: var(--accent);
  white-space: nowrap;
}
.coverage-badge.low {
  background: rgba(0, 212, 138, 0.15);
  color: var(--success);
}

/* Survey meta */
.survey-meta {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.survey-meta p {
  font-size: 13px; color: var(--muted); line-height: 1.6;
}
.survey-meta strong { color: var(--text); }

/* Conveyance list */
.conveyance-list-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.conveyance-list-header h3 {
  font-size: 15px; font-weight: 600;
}
.list-controls select {
  background: var(--panel-alt); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 8px; font-size: 12px; cursor: pointer;
  outline: none;
}
.conveyance-list {
  display: flex; flex-direction: column; gap: 8px;
  padding-bottom: 12px;
}

/* Conveyance card */
.conveyance-card {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
}
.conveyance-card:hover {
  border-color: var(--accent);
  transform: translateX(2px);
}
.conveyance-card.active {
  border-color: var(--accent);
  background: rgba(233, 69, 96, 0.06);
}
.card-type {
  font-size: 10px; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--accent); margin-bottom: 6px;
}
.card-parties {
  font-size: 13px; font-weight: 500;
  line-height: 1.4; margin-bottom: 4px;
}
.card-date {
  font-size: 12px; color: var(--muted);
}
.card-doc {
  font-size: 11px; color: var(--muted);
  margin-top: 2px;
}
.card-coverage {
  font-size: 12px; color: var(--success);
  margin-top: 6px; font-weight: 600;
}

/* --- Timeline bar — bottom --- */
#timeline-bar {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 60px; z-index: 10;
  background: rgba(17, 17, 24, 0.92);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}
#timeline-inner {
  display: flex; align-items: center;
  height: 100%; padding: 0 20px; gap: 14px;
}
.timeline-btn {
  width: 36px; height: 36px; flex-shrink: 0;
  background: var(--panel-alt);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), border-color var(--transition);
}
.timeline-btn:hover { border-color: var(--accent); }
.timeline-btn:disabled { opacity: 0.4; cursor: default; }
.timeline-btn:disabled:hover { border-color: var(--border); }
.timeline-date {
  font-size: 13px; font-weight: 600;
  min-width: 90px; text-align: center;
  white-space: nowrap;
  flex-shrink: 0;
}
#timeline-slider-wrap {
  flex: 1; position: relative; height: 36px;
  display: flex; align-items: center;
}
#timeline-sparkline {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none; opacity: 0.6;
}
#timeline-slider {
  width: 100%; position: relative; z-index: 1;
  -webkit-appearance: none; appearance: none;
  height: 4px; background: var(--border);
  border-radius: 2px; outline: none;
  cursor: pointer;
}
#timeline-slider:disabled {
  opacity: 0.4; cursor: default;
}
#timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px;
  background: var(--accent);
  border: 2px solid var(--text);
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 0 8px rgba(233, 69, 96, 0.5);
  transition: transform 0.15s ease;
}
#timeline-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}
#timeline-slider::-moz-range-thumb {
  width: 16px; height: 16px;
  background: var(--accent);
  border: 2px solid var(--text);
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 0 8px rgba(233, 69, 96, 0.5);
}

/* --- Utility --- */
.spinner-inline {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

/* --- Popup content --- */
.popup-type {
  font-size: 10px; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--accent); margin-bottom: 6px;
}
.popup-parties {
  font-size: 13px; font-weight: 500;
  margin-bottom: 4px;
}
.popup-row {
  font-size: 12px; color: var(--muted);
  margin-bottom: 2px;
}

/* --- Scrollbar for sidebar --- */
#sidebar-content {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* --- Responsive adjustments --- */
@media (max-width: 900px) {
  #sidebar {
    width: 320px;
  }
  #search-bar {
    width: 220px;
  }
  #search-bar:focus-within {
    width: 260px;
  }
}
@media (max-width: 600px) {
  #sidebar {
    width: 100%; bottom: 60px;
    border-left: none;
    border-top: 1px solid var(--border);
    top: 50%;
  }
  #sidebar-toggle {
    left: auto; top: -32px; right: 16px;
    transform: none;
    width: 56px; height: 32px;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
  }
  #sidebar-toggle svg {
    transform: rotate(90deg);
  }
  .sidebar-closed #sidebar-toggle svg {
    transform: rotate(-90deg);
  }
  #logo {
    padding: 8px 12px;
  }
  .logo-title { font-size: 16px; }
  #search-bar { width: 180px; }
}
