/* Harela PWA - mobile-first, matches React Native app theme */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans Devanagari', sans-serif;
  background: #E8F5E9;
  color: #333;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.collection-closed {
  margin: 16px;
  padding: 20px;
  background: #FFF3E0;
  border: 2px solid #EF6C00;
  border-radius: 12px;
  color: #E65100;
  font-size: 16px;
  line-height: 1.6;
  text-align: center;
  font-weight: 600;
}

/* Loading */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  background: #E8F5E9;
  gap: 12px;
}
.loading-screen p { color: #2E7D32; font-size: 16px; }
.spinner {
  width: 40px; height: 40px;
  border: 4px solid #C8E6C9;
  border-top-color: #2E7D32;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* App layout */
.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.header {
  background: #1B5E20;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  text-align: center;
}
.header h1 {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
}
.header p {
  font-size: 16px;
  color: #C8E6C9;
  margin-top: 4px;
}

/* Form boxes */
.form-box {
  background: #fff;
  border-radius: 12px;
  border: 1.5px solid #2E7D32;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}
.form-box-title {
  font-size: 16px;
  font-weight: 700;
  color: #1B5E20;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #C8E6C9;
}

.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
}
.req {
  color: #C62828;
  font-weight: 700;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid #BDBDBD;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 16px;
  background: #FAFAFA;
  color: #333;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.field select:disabled {
  opacity: 0.5;
  background-color: #EEEEEE;
}
.field textarea { resize: vertical; min-height: 60px; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: #2E7D32;
  box-shadow: 0 0 0 2px rgba(46,125,50,0.15);
}

.section-label {
  font-size: 15px;
  font-weight: 700;
  color: #1B5E20;
  margin: 8px 0;
  padding-left: 8px;
  border-left: 3px solid #4CAF50;
}

/* DMS inputs */
.dms-group { margin-bottom: 12px; }
.dms-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin-bottom: 6px;
}
.dms-geofence-hint {
  font-size: 11px;
  color: #558B2F;
  font-style: italic;
  margin: -2px 0 8px;
}
.dms-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.dms-field label {
  display: block;
  font-size: 11px;
  color: #666;
  text-align: center;
  margin-bottom: 2px;
}
.dms-field input.invalid {
  border-color: #C62828;
  background: #FFEBEE;
}
.dms-field input {
  width: 100%;
  border: 1px solid #BDBDBD;
  border-radius: 8px;
  padding: 10px 8px;
  font-size: 14px;
  text-align: center;
  background: #FAFAFA;
}
.dms-field input:invalid:not(:placeholder-shown) {
  border-color: #C62828;
}

/* Species rows */
.species-row {
  background: #F1F8E9;
  border: 1px solid #C8E6C9;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}
.species-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.species-row-header span {
  font-size: 14px;
  font-weight: 600;
  color: #2E7D32;
}
.btn-remove {
  background: #FFEBEE;
  color: #C62828;
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.species-search {
  width: 100%;
  border: 1px solid #BDBDBD;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  margin-bottom: 8px;
  background: #fff;
}
.species-row select {
  width: 100%;
  border: 1px solid #BDBDBD;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
  margin-bottom: 8px;
}
.species-category {
  font-size: 12px;
  color: #558B2F;
  font-style: italic;
  margin-bottom: 8px;
}
.quantity-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.quantity-row label {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.quantity-row input {
  flex: 1;
  border: 1px solid #BDBDBD;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  text-align: center;
  background: #fff;
}

.btn-add {
  width: 100%;
  border: 1px dashed #2E7D32;
  border-radius: 8px;
  padding: 10px;
  background: transparent;
  color: #2E7D32;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
}
.btn-add:active { background: #F1F8E9; }

/* Location blocks */
.location-block {
  border: 2px solid #1B5E20;
  border-radius: 14px;
  margin-bottom: 20px;
  overflow: hidden;
  background: #fff;
}
.location-block-header {
  background: #2E7D32;
  color: #fff;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.location-block-header h3 {
  font-size: 16px;
  font-weight: 700;
}
.btn-remove-location {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.location-block-body {
  padding: 16px;
}
.location-block-body .form-box {
  border-color: #C8E6C9;
  margin-bottom: 12px;
}
.location-block-body .form-box:last-child {
  margin-bottom: 0;
}
.btn-add-location {
  width: 100%;
  border: 2px dashed #1B5E20;
  border-radius: 12px;
  padding: 14px;
  background: #fff;
  color: #1B5E20;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 16px;
}
.btn-add-location:active { background: #E8F5E9; }

.location-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.btn-secondary {
  border: 2px solid #1B5E20;
  border-radius: 12px;
  padding: 14px 10px;
  background: #fff;
  color: #1B5E20;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn-secondary:active { background: #E8F5E9; }
.btn-secondary:disabled,
.btn-add-location:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.saved-locations-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.saved-location-item {
  padding: 10px 12px;
  border: 1px solid #C8E6C9;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 14px;
  background: #F1F8E9;
}
.saved-location-item small {
  color: #558B2F;
}
.draft-label {
  font-size: 12px;
  color: #666;
  margin-top: 8px;
  text-align: center;
}

.btn-submit {
  width: 100%;
  background: #1B5E20;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 16px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  box-shadow: 0 3px 4px rgba(0,0,0,0.2);
}
.btn-submit:active { opacity: 0.85; }
.btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.footer-space { height: 40px; }

/* Toast */
.toast {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  max-width: 448px;
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: slideDown 0.3s ease;
}
.toast.success { background: #1B5E20; color: #fff; }
.toast.error { background: #C62828; color: #fff; }
@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* iPhone standalone PWA */
@media (display-mode: standalone) {
  .app { padding-top: max(24px, env(safe-area-inset-top)); }
}
