:root {
  --bg: #f6f4ed;
  --surface: #ffffff;
  --text: #24301f;
  --text-muted: #5b6b54;
  --border: #e0ddd0;
  --primary: #3f7d3f;
  --primary-dark: #2f5f2f;
  --accent: #c97b3f;
  --danger: #b3432f;
  --chip-good-bg: #e5f2e1;
  --chip-good-text: #2f5f2f;
  --chip-bad-bg: #fbe7e2;
  --chip-bad-text: #9a3b23;
  --chip-additive-bg: #f3ecd8;
  --chip-additive-text: #7a5a1e;
  --shadow: 0 2px 10px rgba(40, 50, 30, 0.08);
  --radius: 14px;
}

:root[data-theme="dark"] {
  --bg: #171d15;
  --surface: #212a1d;
  --text: #e8ecdf;
  --text-muted: #a3b096;
  --border: #34402d;
  --primary: #6fbf6f;
  --primary-dark: #8fd68f;
  --accent: #e0a06a;
  --danger: #e08064;
  --chip-good-bg: #23331f;
  --chip-good-text: #8fd68f;
  --chip-bad-bg: #3a2620;
  --chip-bad-text: #e79a80;
  --chip-additive-bg: #332c1a;
  --chip-additive-text: #e0c17f;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171d15;
    --surface: #212a1d;
    --text: #e8ecdf;
    --text-muted: #a3b096;
    --border: #34402d;
    --primary: #6fbf6f;
    --primary-dark: #8fd68f;
    --accent: #e0a06a;
    --danger: #e08064;
    --chip-good-bg: #23331f;
    --chip-good-text: #8fd68f;
    --chip-bad-bg: #3a2620;
    --chip-bad-text: #e79a80;
    --chip-additive-bg: #332c1a;
    --chip-additive-text: #e0c17f;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background 0.2s, color 0.2s;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 2rem;
}

.brand h1 {
  margin: 0;
  font-size: 1.4rem;
  color: var(--primary-dark);
}

.tagline {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
}

#searchInput {
  flex: 1 1 260px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
}

#searchInput:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.category-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.88rem;
  transition: all 0.15s;
}

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

.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.crop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.crop-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}

.crop-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 18px rgba(40, 50, 30, 0.15);
}

.crop-card img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  background: var(--border);
}

.crop-card-body {
  padding: 12px 14px 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.crop-card-body h3 {
  margin: 0;
  font-size: 1.05rem;
}

.category-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--chip-additive-bg);
  color: var(--chip-additive-text);
}

.crop-card-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: auto;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
}

.hidden {
  display: none !important;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  cursor: pointer;
  font-size: 1.05rem;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:hover {
  opacity: 0.88;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary-dark);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-small {
  padding: 5px 12px;
  font-size: 0.8rem;
}

.site-footer {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 25, 15, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 640px;
  width: 100%;
  padding: 28px;
  position: relative;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

.modal-small {
  max-width: 380px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
}

.detail-image {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 16px;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-header h2 {
  margin: 0;
}

.detail-actions {
  display: flex;
  gap: 8px;
}

.detail-section {
  margin-top: 18px;
}

.detail-section h4 {
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
}

.chip-good {
  background: var(--chip-good-bg);
  color: var(--chip-good-text);
}

.chip-bad {
  background: var(--chip-bad-bg);
  color: var(--chip-bad-text);
}

.additive-item {
  margin-bottom: 8px;
}

.additive-item strong {
  color: var(--chip-additive-text);
}

/* Forms */
#cropForm label,
#passwordForm label {
  display: block;
  margin-bottom: 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

#cropForm input[type="text"],
#cropForm input[type="password"],
#cropForm input[type="file"],
#cropForm select,
#cropForm textarea,
#passwordForm input {
  width: 100%;
  margin-top: 6px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.92rem;
  font-family: inherit;
}

.hint {
  font-weight: normal;
  opacity: 0.7;
}

.field-block {
  margin-bottom: 16px;
}

.field-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.dodatak-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.dodatak-row input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
}

.dodatak-row .dodatak-naziv {
  flex: 0 0 150px;
}

.dodatak-row .dodatak-opis {
  flex: 1;
}

.dodatak-row button {
  border: none;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.1rem;
}

.img-preview {
  margin-top: 10px;
  max-width: 100%;
  max-height: 160px;
  border-radius: 8px;
  object-fit: cover;
}

.form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  gap: 10px;
  flex-wrap: wrap;
}

.form-actions-right {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.form-error {
  color: var(--danger);
  font-size: 0.85rem;
}
