/* ---- Add Bar ---- */
.gl-add-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  align-items: stretch;
}

.gl-add-name {
  flex: 1;
  min-width: 160px;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--color-text);
  background: var(--color-surface);
  min-height: 44px;
  outline: none;
}

.gl-add-name:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.gl-add-qty {
  width: 60px;
  padding: 10px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--color-text);
  background: var(--color-surface);
  min-height: 44px;
  text-align: center;
  outline: none;
}

.gl-add-qty:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.gl-add-category {
  width: 140px;
  padding: 10px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.84rem;
  color: var(--color-text);
  background: var(--color-surface);
  min-height: 44px;
  outline: none;
  cursor: pointer;
}

.gl-add-category:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.gl-add-btn {
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  white-space: nowrap;
  transition: background var(--transition-fast);
}

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

/* ---- Status Bar ---- */
.gl-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.gl-status-counts {
  font-weight: 600;
}

.gl-status-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.gl-btn-clear-checked {
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.gl-btn-clear-checked:hover {
  color: var(--color-text);
  background: var(--color-surface-hover);
}

.gl-hide-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  user-select: none;
}

.gl-hide-toggle input[type="checkbox"] {
  accent-color: var(--color-primary);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* ---- List Container ---- */
.gl-list {
  min-height: 60px;
}

/* ---- Category Header ---- */
.gl-category-header {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 14px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--color-border-light);
}

.gl-category-header:first-child {
  margin-top: 0;
}

/* ---- Item Row ---- */
.gl-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 4px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  transition: box-shadow var(--transition-fast), opacity var(--transition-fast);
}

.gl-item:hover {
  box-shadow: var(--shadow-sm);
}

/* Checked state */
.gl-item.checked {
  opacity: 0.45;
}

.gl-item.checked .gl-name,
.gl-item.checked .gl-qty-display {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

/* ---- Custom Checkbox ---- */
.gl-check {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}

.gl-check input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.gl-checkmark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 2px solid var(--color-border);
  border-radius: 5px;
  background: var(--color-surface);
  transition: all var(--transition-fast);
  font-size: 0;
  color: #fff;
}

.gl-check input:checked + .gl-checkmark {
  background: #38a169;
  border-color: #38a169;
  font-size: 13px;
}

/* ---- Inline Editable Fields ---- */
.gl-name {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--color-text);
  background: transparent;
  outline: none;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.gl-name:hover {
  border-color: var(--color-border-light);
}

.gl-name:focus {
  border-color: var(--color-primary);
  background: var(--color-surface);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.gl-qty-display {
  width: 50px;
  padding: 6px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono, var(--font-body));
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  background: transparent;
  text-align: center;
  outline: none;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.gl-qty-display:hover {
  border-color: var(--color-border-light);
}

.gl-qty-display:focus {
  border-color: var(--color-primary);
  background: var(--color-surface);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.gl-qty-display::-webkit-inner-spin-button,
.gl-qty-display::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.gl-qty-display {
  -moz-appearance: textfield;
}

/* ---- Inline Category Select ---- */
.gl-cat-select {
  width: 110px;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.76rem;
  color: var(--color-text-muted);
  background: transparent;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.gl-cat-select:hover {
  border-color: var(--color-border-light);
}

.gl-cat-select:focus {
  border-color: var(--color-primary);
  background: var(--color-surface);
}

/* ---- Drag Handle ---- */
.drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  cursor: grab;
  color: var(--color-text-muted);
  font-size: 1rem;
  opacity: 0.3;
  transition: opacity var(--transition-fast);
  user-select: none;
  touch-action: none;
  border: none;
  background: transparent;
  padding: 0;
  border-radius: 4px;
}

.drag-handle:hover {
  opacity: 1;
  background: var(--color-surface-hover);
}

.drag-handle:active {
  cursor: grabbing;
}

/* ---- Dragging State ---- */
.gl-item.dragging {
  opacity: 0.35;
  background: var(--color-bg);
}

.drop-indicator {
  height: 3px;
  background: var(--color-primary);
  border-radius: 2px;
  margin: 2px 0;
  transition: opacity 120ms ease;
}

/* ---- Remove Button ---- */
.gl-remove {
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  padding: 0;
  flex-shrink: 0;
  opacity: 0.35;
  transition: all var(--transition-fast);
}

.gl-remove:hover {
  opacity: 1;
  background: var(--color-surface-hover);
}

/* ---- Empty State ---- */
.gl-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--color-text-muted);
  font-size: 0.88rem;
}

.gl-empty-icon {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

/* ---- Action Bar ---- */
.plan-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  margin-bottom: 16px;
}

.saved-status {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  align-self: center;
}

/* ---- Toast ---- */
.toast-msg {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--color-text);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 1000;
  pointer-events: none;
}

.toast-msg.show {
  opacity: 1;
  transform: translateY(0);
}

/* ---- Muted Note ---- */
.muted-note {
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .gl-add-bar {
    gap: 6px;
  }

  .gl-add-name {
    width: 100%;
    flex: none;
  }

  .gl-add-qty {
    flex: 0 0 55px;
  }

  .gl-add-category {
    flex: 1;
    width: auto;
    min-width: 100px;
  }

  .gl-add-btn {
    flex: 0 0 auto;
  }

  .gl-cat-select {
    width: 80px;
  }

  .gl-status {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .gl-status-actions {
    margin-left: 0;
  }
}

@media (max-width: 480px) {
  .gl-add-category {
    min-width: 80px;
  }

  .gl-item {
    gap: 6px;
    padding: 8px 10px;
  }

  .gl-cat-select {
    display: none;
  }
}

@media print {
  .gl-add-bar,
  .plan-row,
  .gl-status-actions,
  .drag-handle,
  .gl-remove,
  .toast-msg,
  .ad-zone {
    display: none !important;
  }

  .gl-item.checked {
    opacity: 0.6;
  }

  .gl-name {
    border: none !important;
    padding: 0;
  }
}
