/* ==============================
   Crop Library / Såkalender
   ============================== */

/* --- Zone Selector --- */
.zone-selector-wrap {
  margin-bottom: var(--spacing-4);
}

.zone-selector {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}

.zone-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--color-surface, #f5f5f5);
  color: var(--color-text, #333);
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
  transition: all 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer;
}

.zone-btn:hover {
  background: var(--color-primary-light, #4A7C59);
  color: white;
  transform: scale(1.08);
}

.zone-btn-active {
  background: var(--color-primary, #2d6a4f) !important;
  color: white !important;
  border-color: var(--color-primary-dark, #1b4332) !important;
  transform: scale(1.08);
}

.zone-btn-auto {
  border-color: var(--color-primary, #2d6a4f);
  border-style: dashed;
}

.zone-label {
  font-size: 0.85rem;
  color: var(--color-muted, #666);
}

.zone-days {
  font-size: 0.75rem;
  margin-left: 4px;
  opacity: 0.7;
}

/* --- Plant Now Panel --- */
.plant-now-panel {
  background: var(--color-surface, #f9f9f9);
  border: 1px solid var(--color-border, #ddd);
  border-radius: var(--radius-md, 8px);
  padding: var(--spacing-4, 16px);
  margin-bottom: var(--spacing-4, 16px);
}

.plant-now-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-3, 12px);
  margin-bottom: var(--spacing-3, 12px);
}

.season-badge {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-primary, #2d6a4f);
}

.current-week-badge {
  font-size: 0.85rem;
  background: var(--color-primary, #2d6a4f);
  color: white;
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 600;
}

.plant-now-group {
  margin-bottom: var(--spacing-3, 12px);
}

.plant-now-group:last-child {
  margin-bottom: 0;
}

.plant-now-type {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-muted, #666);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--color-border, #eee);
}

.plant-now-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 0;
}

.plant-now-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.plant-now-meta {
  color: var(--color-muted, #888);
  font-size: 0.8rem;
}

.plant-now-empty {
  color: var(--color-muted, #888);
  font-style: italic;
  font-size: 0.9rem;
}

/* --- Toolbar --- */
.crops-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-4, 16px);
  gap: var(--spacing-3, 12px);
}

/* --- View Toggle --- */
.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--color-surface, #f0f0f0);
  border-radius: 6px;
  padding: 3px;
}

.view-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-muted, #666);
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
}

.view-toggle-btn:hover {
  color: var(--color-primary, #2d6a4f);
}

.view-toggle-active {
  background: white;
  color: var(--color-primary, #2d6a4f);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* --- Gantt Bar Chart --- */
.bar-chart-wrapper {
  overflow-x: auto;
}

.gantt-chart {
  min-width: 600px;
}

.chart-header {
  display: flex;
  gap: 8px;
  height: 28px;
  margin-bottom: 2px;
}

.chart-header-spacer {
  width: 160px;
  flex-shrink: 0;
}

.month-labels {
  position: relative;
  flex: 1;
  height: 100%;
}

.month-header {
  position: absolute;
  top: 0;
  height: 100%;
  display: flex;
  align-items: flex-end;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-muted, #888);
  padding-bottom: 2px;
  box-sizing: border-box;
}

.chart-body {
  border-top: 1px solid var(--color-border, #eee);
}

.crop-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--color-border, #f5f5f5);
  min-height: 32px;
}

.crop-bar-row:hover {
  background: var(--color-surface, #fafafa);
}

.crop-bar-label {
  width: 160px;
  flex-shrink: 0;
}

.crop-bar-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  position: relative;
  flex: 1;
  min-width: 400px;
}

.month-grid-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 100%;
  background: var(--color-border, #ddd);
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}

.activity-bar-group {
  position: relative;
  height: 16px;
  margin-bottom: 1px;
}

.activity-bar-range {
  position: absolute;
  top: 0;
  height: 14px;
  pointer-events: none;
}

.activity-bar {
  position: absolute;
  top: 0;
  height: 14px;
  border-radius: 3px;
  opacity: 0.9;
  transition: opacity 0.15s ease;
  display: flex;
  align-items: center;
  padding: 0 4px;
  box-sizing: border-box;
  overflow: hidden;
  z-index: 1;
}

.activity-bar:hover {
  opacity: 1;
  z-index: 2;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.bar-label {
  font-size: 0.6rem;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.current-week-line {
  position: absolute;
  top: -2px;
  width: 2px;
  height: 32px;
  background: var(--color-danger, #e63946);
  z-index: 3;
  pointer-events: none;
}

.current-week-line::before {
  content: "";
  position: absolute;
  top: -4px;
  left: -4px;
  width: 10px;
  height: 10px;
  background: var(--color-danger, #e63946);
  border-radius: 50%;
}

/* --- Legend --- */
.chart-legend {
  display: flex;
  gap: var(--spacing-4, 16px);
  margin-top: var(--spacing-3, 12px);
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--color-muted, #666);
}

.legend-explanation {
  width: 100%;
  font-size: 0.75rem;
  color: var(--color-muted, #888);
  margin-top: 2px;
}

.legend-swatch {
  width: 16px;
  height: 12px;
  border-radius: 2px;
}

/* --- Data Table --- */
.table-wrapper {
  overflow-x: auto;
}

.crop-table {
  width: 100%;
  font-size: 0.85rem;
}

.crop-table th {
  white-space: nowrap;
  font-size: 0.8rem;
}

.crop-table td {
  white-space: nowrap;
  padding: 6px 12px;
}

/* --- Crop Form --- */
.crop-form {
  max-width: 600px;
  margin: 0 auto;
}

.crop-form-header {
  margin-bottom: var(--spacing-4, 16px);
}

.crop-form .form-actions {
  display: flex;
  gap: var(--spacing-3, 12px);
  margin-top: var(--spacing-4, 16px);
}

/* --- Crop Page Layout --- */
.crops-page {
  padding-bottom: var(--spacing-6, 48px);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .crop-bar-label {
    width: 110px;
  }

  .crop-bar-name {
    font-size: 0.8rem;
  }

  .zone-btn {
    width: 38px;
    height: 38px;
    font-size: 0.8rem;
  }

  .plant-now-panel {
    padding: var(--spacing-3, 12px);
  }
}
