
:root {
  --bg: #f4f7f2;
  --surface: #ffffff;
  --surface-soft: #f8faf7;
  --border: #d7e1d1;
  --text: #203024;
  --muted: #62746a;
  --primary: #1f7a45;
  --primary-dark: #145c31;
  --danger: #c0392b;
  --shadow: 0 10px 24px rgba(17, 41, 26, 0.08);
  --radius: 1rem;
  --card-bg: #ffffff;
  --primary-hover: #165c33;
  --focus-ring: rgba(31, 122, 69, 0.25);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, #eef5eb 0%, var(--bg) 100%);
  background-color: var(--bg);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.5;
}

.app-shell {
  min-height: 100vh;
  padding: 1rem;
  width: 100%;
  margin: 2rem auto;
}

.form-card {
  width: 100%;
  margin: 0 auto 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.form-header {
  padding: 1.5rem;
  background: linear-gradient(135deg, #1f7a45 0%, #2e8b57 100%);
  color: #fff;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
  
  
  color: white;
  font-weight: bold;
  font-size: 1.25rem;
}

.brand-logo svg {
  width: 28px;
  height: 28px;
}

.form-header h1 {
  font-size: clamp(1.5rem, 1.1rem + 1vw, 2rem);
  margin: 0;
  font-weight: 700;
}

.form-header p {
  margin: 0.375rem 0 0;
  max-width: 62ch;
  color: rgba(255, 255, 255, 0.86);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all 0.2s ease-in-out;
}

.stat-card.clickable {
  cursor: pointer;
  user-select: none;
}

.stat-card.clickable:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.stat-card.active-filter-total {
  border: 2px solid #0d6efd !important;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.2) !important;
  background-color: rgba(13, 110, 253, 0.03);
}

.stat-card.active-filter-completed {
  border: 2px solid #198754 !important;
  box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.2) !important;
  background-color: rgba(25, 135, 84, 0.03);
}

.stat-card.active-filter-pending {
  border: 2px solid #ffc107 !important;
  box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.25) !important;
  background-color: rgba(255, 193, 7, 0.03);
}

.form-body {
  padding: 1.5rem;
  background: var(--surface);
}

.section-card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  height: 100%;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 1rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.section-title i {
  color: var(--primary);
  font-size: 1rem;
}

.form-label {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.45rem;
}

.required-star {
  color: var(--danger);
}

.form-control,
.form-select {
  min-height: 48px;
  border-radius: 0.85rem;
  border-color: #cfdacb;
  padding: 0.75rem 0.9rem;
  box-shadow: none;
}

.form-control[readonly] {
  background-color: #e9ecef;
  cursor: not-allowed;
}

textarea.form-control {
  min-height: 120px;
  resize: vertical;
}

.form-control:focus,
.form-select:focus {
  border-color: rgba(31, 122, 69, 0.55);
  box-shadow: 0 0 0 0.2rem rgba(31, 122, 69, 0.12);
}

