/*
CHANGE LOG
File: /maparea/static/css/draw-sidebar.css
Purpose: Styles for sidebar-based draw tool
Dependencies: None
Version History:
2026-03-16 v2.2.0 - Added address search styles; logo as clickable link
2026-03-15 v2.1.0 - Added Export tab styles (create report, create project)
2026-03-15 v2.0.0 - Layer stack UI: drag handles, opacity sliders, reports controls, AOI mode
2026-03-15 v1.5.0 - Added measurements section styles
2026-03-14 v1.4.0 - Hide default Geoman floating toolbar (use sidebar instead)
2026-03-14 v1.3.0 - Simplified for 15 FREE tools only
2026-03-14 v1.2.0 - Removed advanced toggle styles (all tools visible)
2026-03-14 v1.1.0 - Added basemap toggle styles
2026-03-14 v1.0.0 - Initial creation
*/

:root {
  --sidebar-width: 280px;
  --sidebar-collapsed: 0px;
  --header-height: 44px;
  --iv-green: #166534;
  --iv-green-light: #22c55e;
  --iv-green-dark: #0f4c2a;
  --panel-bg: #f8fafc;
  --border: #e2e8f0;
  --text-primary: #1e293b;
  --text-muted: #64748b;
  --reports-blue: #3388ff;
}

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

/* Hide default Geoman floating toolbar — we use sidebar instead */
.maplibregl-ctrl-top-left .gm-control-container,
.maplibregl-ctrl-top-left .maplibregl-ctrl-group:has(.gm-control-button) {
  display: none !important;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--iv-green-dark);
}

/* AOI selection mode cursor */
body.aoi-mode .maplibregl-canvas { cursor: crosshair !important; }

.header {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--header-height);
  padding: 0 12px;
  background: var(--iv-green);
  border-bottom: 1px solid var(--iv-green-dark);
}

.logo { 
  font-weight: 700; 
  color: white; 
  font-size: 15px; 
  text-decoration: none;
}
.logo:hover { color: rgba(255,255,255,0.85); }
.title { color: rgba(255,255,255,0.85); font-size: 14px; }

/* Address Search */
.address-search {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  max-width: 300px;
  margin-left: 12px;
}
.address-search input {
  flex: 1;
  padding: 5px 10px;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  background: rgba(255,255,255,0.15);
  color: white;
}
.address-search input::placeholder { color: rgba(255,255,255,0.6); }
.address-search input:focus {
  outline: none;
  background: rgba(255,255,255,0.25);
}
.address-search button {
  padding: 5px 8px;
  border: none;
  border-radius: 4px;
  background: var(--iv-green-light);
  color: white;
  font-size: 13px;
  cursor: pointer;
}
.address-search button:hover { background: #16a34a; }
.address-search button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.back-link { margin-left: auto; color: rgba(255,255,255,0.7); font-size: 13px; text-decoration: none; }
.back-link:hover { color: white; }

.container {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--panel-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease;
  position: relative;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .tabs, .sidebar.collapsed .panel { display: none; }

.collapse-btn {
  position: absolute;
  top: 8px;
  right: -24px;
  width: 24px;
  height: 32px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  font-size: 10px;
  color: var(--text-muted);
  z-index: 10;
}

.sidebar.collapsed .collapse-btn { right: -24px; }
.sidebar.collapsed .collapse-btn::after { content: '▶'; }

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1;
  padding: 10px 8px;
  background: transparent;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab.active {
  color: var(--iv-green);
  border-bottom-color: var(--iv-green);
}

.panel { display: none; flex-direction: column; padding: 12px; overflow-y: auto; flex: 1; }
.panel.active { display: flex; }

/* Layer sections */
.layer-section {
  margin-bottom: 16px;
}

.layer-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-style: italic;
}

/* Reports controls */
.reports-controls {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.action-btn {
  flex: 1;
  padding: 8px 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.action-btn:hover {
  border-color: var(--reports-blue);
  color: var(--reports-blue);
}

.action-btn:active {
  background: var(--reports-blue);
  color: white;
}

/* Layer list */
.layer-list { 
  display: flex; 
  flex-direction: column; 
  gap: 4px; 
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.layer-item:hover {
  border-color: #cbd5e1;
}

.layer-item.dragging {
  opacity: 0.8;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  border-color: var(--iv-green);
}

.layer-item.static {
  background: var(--panel-bg);
  border-style: dashed;
}

/* Drag handle */
.drag-handle {
  cursor: grab;
  color: #94a3b8;
  font-size: 14px;
  user-select: none;
  padding: 2px 4px;
}

.drag-handle:hover {
  color: var(--text-primary);
}

.drag-handle:active {
  cursor: grabbing;
}

/* Layer checkbox and label */
.layer-item input[type="checkbox"] { 
  width: 16px; 
  height: 16px; 
  accent-color: var(--iv-green);
  flex-shrink: 0;
}

.layer-item label { 
  flex: 1; 
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Opacity slider */
.layer-opacity {
  width: 60px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  flex-shrink: 0;
}

.layer-opacity::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--iv-green);
  border-radius: 50%;
  cursor: pointer;
}

.layer-opacity::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--iv-green);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.opacity-display {
  font-size: 11px;
  color: var(--text-muted);
  width: 32px;
  text-align: right;
  flex-shrink: 0;
}

/* Tools panel */
.tool-section { margin-bottom: 12px; }

.section-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.tool-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 10px;
  color: var(--text-muted);
  transition: all 0.15s;
}

.tool-btn span { font-size: 18px; line-height: 1; }
.tool-btn:hover { border-color: var(--iv-green); color: var(--iv-green); }
.tool-btn.active { background: var(--iv-green); color: white; border-color: var(--iv-green); }

.map { flex: 1; }

/* Hide Geoman default controls — we use sidebar instead */
.maplibregl-ctrl-top-left .maplibregl-ctrl { display: none !important; }

/* Measurements section */
.measurements-display {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
}

.measure-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

.measure-row.measure-secondary {
  padding-top: 0;
  margin-top: -4px;
}

.measure-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.measure-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.measure-secondary .measure-value {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.unit-toggle {
  width: 100%;
  margin-top: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--panel-bg);
  cursor: pointer;
}

.unit-toggle:focus {
  outline: none;
  border-color: var(--iv-green);
}

#measurements-section .section-header {
  margin-bottom: 8px;
}

