/* Agrocolectiva mini-app de captura de polígonos — CDA-M F17 / PR12 */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1f2937;
}

#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: #166534;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

#header .title {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

#header .title strong { font-size: 16px; }
#header .title span { opacity: 0.8; font-size: 13px; }

#header .counters {
  display: flex;
  gap: 12px;
  font-size: 13px;
}

#map {
  position: fixed;
  top: 48px;
  left: 0;
  right: 320px;
  bottom: 0;
}

#sidebar {
  position: fixed;
  top: 48px;
  right: 0;
  width: 320px;
  bottom: 0;
  background: #f9fafb;
  border-left: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.toolbar {
  padding: 12px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: white;
}

.toolbar button {
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  background: white;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}

.toolbar button:hover:not(:disabled) {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.toolbar button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#btn-draw {
  background: #166534 !important;
  color: white;
  border-color: #14532d !important;
}

#btn-draw:hover:not(:disabled) {
  background: #14532d !important;
}

#btn-save-all {
  background: #2563eb !important;
  color: white;
  border-color: #1d4ed8 !important;
}

#btn-save-all:hover:not(:disabled) {
  background: #1d4ed8 !important;
}

#pending-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

#pending-list .empty {
  color: #6b7280;
  font-size: 13px;
  text-align: center;
  padding: 24px 12px;
  font-style: italic;
}

.parcela-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 10px;
}

.parcela-card.selected {
  border-color: #166534;
  box-shadow: 0 0 0 2px rgba(22, 101, 52, 0.15);
}

.parcela-card.saved {
  opacity: 0.6;
  background: #ecfdf5;
}

.parcela-card.error {
  border-color: #dc2626;
  background: #fef2f2;
}

.parcela-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.parcela-card header strong { font-size: 14px; }
.parcela-card header .area { font-size: 12px; color: #6b7280; }

.parcela-card label {
  display: block;
  font-size: 12px;
  color: #4b5563;
  margin-top: 6px;
}

.parcela-card input, .parcela-card select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 13px;
  margin-top: 2px;
}

.parcela-card .status-line {
  font-size: 12px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #f3f4f6;
}

.parcela-card .status-line.ok { color: #16a34a; }
.parcela-card .status-line.error { color: #dc2626; }

#messages {
  padding: 8px 12px;
  font-size: 12px;
  border-top: 1px solid #e5e7eb;
  max-height: 120px;
  overflow-y: auto;
  background: white;
}

#messages .msg {
  padding: 4px 0;
  border-bottom: 1px dashed #f3f4f6;
}

#messages .msg.error { color: #dc2626; }
#messages .msg.ok { color: #16a34a; }

/* Mobile: hide sidebar into a drawer, full-screen map */
@media (max-width: 768px) {
  #map { right: 0; }
  #sidebar {
    width: 100%;
    top: auto;
    height: 45vh;
    border-left: none;
    border-top: 1px solid #e5e7eb;
  }
}