.hint-text {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.toggle-wrap {
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: 0.9rem;
  padding: 0.9rem 1rem;
}

.image-upload-box {
  position: relative;
  border: 1.5px dashed #bfcfba;
  border-radius: 1rem;
  background: #fff;
  padding: 1rem;
  min-height: 100%;
  transition: all 0.2s ease;
}

.field-hidden {
  display: none !important;
}

label.error {
  color: var(--danger);
  font-size: 0.825rem;
  margin-top: 0.35rem;
  display: block;
  font-weight: 500;
}

.form-control.error,
.form-select.error,
.select2-container--bootstrap-5.select2-container.error .select2-selection,
.is-invalid-file {
  border-color: rgba(192, 57, 43, 0.8) !important;
}

.btn-submit {
  min-height: 50px;
  border-radius: 0.9rem;
  padding-inline: 1.4rem;
  font-weight: 700;
  background: var(--primary);
  border-color: var(--primary);
}

.btn-submit:hover,
.btn-submit:focus {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.footer-note {
  color: var(--muted);
  font-size: 0.875rem;
}

/* Sidebar Styles */
.app-wrapper {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 280px;
  background-color: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  z-index: 1050;
  flex-shrink: 0;
  height: auto;
  min-height: 100vh;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.sidebar-nav {
  flex-grow: 1;
  padding: 1rem;
  overflow-y: auto;
}

.nav-link {
  color: var(--text);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  text-decoration: none;
}

.nav-link:hover {
  background-color: var(--surface-soft);
  color: var(--primary);
}

.nav-link.active {
  background-color: var(--primary);
  color: white !important;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.main-content {
  flex-grow: 1;
  overflow-y: auto;
  height: 100vh;
  position: relative;
  transition: width 0.3s ease, margin 0.3s ease;
}



.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.5);
  z-index: 1040;
}

.stat-card {
  background: var(--card-bg);
  border-radius: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  transition: transform 0.2s;
}

.stat-card.clickable {
  cursor: pointer;
}

.stat-card.clickable:hover {
  transform: translateY(-2px);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-icon.primary { background: rgba(31, 122, 69, 0.1); color: var(--primary); }
.stat-icon.success { background: rgba(25, 135, 84, 0.1); color: #198754; }
.stat-icon.warning { background: rgba(255, 193, 7, 0.1); color: #ffc107; }
.stat-icon.danger { background: rgba(220, 53, 69, 0.1); color: #dc3545; }

.stat-content {
  flex-grow: 1;
}

.stat-label {
  font-size: 0.875rem;
  color: #6c757d;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.pulse-animation {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4); }
  70% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(220, 53, 69, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

.login-card {
  background: var(--card-bg);
  border-radius: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
}

.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
  padding: 0.75rem;
  font-weight: 600;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
}

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

.text-primary-bold {
  color: var(--primary);
  font-weight: 700;
}

.text-sm-custom {
  font-size: 0.85rem;
}

@media (max-width: 768px) {

  .form-header p {
    display: none;
  }
  
  .brand-logo {
    width: 36px;
    height: 36px;
    font-size: 0.875rem;
  } .brand-logo-img { height: 36px; }
  .form-header h1 {
    font-size: 1.25rem;
  }

  .app-shell {
    margin: 0;
    padding: 0;
  }
  .form-card {
    border-radius: 0;
  }
  .form-header,
  .form-body {
    padding: 1rem;
  }
  .section-card {
    padding: 1rem;
  }
  
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
  }
  .sidebar.show {
    left: 0;
  }
  
  .sidebar-backdrop.show {
    display: block !important;
  }
}

.select2-container--bootstrap-5 .select2-selection--single {
  min-height: 48px;
  border-radius: 0.85rem;
  border-color: #cfdacb;
  padding: 0.375rem 0.75rem;
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
  border-color: rgba(31, 122, 69, 0.55);
  box-shadow: 0 0 0 0.2rem rgba(31, 122, 69, 0.12);
}






@media (min-width: 769px) {
  .app-wrapper.sidebar-hidden #sidebar-container {
    margin-left: -280px;
  }
  
  /* When sidebar is visible, push toggle button inside sidebar header or next to it */}




@media (max-width: 991px) {
  .form-header p {
    display: none;
  }
  
  .brand-logo {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  } .brand-logo-img { height: 40px; }
  .form-header h1 {
    font-size: 1.35rem;
  }
  .form-header {
    padding: 1rem;
  }
  .brand-row {
    flex-wrap: nowrap;
  }
}

/* Scroll to Top Button */
.scroll-to-top {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background-color: var(--primary);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(31, 122, 69, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.2s ease, background-color 0.2s ease;
  z-index: 1050;
}

.scroll-to-top.show {
  opacity: 1;
  visibility: visible;
}

.scroll-to-top:hover {
  transform: translateY(-3px);
  background-color: var(--primary-dark);
  color: white;
}

.brand-logo-img {
  height: 48px;
  width: auto;
  max-width: 150px;
  object-fit: contain;
  flex-shrink: 0;
}


#sidebar-container {
  display: block;
  width: 280px;
  flex-shrink: 0;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}
@media (max-width: 768px) {
  #sidebar-container {
    width: 0;
    min-height: 0;
  }
}

/* Page Loader */
#page-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

#page-loader.hidden {
  opacity: 0;
  visibility: hidden;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(31, 122, 69, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* ============================================================================
   Font-size utilities (Bootstrap ships fs-1..fs-6 only)
   ============================================================================ */
.fs-7 { font-size: 0.85rem !important; }
.fs-8 { font-size: 0.75rem !important; }

/* ============================================================================
   Image / video preview thumbnails
   ============================================================================ */
.preview-wrap img,
.preview-wrap .preview-img-thumb {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: cover !important;
  object-position: center !important;
  border-radius: 0.625rem;
  display: block;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.preview-wrap img:hover {
  transform: scale(1.03);
}

.video-preview-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.8rem;
  text-align: center;
  padding: 0.5rem;
  width: 100%;
  height: 100%;
}

.video-preview-badge .file-name-tag {
  max-width: 90%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #203024;
}

/* ============================================================================
   Farmer autocomplete dropdown
   ============================================================================ */
.farmer-autocomplete-wrapper {
  position: relative;
  width: 100%;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1050;
  background: #ffffff;
  border: 1px solid #bcd4bf;
  border-radius: 0.625rem;
  box-shadow: 0 12px 28px rgba(20, 50, 30, 0.12);
  max-height: 280px;
  overflow-y: auto;
  margin-top: 4px;
}

.autocomplete-dropdown-header {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #4a6b52;
  padding: 0.5rem 0.875rem;
  background: #f4f8f3;
  border-bottom: 1px solid #e2ece0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.autocomplete-item {
  padding: 0.625rem 0.875rem;
  cursor: pointer;
  border-bottom: 1px solid #f0f4ee;
  transition: all 0.15s ease-in-out;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

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

.autocomplete-item:hover,
.autocomplete-item.active {
  background-color: #ebf5e9;
}

.autocomplete-item .farmer-name-text {
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.autocomplete-item .farmer-meta-text {
  font-size: 0.8125rem;
  color: #556b5d;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.autocomplete-item.new-entry-option {
  background-color: #fafcf9;
  border-top: 1px dashed #c8dec6;
}

.autocomplete-item.new-entry-option:hover {
  background-color: #f0f7ee;
}

/* ============================================================================
   Locked field / disabled select styling
   ============================================================================ */
.is-locked {
  background-color: #f3f6f3 !important;
  color: #3b4d40 !important;
  border-color: #cbd8cc !important;
  cursor: not-allowed;
}

.form-select:disabled,
.select2-container--bootstrap-5.select2-container--disabled .select2-selection {
  background-color: #f3f6f3 !important;
  color: #556b5d !important;
  cursor: not-allowed !important;
  border-color: #cbd8cc !important;
  opacity: 0.85;
}

.lock-badge {
  font-size: 0.725rem;
  font-weight: 500;
  padding: 0.25em 0.55em;
  vertical-align: middle;
}

/* ============================================================================
   Observation block lock / active styles
   ============================================================================ */
.obs-block {
  transition: all 0.3s ease;
  border-radius: 0.875rem;
  padding: 1.125rem;
  margin-bottom: 1.25rem;
}

.obs-block.obs-locked {
  background-color: #f5f8f5;
  border: 1px dashed #c9d8cb;
  opacity: 0.65;
  user-select: none;
  pointer-events: none;
}

/* Keep the header (badge/icon) itself readable even while the block is locked */
.obs-block.obs-locked .obs-header-title {
  pointer-events: auto;
}

.obs-block.obs-locked input,
.obs-block.obs-locked textarea,
.obs-block.obs-locked button {
  cursor: not-allowed !important;
  background-color: #eef3ee !important;
  border-color: #d1ded3 !important;
}

.obs-block.obs-active {
  background-color: #ffffff;
  border: 1.5px solid #2e8b57;
  opacity: 1;
  box-shadow: 0 4px 16px rgba(31, 122, 69, 0.08);
}

.obs-block.obs-completed {
  background-color: #fafcfa;
  border: 1px solid #d0ded2;
  opacity: 1;
}

.obs-header-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.875rem;
  transition: color 0.2s ease;
}

.obs-locked .obs-header-title {
  color: #63756a;
}

.obs-active .obs-header-title {
  color: #145c31;
}

.obs-completed .obs-header-title {
  color: #203024;
}