/* Report popup styles */
.report-popup {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  line-height: 1.4;
}

.report-popup strong {
  font-size: 14px;
  color: var(--text-primary);
}

.popup-date {
  color: var(--text-muted);
  font-size: 12px;
}

.popup-area {
  font-weight: 600;
  color: var(--text-primary);
}

.popup-link {
  display: inline-block;
  margin-top: 6px;
  color: var(--reports-blue);
  text-decoration: none;
  font-weight: 600;
}

.popup-link:hover {
  text-decoration: underline;
}

/* MapLibre popup overrides */
.maplibregl-popup-content {
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.maplibregl-popup-close-button {
  font-size: 18px;
  color: var(--text-muted);
  padding: 4px 8px;
}

/* =========================================
   Reports Tab - Wizard Flow
   ========================================= */
.wizard-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wizard-step {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.step-number {
  width: 24px;
  height: 24px;
  background: var(--iv-green);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.step-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.step-description {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 12px;
}

.step-hint {
  font-size: 12px;
  color: var(--reports-blue);
  font-style: italic;
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(51, 136, 255, 0.1);
  border-radius: 6px;
}

.wizard-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-right: 8px;
}

.wizard-btn.primary {
  background: var(--iv-green);
  color: white;
}

.wizard-btn.primary:hover { background: var(--iv-green-dark); }

.wizard-btn.secondary {
  background: white;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.wizard-btn.secondary:hover {
  border-color: var(--iv-green);
  color: var(--iv-green);
}

.wizard-btn.danger {
  background: white;
  border: 1px solid #ef4444;
  color: #ef4444;
}

.wizard-btn.danger:hover {
  background: #ef4444;
  color: white;
}

.no-results {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--iv-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.duplicates-intro {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* =========================================
   Duplicate Picker Modal
   ========================================= */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: white;
  border-radius: 12px;
  max-width: 720px;
  max-height: 80vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.report-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.report-tile {
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: white;
}

.report-tile:hover { border-color: #94a3b8; }

.report-tile.selected {
  border-color: var(--iv-green);
  box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.2);
}

.tile-map {
  height: 100px;
  background: #e2e8f0;
}

.tile-info { padding: 10px 12px; }

.tile-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.tile-address {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

.tile-meta .has-photos { color: var(--iv-green); }

.cluster-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.cluster-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.cluster-label {
  font-size: 12px;
  font-weight: 600;
}

.cluster-count {
  font-size: 11px;
  color: var(--text-muted);
}

.cluster-btn {
  width: 100%;
  padding: 8px;
  background: white;
  border: 1px solid var(--reports-blue);
  color: var(--reports-blue);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.cluster-btn:hover {
  background: var(--reports-blue);
  color: white;
}

/* Pagination controls */
.pagination-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.pagination-controls #page-info {
  font-size: 13px;
  color: var(--text-muted);
}

/* Wizard action buttons row */
.wizard-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.wizard-actions .wizard-btn {
  flex: 1;
}

/* Mini map in tiles */
.tile-map {
  height: 120px;
  background: #1a1a2e;
  position: relative;
}

.tile-map .maplibregl-map {
  width: 100%;
  height: 100%;
}

.tile-map .maplibregl-ctrl-attrib {
  display: none !important;
}

.tile-map .maplibregl-ctrl-logo {
  display: none !important;
}

/* ========== EXPORT TAB ========== */

.export-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.export-section:last-child {
  border-bottom: none;
}

.export-section .section-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.export-section .section-description {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

.export-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #fef3c7;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
}

.export-status.ready {
  background: #d1fae5;
}

.export-status.ready .status-icon {
  color: var(--iv-green);
}

.export-status .status-icon {
  font-size: 16px;
}

.export-status .status-text {
  color: var(--text-primary);
}

/* Project report list */
.project-report-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 12px 0;
}

.project-report-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.project-report-item:last-child {
  border-bottom: none;
}

.project-report-item:hover {
  background: #f1f5f9;
}

.project-report-item.selected {
  background: #d1fae5;
}

.project-report-item input[type="checkbox"] {
  flex-shrink: 0;
}

.project-report-item .report-info {
  flex: 1;
  min-width: 0;
}

.project-report-item .report-address {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-report-item .report-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.project-report-item .report-area {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}